Maintenance: Remove parser re-export from storybook/internal/babel#34693
Closed
valentinpalkovic wants to merge 1 commit into
Closed
Maintenance: Remove parser re-export from storybook/internal/babel#34693valentinpalkovic wants to merge 1 commit into
parser re-export from storybook/internal/babel#34693valentinpalkovic wants to merge 1 commit into
Conversation
`storybook/internal/babel` re-exported the entire `@babel/parser` namespace as `parser`, leaking the upstream API into the public surface of `storybook/internal`. Replace it with two thin helpers in `babel/babelParse.ts`: - `parseAst(code, options)` — wraps `parser.parse` - `parseAstExpression(code, options)` — wraps `parser.parseExpression` Both helpers preserve the single-Babel-version guarantee: callers go through the bundled `storybook/internal/babel` entry instead of pulling in their own `@babel/parser` copy. Migrated all four `parser` consumers: - `core/src/mocking-utils/extract.ts` - `core/src/core-server/utils/save-story/valueToAST.ts` - `core/src/core-server/utils/parser/generic-parser.ts` - `lib/cli-storybook/src/codemod/helpers/csf-factories-utils.test.ts` Also remove `babelParseExpression` from `babelParse.ts` — it had zero callers in the repo and is superseded by `parseAstExpression`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughIntroduced convenience wrappers ChangesBabel API Modernization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes ✨ Finishing Touches📝 Generate docstrings
Review rate limit: 3/5 reviews remaining, refill in 15 minutes and 18 seconds. Comment |
Base automatically changed from
valentin/replace-resolve-with-oxc-resolver
to
next
May 20, 2026 13:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #
What I did
Stacked on top of #34692 (resolve → oxc-resolver), which is itself stacked on #34625 (change-detection oxc adoption).
This PR slims the
storybook/internal/babelre-export barrel by removing the rawparsernamespace export from@babel/parser. Two thin helpers replace it:parseAst(code, options)— wrapsparser.parseparseAstExpression(code, options)— wrapsparser.parseExpressionBoth helpers live in
code/core/src/babel/babelParse.tsand are re-exported fromstorybook/internal/babel. The single-Babel-version guarantee is preserved — callers continue to route through the bundled core entry instead of pulling their own@babel/parsercopy.Migrated callers (4)
code/core/src/mocking-utils/extract.tscode/core/src/core-server/utils/save-story/valueToAST.tscode/core/src/core-server/utils/parser/generic-parser.tscode/lib/cli-storybook/src/codemod/helpers/csf-factories-utils.test.tsEach call site previously did
parser.parse(code, opts).program(or.parseExpression); they now useparseAst/parseAstExpressionwith identical options. No behavioural changes.Cleanup
babelParseExpressionfrombabelParse.ts— zero callers in the repo, and superseded byparseAstExpression.Why now
The
parserre-export was a leaky abstraction over@babel/parser's API. Migrating off it is a prerequisite for the long-term Phase 3 plan: replacing the Babel+recast stack withoxc-transform/oxc-codegenonce those tools support source-preserving transforms. With the named helpers in place, future swaps need only change the helper bodies — no widespread call-site refactor.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
The pre-existing unit tests for
mocking-utils,core-server/utils/save-story,core-server/utils/parser,babel/, andlib/cli-storybook/codemod/helpersexercise every migrated call site (77 tests pass).Manual testing
yarn nx compile core— should succeed.yarn nx run-many -t check— type-check is clean.Documentation
parserandbabelParseExpressionwere on thestorybook/internal/babelbarrel and are technically removed. `storybook/internal/*` paths are documented as internal/unsupported, so a MIGRATION.md entry is not strictly required, but a one-line note could be added if maintainers want to be explicit.Checklist for Maintainers
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes.Suggested label:
maintenanceorcleanup.🤖 Generated with Claude Code
Summary by CodeRabbit
Breaking Changes
parserexport from Babel utilities—use convenience functions instead.New Features
parseAstandparseAstExpressionconvenience functions with optional parser configuration support.Refactor