@@ -144,7 +144,7 @@ module.exports = {
144144 // https://github.com/facebook/create-react-app/issues/290
145145 // `web` extension prefixes have been added for better support
146146 // for React Native Web.
147- extensions : [ '.web.js' , '.js' , '.json' , '.web.jsx' , '.jsx' ] ,
147+ extensions : [ '.mjs' , '. web.js', '.js' , '.json' , '.web.jsx' , '.jsx' ] ,
148148 alias : {
149149 // Support React Native Web
150150 // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
@@ -178,7 +178,7 @@ module.exports = {
178178 // First, run the linter.
179179 // It's important to do this before Babel processes the JS.
180180 {
181- test : / \. ( j s | j s x ) $ / ,
181+ test : / \. ( j s | m j s | j s x ) $ / ,
182182 enforce : 'pre' ,
183183 use : [
184184 {
@@ -199,16 +199,6 @@ module.exports = {
199199 ] ,
200200 include : paths . appSrc ,
201201 } ,
202- {
203- // `mjs` support is still in its infancy in the ecosystem, so we don't
204- // support it.
205- // Modules who define their `browser` or `module` key as `mjs` force
206- // the use of this extension, so we need to tell webpack to fall back
207- // to auto mode (ES Module interop, allows ESM to import CommonJS).
208- test : / \. m j s $ / ,
209- include : / n o d e _ m o d u l e s / ,
210- type : 'javascript/auto' ,
211- } ,
212202 {
213203 // "oneOf" will traverse all following loaders until one will
214204 // match the requirements. When no loader matches it will fall
@@ -228,7 +218,7 @@ module.exports = {
228218 // Process application JS with Babel.
229219 // The preset includes JSX, Flow, and some ESnext features.
230220 {
231- test : / \. ( j s | j s x ) $ / ,
221+ test : / \. ( j s | m j s | j s x ) $ / ,
232222 include : paths . appSrc ,
233223 loader : require . resolve ( 'babel-loader' ) ,
234224 options : {
@@ -274,7 +264,7 @@ module.exports = {
274264 // Process any JS outside of the app with Babel.
275265 // Unlike the application JS, we only compile the standard ES features.
276266 {
277- test : / \. j s $ / ,
267+ test : / \. ( j s | m j s ) $ / ,
278268 exclude : / @ b a b e l (?: \/ | \\ { 1 , 2 } ) r u n t i m e / ,
279269 loader : require . resolve ( 'babel-loader' ) ,
280270 options : {
@@ -361,7 +351,7 @@ module.exports = {
361351 // its runtime that would otherwise be processed through "file" loader.
362352 // Also exclude `html` and `json` extensions so they get processed
363353 // by webpacks internal loaders.
364- exclude : [ / \. ( j s | j s x ) $ / , / \. h t m l $ / , / \. j s o n $ / ] ,
354+ exclude : [ / \. ( j s | m j s | j s x ) $ / , / \. h t m l $ / , / \. j s o n $ / ] ,
365355 loader : require . resolve ( 'file-loader' ) ,
366356 options : {
367357 name : 'static/media/[name].[hash:8].[ext]' ,
0 commit comments