Skip to content

Commit

Permalink
fix: babel in react native, web tags transform to mobile equivalents
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgraeme committed Feb 4, 2025
1 parent faf7ef7 commit 40d5cfb
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
module.exports = api => {
module.exports = (api) => {
const isTest = api.env('test');

return {
presets: [
['module:metro-react-native-babel-preset', { modules: false }]
],
presets: [['module:metro-react-native-babel-preset', { modules: false }]],
plugins: [
['module-resolver', {
alias: {
'^react-native$': 'react-native-web'
}
}]
[
'module-resolver',
{
alias: {
'^react-native$': 'react-native',
'^react-dom$': 'react-native',
'^react-native-web$': 'react-native',
},
extensions: [
'.ios.js',
'.android.js',
'.native.js',
'.js',
'.ts',
'.tsx',
],
},
],
],
env: {
test: {
presets: [
['@babel/preset-env', { targets: { node: 'current' }, modules: 'commonjs' }],
[
'@babel/preset-env',
{ targets: { node: 'current' }, modules: 'commonjs' },
],
'@babel/preset-typescript',
['@babel/preset-react', { runtime: 'automatic' }]
]
['@babel/preset-react', { runtime: 'automatic' }],
],
},
production: {
presets: [
['@babel/preset-env', { modules: false }],
'@babel/preset-typescript',
['@babel/preset-react', { runtime: 'automatic' }]
]
}
}
['@babel/preset-react', { runtime: 'automatic' }],
],
},
},
};
};

0 comments on commit 40d5cfb

Please sign in to comment.