reactjs / reactjs/react-docgen
Support Babel 8 in babelParser (loadPartialConfigSync)
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 3.8k
- フォーク
- 316
- 平均マージ
- 5時間 7分
- マージ済み PR(30日)
- 4
説明
Description
react-docgen@8.0.3 cannot parse components when its @babel/core dependency is resolved to Babel 8.
babelParser calls loadPartialConfig synchronously. Starting with Babel 8, that API expects a callback; synchronous callers must use loadPartialConfigSync.
This surfaced through Storybook's react-docgen plugin when a workspace-wide override resolved Babel to 8.0.1. Storybook is currently tracking Babel 8 support and explicitly waiting for react-docgen compatibility: https://github.com/storybookjs/storybook/issues/35295
Minimal reproduction
package.json:
{
"private": true,
"type": "module",
"packageManager": "pnpm@11.13.0",
"dependencies": {
"@babel/core": "8.0.1",
"react-docgen": "8.0.3"
}
}
pnpm-workspace.yaml:
packages:
- .
overrides:
'@babel/core': 8.0.1
repro.mjs:
import { parse } from 'react-docgen';
parse('export const Button = ({ label }) => <button>{label}</button>;');
Run:
pnpm install
node repro.mjs
Actual result
Error: Starting from Babel 8.0.0, the 'loadPartialConfig' function expects a callback. If you need to call it synchronously, please use 'loadPartialConfigSync'.
at loadPartialConfig (.../@babel/core/lib/index-shared.js:2207:11)
at buildPluginList (.../react-docgen/dist/babelParser.js:34:27)
Expected result
Parsing succeeds with Babel 8, while retaining Babel 7 compatibility.
Versions
react-docgen: 8.0.3@babel/core: 8.0.1- Node.js: 24.18.0
- pnpm: 11.13.0
The likely compatibility change is to use loadPartialConfigSync for this synchronous code path; that API is also available in Babel 7.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
dist/babelParser.js に示されている同期 babelParser パスから始めて、loadPartialConfig の呼び出しを調べます。提供されている repro.mjs を @babel/core 8.0.1 で使用し、その後、Babel 7 との互換性を維持したまま Babel 8 でパースが成功することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- react, typescript
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 78/100