Honour Metro's experimentalImportSupport in react-native/babel-preset via the Babel caller - #58459
Open
shubh73 wants to merge 1 commit into
Open
Honour Metro's experimentalImportSupport in react-native/babel-preset via the Babel caller#58459shubh73 wants to merge 1 commit into
experimentalImportSupport in react-native/babel-preset via the Babel caller#58459shubh73 wants to merge 1 commit into
Conversation
shubh73
force-pushed
the
babel-preset-import-support-caller
branch
from
September 10, 2026 16:49
6d4e378 to
3fae730
Compare
shubh73
force-pushed
the
babel-preset-import-support-caller
branch
from
September 10, 2026 16:55
3fae730 to
bee1ca0
Compare
…set` via the Babel caller `experimentalImportSupport: true` in a Metro config asks Metro to lower `import`/`export` itself, so `react-native/babel-preset` must leave ESM intact. `react-native/metro-babel-transformer` only passes the matching `disableImportExportTransform` preset option when the project has no Babel config of its own. Apps from the template have a `babel.config.js` naming the preset, so the preset lowers to CommonJS regardless and the Metro option is silently a no-op (react/metro#909). It also keeps default imports eager under `inlineRequires`, which only inlines bare `require` calls. Pass `experimentalImportSupport` through the Babel caller and resolve it in the preset as `options.disableImportExportTransform ?? babel.caller(...) ?? false`, the channel react#57973 added for `inlinePlatform`. Preset options still take precedence and the default is unchanged. Changelog: [General][Fixed] - `experimentalImportSupport` in a Metro config now takes effect when `react-native/babel-preset` is named in a project Babel config Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
shubh73
force-pushed
the
babel-preset-import-support-caller
branch
from
September 10, 2026 16:55
bee1ca0 to
c306f3f
Compare
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.
Summary:
experimentalImportSupport: truein a Metro config asks Metro to lowerimport/exportitself, soreact-native/babel-presetmust leave ESM intact.react-native/metro-babel-transformeronly passes the matchingdisableImportExportTransformpreset option when the project has no Babel config of its own. Apps from the template have ababel.config.jsnaming the preset, so the preset lowers to CommonJS regardless and the Metro option is silently a no-op (react/metro#909). It also keeps default imports eager underinlineRequires, which only inlines barerequirecalls.Pass
experimentalImportSupportthrough the Babel caller and resolve it in the preset asoptions.disableImportExportTransform ?? babel.caller(...) ?? false, the channel #57973 added forinlinePlatform. Preset options still take precedence and the default is unchanged.Changelog:
[GENERAL] [FIXED] -
experimentalImportSupportin a Metro config now takes effect whenreact-native/babel-presetis named in a project Babel configTest Plan:
yarn test packages/react-native-babel-preset packages/react-native-babel-transformer: 151 pass, including new tests for the caller channel and for a projectbabel.config.jsnaming the preset.yarn flow-check: no errors.private/helloworldiOS release bundle withexperimentalImportSupport: trueand the stockbabel.config.js: module-scope_interopRequireDefault(require(...))1274 → 0, modules evaluated at startup 83 → 49. Without the option, output is byte-identical.🤖 Generated with Claude Code