Closed matinzd closed 3 months ago
I tracked down the code and might be related to this line:
Tried commenting out the L16:L17 and it fixed the issue for me. Do you think it's still relevant to pull the dev version of @babel/plugin-transform-react-jsx
?
Seeing the same error as @matinzd however on a standard react native app created from the react-native-cli.
[error] src/App.tsx: /Users/**/Workspace/my-app/src/App.tsx: Duplicate __self prop found. You are most likely using the deprecated transform-react-jsx-self Babel plugin. Both __source and __self are automatically set when using the automatic runtime. Please remove transform-react-jsx-source and transform-react-jsx-self from your Babel config.
41 | }}>
42 | <PortalProvider>
> 43 | <Navigation />
| ^^^^^^^^^^^^^^
44 | <Calendar />
45 | <PortalHost name={BOTTOM_SHEET_PORTAL} />
46 | {/* {__DEV__ ? null : (
module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: ['react-native-reanimated/plugin'],
};
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const defaultConfig = getDefaultConfig(__dirname);
const {assetExts, sourceExts} = defaultConfig.resolver;
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
};
module.exports = mergeConfig(defaultConfig, config);
React Native IDE: 0.0.9 React Native: 0.73.7
Same Error :
babel.config.js
module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: [
'react-native-reanimated/plugin',
[
"babel-plugin-root-import",
{
"rootPathSuffix": "src", // Assuming you put all the code in Src folder
"rootPathPrefix": "@pc/"
}
]
]
};
metro.config.js
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const defaultConfig = getDefaultConfig(__dirname);
const { assetExts, sourceExts } = defaultConfig.resolver;
/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
transformer: {
babelTransformerPath: require.resolve("react-native-svg-transformer")
},
resolver: {
assetExts: assetExts.filter((ext) => ext !== "svg"),
sourceExts: [...sourceExts, "svg"]
}
};
module.exports = mergeConfig(defaultConfig, config);
Environment
React Native IDE: 0.0.9 React Native: 0.74.0
I have the same error on my personal project, but not the company one. Dependencies are the same, but in one App.tsx is in the root, in the other in the src
folder. I check the dependencies of both and are pretty the same, expect for some fewer or different libraries used in my own project.
Not related to code btw, because removing everything and leaving the app with only a <View />
will result in the same error.
Something to add here same as @Martinocom. My app entrypoint is located under src/main.tsx
and I have configured it in build gradle and xcode.env:
entryFile = file("../../src/main.tsx")
export ENTRY_FILE="${PROJECT_DIR}/../src/main.tsx"
Reproducible: https://github.com/matinzd/react-native-ide-nx-repro @kmagiera
same issue as above on iOS builds
This issue turned out to be a problem with svg transformer: https://github.com/matinzd/react-native-ide-nx-repro/blob/main/apps/react-native-ide-nx-repro-mobile/metro.config.js#L15
The transformer wasn't forwarding some of the properties to the upstream version of transformer and I submitted a PR to fix that here: https://github.com/kristerkari/react-native-svg-transformer/pull/354
I also found another way to workaround this issue without the need for a fix in svg transformer. Can other people here confirm that you've been using that transformer in your setups?
I can confirm we were using react-native-svg-transformer
. Thanks for the fix - hope to try the new build soon.
This issue turned out to be a problem with svg transformer: https://github.com/matinzd/react-native-ide-nx-repro/blob/main/apps/react-native-ide-nx-repro-mobile/metro.config.js#L15
The transformer wasn't forwarding some of the properties to the upstream version of transformer and I submitted a PR to fix that here: kristerkari/react-native-svg-transformer#354
I also found another way to workaround this issue without the need for a fix in svg transformer. Can other people here confirm that you've been using that transformer in your setups?
I was running into this issue and I can confirm that I am also using react-native-svg-transformer
.
Tried commenting out the L16:L17 and it fixed the issue for me. Do you think it's still relevant to pull the dev version of
@babel/plugin-transform-react-jsx
?
Hi. How did you commented it? I'm facing this issue even if I installed react-native-svg-transformer 1.4.0
or commented the babelTransformerPath: require.resolve('react-native-svg-transformer')
.
Description
After building the app, when metro tries to bundle the app it fails with the following error:
Might be related to monorepo stuff since I am using NX.
Metro Config:
My babel config:
Screenshot
Environment
React Native IDE: 0.0.9 React Native: 0.74.0