reactjs / reactjs/react-docgen

Support Babel 8 in babelParser (loadPartialConfigSync)

Offen Anfängerfreundlich
#1,102 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
TypeScript
Sterne
3.8k
Forks
316
Ø Merge
5 Std. 7 Min.
Gemergte PRs (30 T.)
4

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie beim synchronen babelParser-Pfad in dist/babelParser.js und untersuchen Sie den Aufruf von loadPartialConfig. Verwenden Sie die bereitgestellte repro.mjs mit @babel/core 8.0.1 und überprüfen Sie anschließend, dass das Parsen mit Babel 8 erfolgreich ist und die Kompatibilität mit Babel 7 erhalten bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
react, typescript
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Ruhig
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
78/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.