reactjs / reactjs/react-docgen
When postcss modules are present, in some scenarios react-docgen tries to parse css files
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 3.8k
- フォーク
- 316
- 平均マージ
- 5時間 7分
- マージ済み PR(30日)
- 4
説明
Background
In certain scenarios react-docgen tries to parse CSS modules.
This yields an error as follows:
Use case
See related Storybook issue https://github.com/storybookjs/storybook/issues/25662 and stackblitz reproduction https://stackblitz.com/edit/github-cwovgn-yvzreq
Have a component like so
import React from "react"
import styles, { stylesheet } from "./Container.module.css"
const Container = ({ children }) => (
<div>
{children}
</div>
)
export default Container;
export stylesheet;
And where the css file contains an @import
@import url("../../css/variables.css");
The babel config passed to react-docgen doesn't take into account the .babelrc file and attempts to parse the .css file as JavaScript.
This causes an error like so
[vite] Internal server error: /path/to/Container.module.css: Support for the experimental syntax 'decorators' isn't currently enabled (1:1):
Is there anyway to configure react-docgen to ignore .css files in this case?
If you're wondering why are we importing and exporting the processed stylesheet, we're building a critical css component that inlines CSS needed for the first paint. We're doing this by using rollup-post-css-modules to import postcss modules but also export the built stylesheet so it can be collated in a reliable fashion (ie the class names don't change from what is rendered in the component).
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている StackBlitz の再現と関連する Storybook issue から始め、コンポーネントが CSS モジュールを import および export するときに、react-docgen が提供された Babel 設定をどのように使用するかを追跡します。CSS ファイルが JavaScript として解析されなくなり、React コンポーネントのドキュメント抽出が引き続き機能すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- react, typescript
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100