-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Labels
status:confirmedThe issue has been reviewed and all necessary information is provided.The issue has been reviewed and all necessary information is provided.type:bugA bug report.A bug report.
Description
Describe the bug
Has anybody got tree shaking to work with the new @callstack/repack/babel-swc-loader?
As rspack docs says, modules cannot be converted to CJS to utilize tree shaking. However when I configure the @react-native/babel-preset in babel.config.js to do so:
presets: [
[
'module:@react-native/babel-preset', { disableImportExportTransform: true },
],
],
...bundler throws error:
error: [Error [TypeError]: Cannot read properties of undefined (reading 'type')
at Proxy.babelSwcLoader (/Users/m/project/node_modules/@callstack/repack/dist/loaders/babelSwcLoader/babelSwcLoader.js:111:32)]
I've also tried to use babelOverrides property instead and the error is gone, but there is still no tree shaking result.
{
test: /\.[cm]?[jt]sx?$/,
type: 'javascript/auto',
use: {
loader: '@callstack/repack/babel-swc-loader',
parallel: true,
options: {
lazyImports: true,
babelOverrides: {
presets: [
['module:@react-native/babel-preset', { disableImportExportTransform: true }],
],
}
},
},
},System Info
"@callstack/repack": "5.2.2",
"react-native": "0.81.4",
"@react-native/babel-preset"Re.Pack Version
5.2.2
Reproduction
https://github.com/mefjuu/repack-optimizations-test
Steps to reproduce
- Clone the repo https://github.com/mefjuu/repack-optimizations-test
- Run
npm run bundle -- --entry-file ./index.js && cat build/generated/ios/index.bundle | grep "sernik" - The phrase "sernik" has been found in bundled file even though the
Sernique.tsxfile is not imported in App.tsx (however it's located in components/index.ts barrel file).
Ok, let's get aligned with that rspack docs says and:
- Put
{ disableImportExportTransform: true }atmodule:@react-native/babel-presetconfig in babel.config.js - Run
npm run bundle -- --entry-file ./index.js - Error:
... [Error [TypeError]: Cannot read properties of undefined (reading 'type') ...
Metadata
Metadata
Assignees
Labels
status:confirmedThe issue has been reviewed and all necessary information is provided.The issue has been reviewed and all necessary information is provided.type:bugA bug report.A bug report.