Skip to content

Commit f2c7933

Browse files
committed
Use babel-plugin-react-native-web instead of webpack alias
Fixes necolas/react-native-web#629
1 parent 1e52f25 commit f2c7933

File tree

5 files changed

+5
-10
lines changed

5 files changed

+5
-10
lines changed

packages/babel-preset-react-app/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ module.exports = function(api, opts) {
8484
// Experimental macros support. Will be documented after it's had some time
8585
// in the wild.
8686
require('babel-plugin-macros'),
87+
// Allows correctly aliasing `react-native` to `react-native-web`
88+
// Prevents bundling unused react-native(-web) modules in production
89+
require('babel-plugin-react-native-web'),
8790
// Necessary to include regardless of the environment because
8891
// in practice some other transforms (such as object-rest-spread)
8992
// don't work without it: https://github.com/babel/babel/issues/7215

packages/babel-preset-react-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@babel/preset-flow": "7.0.0-beta.38",
2727
"@babel/preset-react": "7.0.0-beta.38",
2828
"babel-plugin-macros": "2.0.0",
29+
"babel-plugin-react-native-web": "0.5.2",
2930
"babel-plugin-transform-dynamic-import": "2.0.0",
3031
"babel-plugin-transform-react-remove-prop-types": "0.4.12"
3132
}

packages/react-scripts/config/webpack.config.dev.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ module.exports = {
115115
'@babel/runtime': path.dirname(
116116
require.resolve('@babel/runtime/package.json')
117117
),
118-
// @remove-on-eject-end
119-
// Support React Native Web
120-
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
121-
'react-native': 'react-native-web',
122118
},
123119
plugins: [
124120
// Prevents users from importing files from outside of src/ (or node_modules/).

packages/react-scripts/config/webpack.config.prod.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,6 @@ module.exports = {
122122
'@babel/runtime': path.dirname(
123123
require.resolve('@babel/runtime/package.json')
124124
),
125-
// @remove-on-eject-end
126-
// Support React Native Web
127-
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
128-
'react-native': 'react-native-web',
129125
},
130126
plugins: [
131127
// Prevents users from importing files from outside of src/ (or node_modules/).
@@ -413,7 +409,7 @@ module.exports = {
413409
// having to parse `index.html`.
414410
new ManifestPlugin({
415411
fileName: 'asset-manifest.json',
416-
publicPath: publicPath
412+
publicPath: publicPath,
417413
}),
418414
// Generate a service worker script that will precache, and keep up to date,
419415
// the HTML & assets that are part of the Webpack build.

packages/react-scripts/scripts/utils/createJestConfig.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ module.exports = (resolve, rootDir, srcRoots) => {
4848
'^.+\\.module\\.css$',
4949
],
5050
moduleNameMapper: {
51-
'^react-native$': 'react-native-web',
5251
'^.+\\.module\\.css$': 'identity-obj-proxy',
5352
},
5453
moduleFileExtensions: [

0 commit comments

Comments
 (0)