From ba5f1b2c212d254463640c7a6405d74d777c9215 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Mon, 22 Oct 2018 15:32:24 -0500 Subject: [PATCH] [change] Update react-native-web example (#5489) Utilize ES modules, which are now the default export for `react-native-web`. _NOTE:_ [This example requires `next@^7.0.0`](https://bit.ly/2PaEhao). --- examples/with-react-native-web/.babelrc | 6 ------ examples/with-react-native-web/next.config.js | 13 +++++++++++++ examples/with-react-native-web/package.json | 10 +++++----- examples/with-react-native-web/pages/_document.js | 1 - 4 files changed, 18 insertions(+), 12 deletions(-) delete mode 100644 examples/with-react-native-web/.babelrc create mode 100644 examples/with-react-native-web/next.config.js diff --git a/examples/with-react-native-web/.babelrc b/examples/with-react-native-web/.babelrc deleted file mode 100644 index 8aa610ad..00000000 --- a/examples/with-react-native-web/.babelrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "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 new file mode 100644 index 00000000..16e10320 --- /dev/null +++ b/examples/with-react-native-web/next.config.js @@ -0,0 +1,13 @@ +const withTM = require('next-plugin-transpile-modules') + +module.exports = withTM({ + transpileModules: ['react-native-web'], + webpack: (config) => { + // Alias all `react-native` imports to `react-native-web` + config.resolve.alias = { + 'react-native$': 'react-native-web' + } + + return config + } +}) diff --git a/examples/with-react-native-web/package.json b/examples/with-react-native-web/package.json index d9530bfe..4a556164 100644 --- a/examples/with-react-native-web/package.json +++ b/examples/with-react-native-web/package.json @@ -6,11 +6,11 @@ "start": "next start" }, "dependencies": { - "babel-plugin-react-native-web": "^0.8.8", "next": "latest", - "react": "^16.4.1", - "react-art": "^16.4.1", - "react-dom": "^16.4.1", - "react-native-web": "0.9.3" + "next-plugin-transpile-modules": "^0.1.3", + "react": "^16.5.2", + "react-art": "^16.5.2", + "react-dom": "^16.5.2", + "react-native-web": "^0.9.3" } } diff --git a/examples/with-react-native-web/pages/_document.js b/examples/with-react-native-web/pages/_document.js index 9de2957b..7b920ed9 100644 --- a/examples/with-react-native-web/pages/_document.js +++ b/examples/with-react-native-web/pages/_document.js @@ -27,7 +27,6 @@ export default class MyDocument extends Document { return ( - react-native-web