Skip to content

Commit 85b4a45

Browse files
authored
Merge pull request #83359 from callstack-internal/cleanup-platform-specifics-from-hermes-build
Enable platform tree shaking in hermes bundle
2 parents a7bcf8d + d8570ac commit 85b4a45

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

babel.config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const webpack = {
6363
};
6464

6565
const metro = {
66-
presets: [require('@react-native/babel-preset')],
66+
presets: [[require('@react-native/babel-preset'), {disableImportExportTransform: true}]],
6767
plugins: [
6868
['babel-plugin-react-compiler', ReactCompilerConfig], // must run first!
6969

@@ -174,5 +174,14 @@ module.exports = (api) => {
174174
const runningIn = api.caller((args = {}) => args.name);
175175
console.debug(' - running in: ', runningIn);
176176

177-
return ['metro', 'babel-jest'].includes(runningIn) ? metro : webpack;
177+
// Jest runs in Node.js without Metro's experimentalImportSupport transform,
178+
// so Babel must handle import/export transforms for tests.
179+
if (runningIn === 'babel-jest') {
180+
return {
181+
...metro,
182+
presets: [[require('@react-native/babel-preset'), {disableImportExportTransform: false}]],
183+
};
184+
}
185+
186+
return runningIn === 'metro' ? metro : webpack;
178187
};

metro.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const config = {
3535
transformer: {
3636
getTransformOptions: async () => ({
3737
transform: {
38+
experimentalImportSupport: true,
3839
inlineRequires: true,
3940
},
4041
}),

0 commit comments

Comments
 (0)