From 5aa95d8b563d1d9e5edf93688f15b7470fb92943 Mon Sep 17 00:00:00 2001 From: Jiri Spac Date: Thu, 20 Sep 2018 22:24:10 +0200 Subject: [PATCH] showcase sample configs with respect to .mjs as mentioned https://twitter.com/capajj/status/1042836215022735361 we need to transpile .mjs files as well. Having this regex like this by default will save countless developers from wondering why their bundle has fat arrows and other ES6 features. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 48757c74..1b0e1d23 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Within your webpack configuration object, you'll need to add the babel-loader to module: { rules: [ { - test: /\.js$/, + test: /\.(js|mjs)$/, exclude: /(node_modules|bower_components)/, use: { loader: 'babel-loader', @@ -68,7 +68,7 @@ You can pass options to the loader by using the [`options`](https://webpack.js.o module: { rules: [ { - test: /\.js$/, + test: /\.(js|mjs)$/, exclude: /(node_modules|bower_components)/, use: { loader: 'babel-loader', @@ -119,7 +119,7 @@ rules: [ // the 'transform-runtime' plugin tells Babel to // require the runtime instead of inlining it. { - test: /\.js$/, + test: /\.(js|mjs)$/, exclude: /(node_modules|bower_components)/, use: { loader: 'babel-loader', @@ -183,7 +183,7 @@ require('./app'); If you receive this message, it means that you have the npm package `babel` installed and are using the short notation of the loader in the webpack config (which is not valid anymore as of webpack 2.x): ```javascript { - test: /\.js$/, + test: /\.(js|mjs)$/, loader: 'babel', } ``` @@ -194,7 +194,7 @@ To fix this, you should uninstall the npm package `babel`, as it is deprecated i In the case one of your dependencies is installing `babel` and you cannot uninstall it yourself, use the complete name of the loader in the webpack config: ```javascript { - test: /\.js$/, + test: /\.(js|mjs)$/, loader: 'babel-loader', } ```