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
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -250,6 +250,26 @@ You will need to exclude them form `babel-loader`.
250
250
}
251
251
```
252
252
253
+
### Top level function (IIFE) is still arrow (on Webpack 5)
254
+
255
+
That function is injected by Webpack itself _after_ running `babel-loader`. By default Webpack asumes that your target environment supports some ES2015 features, but you can overwrite this behavior using the `output.environment` Webpack option ([documentation]((https://webpack.js.org/configuration/output/#outputenvironment)).
256
+
257
+
To avoid the top-level arrow function, you can use `output.environment.arrowFunction`:
258
+
259
+
```js
260
+
// webpack.config.js
261
+
module.exports= {
262
+
// ...
263
+
output: {
264
+
// ...
265
+
environment: {
266
+
// ...
267
+
arrowFunction:false, // <-- this line does the trick
268
+
},
269
+
},
270
+
};
271
+
```
272
+
253
273
## Customize config based on webpack target
254
274
255
275
Webpack supports bundling multiple [targets](https://webpack.js.org/concepts/targets/). For cases where you may want different Babel configurations for each target (like `web`_and_`node`), this loader provides a `target` property via Babel's [caller](https://babeljs.io/docs/en/config-files#apicallercb) API.
0 commit comments