babel-loader 9.1.1 → 9.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -12
- package/lib/Error.js +0 -2
- package/lib/cache.js +4 -3
- package/lib/index.js +0 -2
- package/lib/injectCaller.js +0 -2
- package/lib/transform.js +0 -2
- package/package.json +3 -3
package/README.md
CHANGED
@@ -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: /\.
|
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: /\.
|
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: /\.
|
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: /\.
|
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: /\.
|
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:
|
228
228
|
```javascript
|
229
229
|
{
|
230
|
-
test: /\.
|
230
|
+
test: /\.(?:js|mjs|cjs)$/,
|
231
231
|
loader: 'babel-loader',
|
232
232
|
}
|
233
233
|
```
|
@@ -323,7 +323,8 @@ your `custom` callback function.
|
|
323
323
|
```js
|
324
324
|
// Export from "./my-custom-loader.js" or whatever you want.
|
325
325
|
module.exports = require("babel-loader").custom(babel => {
|
326
|
-
|
326
|
+
// Extract the custom options in the custom plugin
|
327
|
+
function myPlugin(api, { opt1, opt2 }) {
|
327
328
|
return {
|
328
329
|
visitor: {},
|
329
330
|
};
|
@@ -342,7 +343,7 @@ module.exports = require("babel-loader").custom(babel => {
|
|
342
343
|
},
|
343
344
|
|
344
345
|
// Passed Babel's 'PartialConfig' object.
|
345
|
-
config(cfg) {
|
346
|
+
config(cfg, { customOptions }) {
|
346
347
|
if (cfg.hasFilesystemConfig()) {
|
347
348
|
// Use the normal config
|
348
349
|
return cfg.options;
|
@@ -353,8 +354,8 @@ module.exports = require("babel-loader").custom(babel => {
|
|
353
354
|
plugins: [
|
354
355
|
...(cfg.options.plugins || []),
|
355
356
|
|
356
|
-
// Include a custom plugin in the options.
|
357
|
-
myPlugin,
|
357
|
+
// Include a custom plugin in the options and passing it the customOptions object.
|
358
|
+
[myPlugin, customOptions],
|
358
359
|
],
|
359
360
|
};
|
360
361
|
},
|
@@ -389,7 +390,7 @@ Given the loader's options, split custom options out of `babel-loader`'s
|
|
389
390
|
options.
|
390
391
|
|
391
392
|
|
392
|
-
### `config(cfg: PartialConfig): Object`
|
393
|
+
### `config(cfg: PartialConfig, options: { source, customOptions }): Object`
|
393
394
|
|
394
395
|
Given Babel's `PartialConfig` object, return the `options` object that should
|
395
396
|
be passed to `babel.transform`.
|
package/lib/Error.js
CHANGED
package/lib/cache.js
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
1
|
/**
|
4
2
|
* Filesystem Cache
|
5
3
|
*
|
@@ -13,7 +11,6 @@ const os = require("os");
|
|
13
11
|
const path = require("path");
|
14
12
|
const zlib = require("zlib");
|
15
13
|
const crypto = require("crypto");
|
16
|
-
const findCacheDir = require("find-cache-dir");
|
17
14
|
const {
|
18
15
|
promisify
|
19
16
|
} = require("util");
|
@@ -22,6 +19,7 @@ const {
|
|
22
19
|
writeFile,
|
23
20
|
mkdir
|
24
21
|
} = require("fs/promises");
|
22
|
+
const findCacheDirP = import("find-cache-dir");
|
25
23
|
const transform = require("./transform");
|
26
24
|
// Lazily instantiated when needed
|
27
25
|
let defaultCacheDirectory = null;
|
@@ -167,6 +165,9 @@ module.exports = async function (params) {
|
|
167
165
|
directory = params.cacheDirectory;
|
168
166
|
} else {
|
169
167
|
if (defaultCacheDirectory === null) {
|
168
|
+
const {
|
169
|
+
default: findCacheDir
|
170
|
+
} = await findCacheDirP;
|
170
171
|
defaultCacheDirectory = findCacheDir({
|
171
172
|
name: "babel-loader"
|
172
173
|
}) || os.tmpdir();
|
package/lib/index.js
CHANGED
package/lib/injectCaller.js
CHANGED
package/lib/transform.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "babel-loader",
|
3
|
-
"version": "9.1.
|
3
|
+
"version": "9.1.3",
|
4
4
|
"description": "babel module loader for webpack",
|
5
5
|
"files": [
|
6
6
|
"lib"
|
@@ -10,7 +10,7 @@
|
|
10
10
|
"node": ">= 14.15.0"
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
|
-
"find-cache-dir": "^
|
13
|
+
"find-cache-dir": "^4.0.0",
|
14
14
|
"schema-utils": "^4.0.0"
|
15
15
|
},
|
16
16
|
"peerDependencies": {
|
@@ -41,7 +41,7 @@
|
|
41
41
|
"react-intl": "^5.9.4",
|
42
42
|
"react-intl-webpack-plugin": "^0.3.0",
|
43
43
|
"rimraf": "^3.0.0",
|
44
|
-
"semver": "7.
|
44
|
+
"semver": "7.5.2",
|
45
45
|
"webpack": "^5.74.0"
|
46
46
|
},
|
47
47
|
"scripts": {
|