From 7a25e0abddc3bffe8fa303a22e2bc3dc4f207358 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Tue, 18 Sep 2018 14:59:25 -0400 Subject: [PATCH] Remove `mjs` support --- .../config/webpack.config.dev.js | 8 +++---- .../config/webpack.config.prod.js | 8 +++---- .../scripts/utils/createJestConfig.js | 22 ++++++------------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 3a3f96eeefd..643fa1798d1 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -142,7 +142,7 @@ module.exports = { // https://github.com/facebook/create-react-app/issues/290 // `web` extension prefixes have been added for better support // for React Native Web. - extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'], + extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'], alias: { // @remove-on-eject-begin // Resolve Babel runtime relative to react-scripts. @@ -175,7 +175,7 @@ module.exports = { // First, run the linter. // It's important to do this before Babel processes the JS. { - test: /\.(js|jsx|mjs)$/, + test: /\.(js|jsx)$/, enforce: 'pre', use: [ { @@ -214,7 +214,7 @@ module.exports = { // Process application JS with Babel. // The preset includes JSX, Flow, and some ESnext features. { - test: /\.(js|jsx|mjs)$/, + test: /\.(js|jsx)$/, include: paths.appSrc, use: [ // This loader parallelizes code compilation, it is optional but @@ -341,7 +341,7 @@ module.exports = { // its runtime that would otherwise be processed through "file" loader. // Also exclude `html` and `json` extensions so they get processed // by webpacks internal loaders. - exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/], + exclude: [/\.(js|jsx)$/, /\.html$/, /\.json$/], loader: require.resolve('file-loader'), options: { name: 'static/media/[name].[hash:8].[ext]', diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index f936a8ddbf9..010a5db4c20 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -180,7 +180,7 @@ module.exports = { // https://github.com/facebook/create-react-app/issues/290 // `web` extension prefixes have been added for better support // for React Native Web. - extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'], + extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'], alias: { // @remove-on-eject-begin // Resolve Babel runtime relative to react-scripts. @@ -213,7 +213,7 @@ module.exports = { // First, run the linter. // It's important to do this before Babel processes the JS. { - test: /\.(js|jsx|mjs)$/, + test: /\.(js|jsx)$/, enforce: 'pre', use: [ { @@ -253,7 +253,7 @@ module.exports = { // Process application JS with Babel. // The preset includes JSX, Flow, and some ESnext features. { - test: /\.(js|jsx|mjs)$/, + test: /\.(js|jsx)$/, include: paths.appSrc, use: [ // This loader parallelizes code compilation, it is optional but @@ -375,7 +375,7 @@ module.exports = { // it's runtime that would otherwise be processed through "file" loader. // Also exclude `html` and `json` extensions so they get processed // by webpacks internal loaders. - exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/], + exclude: [/\.(js|jsx)$/, /\.html$/, /\.json$/], options: { name: 'static/media/[name].[hash:8].[ext]', }, diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 72c50e1f1b2..373981d09ed 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -21,42 +21,34 @@ module.exports = (resolve, rootDir, isEjecting) => { // TODO: I don't know if it's safe or not to just use / as path separator // in Jest configs. We need help from somebody with Windows to determine this. const config = { - collectCoverageFrom: ['src/**/*.{js,jsx,mjs}'], + collectCoverageFrom: ['src/**/*.{js,jsx}'], setupFiles: [resolve('config/polyfills.js')], setupTestFrameworkScriptFile: setupTestsFile, testMatch: [ - '/src/**/__tests__/**/*.{js,jsx,mjs}', - '/src/**/?(*.)(spec|test).{js,jsx,mjs}', + '/src/**/__tests__/**/*.{js,jsx}', + '/src/**/?(*.)(spec|test).{js,jsx}', ], testEnvironment: 'node', testURL: 'http://localhost', transform: { - '^.+\\.(js|jsx|mjs)$': isEjecting + '^.+\\.(js|jsx)$': isEjecting ? '/node_modules/babel-jest' : resolve('config/jest/babelTransform.js'), '^.+\\.css$': resolve('config/jest/cssTransform.js'), '^.+\\.(graphql)$': resolve('config/jest/graphqlTransform.js'), - '^(?!.*\\.(js|jsx|mjs|css|json|graphql)$)': resolve( + '^(?!.*\\.(js|jsx|css|json|graphql)$)': resolve( 'config/jest/fileTransform.js' ), }, transformIgnorePatterns: [ - '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$', + '[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$', '^.+\\.module\\.(css|sass|scss)$', ], moduleNameMapper: { '^react-native$': 'react-native-web', '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy', }, - moduleFileExtensions: [ - 'web.js', - 'js', - 'json', - 'web.jsx', - 'jsx', - 'node', - 'mjs', - ], + moduleFileExtensions: ['web.js', 'js', 'json', 'web.jsx', 'jsx', 'node'], }; if (rootDir) { config.rootDir = rootDir;