Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README examples #987

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Within your webpack configuration object, you'll need to add the babel-loader to
module: {
rules: [
{
test: /\.m?js$/,
test: /\.(?:js|mjs|cjs)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
Expand All @@ -66,7 +66,7 @@ You can pass options to the loader by using the [`options`](https://webpack.js.o
module: {
rules: [
{
test: /\.m?js$/,
test: /\.(?:js|mjs|cjs)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
Expand Down Expand Up @@ -106,13 +106,13 @@ You can also speed up babel-loader by as much as 2x by using the `cacheDirectory

### Some files in my node_modules are not transpiled for IE 11

Although we typically recommend not compiling `node_modules`, you may need to when using libraries that do not support IE 11.
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.

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).

```javascript
{
test: /\.m?js$/,
test: /\.(?:js|mjs|cjs)$/,
exclude: {
and: [/node_modules/], // Exclude libraries in node_modules ...
not: [
Expand Down Expand Up @@ -150,7 +150,7 @@ rules: [
// the 'transform-runtime' plugin tells Babel to
// require the runtime instead of inlining it.
{
test: /\.m?js$/,
test: /\.(?:js|mjs|cjs)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
Expand Down Expand Up @@ -216,7 +216,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: /\.m?js$/,
test: /\.(?:js|mjs|cjs)$/,
loader: 'babel',
}
```
Expand All @@ -227,7 +227,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: /\.m?js$/,
test: /\.(?:js|mjs|cjs)$/,
loader: 'babel-loader',
}
```
Expand Down