diff --git a/babel.config.js b/babel.config.js index f950b6603a512..e500371df49e2 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,8 +1,8 @@ +const config = process.env.MOBILE ? require( './packages/react-native-editor/babel.config' ) : { + presets: [ '@wordpress/babel-preset-default' ], + plugins: [ 'babel-plugin-inline-json-import' ], +}; module.exports = function( api ) { - api.cache( true ); - - return { - presets: [ '@wordpress/babel-preset-default' ], - plugins: [ 'babel-plugin-emotion', 'babel-plugin-inline-json-import' ], - }; + api.cache.using( () => process.env.MOBILE ? 'mobile' : 'web' ); + return config; }; diff --git a/package-lock.json b/package-lock.json index da9d1f42c252f..e9dfd3e56e7b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7231,6 +7231,7 @@ "@wordpress/i18n": "file:packages/i18n", "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "@wordpress/keycodes": "file:packages/keycodes", + "@wordpress/react-native-bridge": "file:packages/react-native-bridge", "@wordpress/rich-text": "file:packages/rich-text", "@wordpress/token-list": "file:packages/token-list", "@wordpress/url": "file:packages/url", @@ -7273,6 +7274,7 @@ "@wordpress/i18n": "file:packages/i18n", "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "@wordpress/keycodes": "file:packages/keycodes", + "@wordpress/react-native-bridge": "file:packages/react-native-bridge", "@wordpress/rich-text": "file:packages/rich-text", "@wordpress/server-side-render": "file:packages/server-side-render", "@wordpress/url": "file:packages/url", @@ -7525,6 +7527,7 @@ "@wordpress/notices": "file:packages/notices", "@wordpress/nux": "file:packages/nux", "@wordpress/plugins": "file:packages/plugins", + "@wordpress/react-native-bridge": "file:packages/react-native-bridge", "@wordpress/url": "file:packages/url", "@wordpress/viewport": "file:packages/viewport", "classnames": "^2.2.5", @@ -7580,6 +7583,7 @@ "@wordpress/media-utils": "file:packages/media-utils", "@wordpress/notices": "file:packages/notices", "@wordpress/nux": "file:packages/nux", + "@wordpress/react-native-bridge": "file:packages/react-native-bridge", "@wordpress/rich-text": "file:packages/rich-text", "@wordpress/server-side-render": "file:packages/server-side-render", "@wordpress/url": "file:packages/url", diff --git a/packages/react-native-editor/babel.config.js b/packages/react-native-editor/babel.config.js index fe85eb62619c5..497719de10803 100644 --- a/packages/react-native-editor/babel.config.js +++ b/packages/react-native-editor/babel.config.js @@ -1,5 +1,3 @@ -/** @format */ - module.exports = { presets: [ 'module:metro-react-native-babel-preset' ], plugins: [ diff --git a/packages/react-native-editor/ios/gutenberg.xcodeproj/project.pbxproj b/packages/react-native-editor/ios/gutenberg.xcodeproj/project.pbxproj index 56261cc8ff99d..14cdd71dc5dab 100644 --- a/packages/react-native-editor/ios/gutenberg.xcodeproj/project.pbxproj +++ b/packages/react-native-editor/ios/gutenberg.xcodeproj/project.pbxproj @@ -1339,7 +1339,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n../../../node_modules/react-native/scripts/react-native-xcode.sh\n"; + shellScript = "export NODE_BINARY=node\nexport MOBILE=true\n../../../node_modules/react-native/scripts/react-native-xcode.sh packages/react-native-editor/index.js\n"; }; 2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = { isa = PBXShellScriptBuildPhase; diff --git a/packages/react-native-editor/rn-cli.config.js b/packages/react-native-editor/rn-cli.config.js index 6ba929fc2e526..e04a7aa2a40da 100644 --- a/packages/react-native-editor/rn-cli.config.js +++ b/packages/react-native-editor/rn-cli.config.js @@ -6,7 +6,6 @@ const path = require( 'path' ); const enm = require( './extra-node-modules.config.js' ); module.exports = { - projectRoot: path.resolve( __dirname, './' ), resolver: { extraNodeModules: enm, sourceExts: [ 'js', 'json', 'scss', 'sass' ], diff --git a/rn-cli.config.js b/rn-cli.config.js new file mode 100644 index 0000000000000..670b07eecd8b4 --- /dev/null +++ b/rn-cli.config.js @@ -0,0 +1 @@ +module.exports = require( './packages/react-native-editor/rn-cli.config' ); diff --git a/packages/react-native-editor/jest_ui.config.js b/test/native/jest_ui.config.js similarity index 65% rename from packages/react-native-editor/jest_ui.config.js rename to test/native/jest_ui.config.js index adf98100cde47..89d66b615b59e 100644 --- a/packages/react-native-editor/jest_ui.config.js +++ b/test/native/jest_ui.config.js @@ -1,6 +1,3 @@ -/** @flow - * @format */ - const main = require( './jest.config.js' ); module.exports = { @@ -10,8 +7,5 @@ module.exports = { testMatch: [ '**/__device-tests__/**/*.test.[jt]s?(x)' ], testPathIgnorePatterns: [ '/node_modules/', - '/gutenberg/gutenberg-mobile/', - '/gutenberg/test/', - '/gutenberg/packages/', ], }; diff --git a/test/unit/jest.config.js b/test/unit/jest.config.js index 6ad2de76e69ef..0a468d4a735d7 100644 --- a/test/unit/jest.config.js +++ b/test/unit/jest.config.js @@ -25,6 +25,8 @@ module.exports = { '/.*/build/', '/.*/build-module/', '/.+\.native\.js$', + // This is temporary. In the future we should change the names of the native tests files to .native.js. + '/packages/react-native-editor', ], transform: { '^.+\\.[jt]sx?$': '/test/unit/scripts/babel-transformer.js',