From 5f961382564a5616616a74be3a3a66089518d66f Mon Sep 17 00:00:00 2001 From: Brandon Bayer Date: Mon, 14 Oct 2019 20:36:43 -0700 Subject: [PATCH 1/2] fix react-native-web example by adding babel plugin --- examples/with-react-native-web/next.config.js | 5 ++++- examples/with-react-native-web/package.json | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/with-react-native-web/next.config.js b/examples/with-react-native-web/next.config.js index 041ca4d5f86d0..3a3e6c61093c7 100644 --- a/examples/with-react-native-web/next.config.js +++ b/examples/with-react-native-web/next.config.js @@ -1,10 +1,13 @@ module.exports = { - webpack: config => { + webpack: (config, { defaultLoaders }) => { config.resolve.alias = { ...(config.resolve.alias || {}), // Transform all direct `react-native` imports to `react-native-web` 'react-native$': 'react-native-web' } + defaultLoaders.babel.options.plugins = [ + ['react-native-web', { commonjs: true }] + ] return config } } diff --git a/examples/with-react-native-web/package.json b/examples/with-react-native-web/package.json index b4731af96dca4..9a3497e1e70db 100644 --- a/examples/with-react-native-web/package.json +++ b/examples/with-react-native-web/package.json @@ -10,5 +10,8 @@ "react": "^16.7.0", "react-dom": "^16.7.0", "react-native-web": "^0.11.6" + }, + "devDependencies": { + "babel-plugin-react-native-web": "^0.11.7" } } From a1a750b6d6030df24df8d1d162deee8dce442f52 Mon Sep 17 00:00:00 2001 From: Brandon Bayer Date: Sat, 26 Oct 2019 20:00:24 -0700 Subject: [PATCH 2/2] changes --- examples/with-react-native-web/babel.config.js | 4 ++++ examples/with-react-native-web/next.config.js | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 examples/with-react-native-web/babel.config.js diff --git a/examples/with-react-native-web/babel.config.js b/examples/with-react-native-web/babel.config.js new file mode 100644 index 0000000000000..300c182f0002a --- /dev/null +++ b/examples/with-react-native-web/babel.config.js @@ -0,0 +1,4 @@ +module.exports = { + presets: ['next/babel'], + plugins: [['react-native-web', { commonjs: true }]] +} diff --git a/examples/with-react-native-web/next.config.js b/examples/with-react-native-web/next.config.js index 3a3e6c61093c7..ecdab272e4d0a 100644 --- a/examples/with-react-native-web/next.config.js +++ b/examples/with-react-native-web/next.config.js @@ -5,9 +5,7 @@ module.exports = { // Transform all direct `react-native` imports to `react-native-web` 'react-native$': 'react-native-web' } - defaultLoaders.babel.options.plugins = [ - ['react-native-web', { commonjs: true }] - ] + config.resolve.extensions.push('.web.js', '.web.ts', '.web.tsx') return config } }