You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ Within your webpack configuration object, you'll need to add the babel-loader to
41
41
module: {
42
42
rules: [
43
43
{
44
-
test:/\.m?js$/,
44
+
test:/\.(?:js|mjs|cjs)$/,
45
45
exclude:/node_modules/,
46
46
use: {
47
47
loader:'babel-loader',
@@ -66,7 +66,7 @@ You can pass options to the loader by using the [`options`](https://webpack.js.o
66
66
module: {
67
67
rules: [
68
68
{
69
-
test:/\.m?js$/,
69
+
test:/\.(?:js|mjs|cjs)$/,
70
70
exclude:/node_modules/,
71
71
use: {
72
72
loader:'babel-loader',
@@ -106,13 +106,13 @@ You can also speed up babel-loader by as much as 2x by using the `cacheDirectory
106
106
107
107
### Some files in my node_modules are not transpiled for IE 11
108
108
109
-
Although we typically recommend not compiling `node_modules`, you may need to when using libraries that do not support IE 11.
109
+
Although we typically recommend not compiling `node_modules`, you may need to when using libraries that do not support IE 11 or any legacy targets.
110
110
111
111
For this, you can either use a combination of `test` and `not`, or [pass a function](https://webpack.js.org/configuration/module/#condition) to your `exclude` option. You can also use negative lookahead regex as suggested [here](https://github.com/webpack/webpack/issues/2031#issuecomment-294706065).
112
112
113
113
```javascript
114
114
{
115
-
test:/\.m?js$/,
115
+
test:/\.(?:js|mjs|cjs)$/,
116
116
exclude: {
117
117
and: [/node_modules/], // Exclude libraries in node_modules ...
118
118
not: [
@@ -150,7 +150,7 @@ rules: [
150
150
// the 'transform-runtime' plugin tells Babel to
151
151
// require the runtime instead of inlining it.
152
152
{
153
-
test:/\.m?js$/,
153
+
test:/\.(?:js|mjs|cjs)$/,
154
154
exclude:/node_modules/,
155
155
use: {
156
156
loader:'babel-loader',
@@ -216,7 +216,7 @@ require('./app');
216
216
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):
217
217
```javascript
218
218
{
219
-
test:/\.m?js$/,
219
+
test:/\.(?:js|mjs|cjs)$/,
220
220
loader:'babel',
221
221
}
222
222
```
@@ -227,7 +227,7 @@ To fix this, you should uninstall the npm package `babel`, as it is deprecated i
227
227
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:
0 commit comments