@rsbuild/plugin-babel 1.0.1-rc.5 → 1.0.2
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/compiled/babel-loader/index.js +51 -37
- package/compiled/babel-loader/package.json +1 -1
- package/{dist-types → dist}/helper.d.ts +1 -1
- package/dist/index.cjs +313 -268
- package/{dist-types → dist}/index.d.ts +3 -3
- package/dist/index.js +192 -248
- package/{dist-types → dist}/plugin.d.ts +1 -1
- package/package.json +15 -16
- package/dist-types/package.json +0 -1
- /package/{dist-types → dist}/types.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
69: (module) => {
|
|
4
4
|
const STRIP_FILENAME_RE = /^[^:]+: /;
|
|
5
5
|
const format = (err) => {
|
|
6
6
|
if (err instanceof SyntaxError) {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
}
|
|
27
27
|
module.exports = LoaderError;
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
856: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
30
30
|
const os = __nccwpck_require__(37);
|
|
31
31
|
const path = __nccwpck_require__(17);
|
|
32
32
|
const zlib = __nccwpck_require__(796);
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
const findCacheDirP = __nccwpck_require__
|
|
37
37
|
.e(672)
|
|
38
38
|
.then(__nccwpck_require__.bind(__nccwpck_require__, 672));
|
|
39
|
-
const transform = __nccwpck_require__(
|
|
39
|
+
const transform = __nccwpck_require__(694);
|
|
40
40
|
let defaultCacheDirectory = null;
|
|
41
41
|
let hashType = "sha256";
|
|
42
42
|
try {
|
|
43
43
|
crypto.createHash(hashType);
|
|
44
|
-
} catch
|
|
44
|
+
} catch {
|
|
45
45
|
hashType = "md5";
|
|
46
46
|
}
|
|
47
47
|
const gunzip = promisify(zlib.gunzip);
|
|
@@ -69,17 +69,22 @@
|
|
|
69
69
|
cacheIdentifier,
|
|
70
70
|
cacheDirectory,
|
|
71
71
|
cacheCompression,
|
|
72
|
+
logger,
|
|
72
73
|
} = params;
|
|
73
74
|
const file = path.join(
|
|
74
75
|
directory,
|
|
75
76
|
filename(source, cacheIdentifier, options),
|
|
76
77
|
);
|
|
77
78
|
try {
|
|
79
|
+
logger.debug(`reading cache file '${file}'`);
|
|
78
80
|
return await read(file, cacheCompression);
|
|
79
|
-
} catch
|
|
81
|
+
} catch {
|
|
82
|
+
logger.debug(`discarded cache as it can not be read`);
|
|
83
|
+
}
|
|
80
84
|
const fallback =
|
|
81
85
|
typeof cacheDirectory !== "string" && directory !== os.tmpdir();
|
|
82
86
|
try {
|
|
87
|
+
logger.debug(`creating cache folder '${directory}'`);
|
|
83
88
|
await mkdir(directory, { recursive: true });
|
|
84
89
|
} catch (err) {
|
|
85
90
|
if (fallback) {
|
|
@@ -87,9 +92,11 @@
|
|
|
87
92
|
}
|
|
88
93
|
throw err;
|
|
89
94
|
}
|
|
95
|
+
logger.debug(`applying Babel transform`);
|
|
90
96
|
const result = await transform(source, options);
|
|
91
97
|
if (!result.externalDependencies.length) {
|
|
92
98
|
try {
|
|
99
|
+
logger.debug(`writing result to cache file '${file}'`);
|
|
93
100
|
await write(file, cacheCompression, result);
|
|
94
101
|
} catch (err) {
|
|
95
102
|
if (fallback) {
|
|
@@ -115,7 +122,7 @@
|
|
|
115
122
|
return await handleCache(directory, params);
|
|
116
123
|
};
|
|
117
124
|
},
|
|
118
|
-
|
|
125
|
+
98: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
119
126
|
let babel;
|
|
120
127
|
try {
|
|
121
128
|
babel = __nccwpck_require__(718);
|
|
@@ -134,10 +141,10 @@
|
|
|
134
141
|
);
|
|
135
142
|
}
|
|
136
143
|
const { version } = __nccwpck_require__(684);
|
|
137
|
-
const cache = __nccwpck_require__(
|
|
138
|
-
const transform = __nccwpck_require__(
|
|
139
|
-
const injectCaller = __nccwpck_require__(
|
|
140
|
-
const schema = __nccwpck_require__(
|
|
144
|
+
const cache = __nccwpck_require__(856);
|
|
145
|
+
const transform = __nccwpck_require__(694);
|
|
146
|
+
const injectCaller = __nccwpck_require__(635);
|
|
147
|
+
const schema = __nccwpck_require__(441);
|
|
141
148
|
const { isAbsolute } = __nccwpck_require__(17);
|
|
142
149
|
const validateOptions = __nccwpck_require__(14).validate;
|
|
143
150
|
function subscribe(subscriber, metadata, context) {
|
|
@@ -159,6 +166,10 @@
|
|
|
159
166
|
}
|
|
160
167
|
async function loader(source, inputSourceMap, overrides) {
|
|
161
168
|
const filename = this.resourcePath;
|
|
169
|
+
const logger =
|
|
170
|
+
typeof this.getLogger === "function"
|
|
171
|
+
? this.getLogger("babel-loader")
|
|
172
|
+
: { debug: () => {} };
|
|
162
173
|
let loaderOptions = this.getOptions();
|
|
163
174
|
validateOptions(schema, loaderOptions, { name: "Babel loader" });
|
|
164
175
|
if (loaderOptions.customize != null) {
|
|
@@ -179,15 +190,20 @@
|
|
|
179
190
|
"using a customized babel-loader wrapper.",
|
|
180
191
|
);
|
|
181
192
|
}
|
|
193
|
+
logger.debug(
|
|
194
|
+
`loading customize override: '${loaderOptions.customize}'`,
|
|
195
|
+
);
|
|
182
196
|
let override = require(loaderOptions.customize);
|
|
183
197
|
if (override.__esModule) override = override.default;
|
|
184
198
|
if (typeof override !== "function") {
|
|
185
199
|
throw new Error("Custom overrides must be functions.");
|
|
186
200
|
}
|
|
201
|
+
logger.debug("applying customize override to @babel/core");
|
|
187
202
|
overrides = override(babel);
|
|
188
203
|
}
|
|
189
204
|
let customOptions;
|
|
190
205
|
if (overrides && overrides.customOptions) {
|
|
206
|
+
logger.debug("applying overrides customOptions() to loader options");
|
|
191
207
|
const result = await overrides.customOptions.call(
|
|
192
208
|
this,
|
|
193
209
|
loaderOptions,
|
|
@@ -210,6 +226,7 @@
|
|
|
210
226
|
"https://babeljs.io/docs/core-packages/#options",
|
|
211
227
|
);
|
|
212
228
|
}
|
|
229
|
+
logger.debug("normalizing loader options");
|
|
213
230
|
if (
|
|
214
231
|
Object.prototype.hasOwnProperty.call(loaderOptions, "sourceMap") &&
|
|
215
232
|
!Object.prototype.hasOwnProperty.call(loaderOptions, "sourceMaps")
|
|
@@ -233,12 +250,14 @@
|
|
|
233
250
|
delete programmaticOptions.cacheIdentifier;
|
|
234
251
|
delete programmaticOptions.cacheCompression;
|
|
235
252
|
delete programmaticOptions.metadataSubscribers;
|
|
253
|
+
logger.debug("resolving Babel configs");
|
|
236
254
|
const config = await babel.loadPartialConfigAsync(
|
|
237
255
|
injectCaller(programmaticOptions, this.target),
|
|
238
256
|
);
|
|
239
257
|
if (config) {
|
|
240
258
|
let options = config.options;
|
|
241
259
|
if (overrides && overrides.config) {
|
|
260
|
+
logger.debug("applying overrides config() to Babel config");
|
|
242
261
|
options = await overrides.config.call(this, config, {
|
|
243
262
|
source,
|
|
244
263
|
map: inputSourceMap,
|
|
@@ -260,6 +279,7 @@
|
|
|
260
279
|
} = loaderOptions;
|
|
261
280
|
let result;
|
|
262
281
|
if (cacheDirectory) {
|
|
282
|
+
logger.debug("cache is enabled");
|
|
263
283
|
result = await cache({
|
|
264
284
|
source,
|
|
265
285
|
options,
|
|
@@ -267,13 +287,21 @@
|
|
|
267
287
|
cacheDirectory,
|
|
268
288
|
cacheIdentifier,
|
|
269
289
|
cacheCompression,
|
|
290
|
+
logger,
|
|
270
291
|
});
|
|
271
292
|
} else {
|
|
293
|
+
logger.debug("cache is disabled, applying Babel transform");
|
|
272
294
|
result = await transform(source, options);
|
|
273
295
|
}
|
|
274
|
-
config.files.forEach((configFile) =>
|
|
296
|
+
config.files.forEach((configFile) => {
|
|
297
|
+
this.addDependency(configFile);
|
|
298
|
+
logger.debug(`added '${configFile}' to webpack dependencies`);
|
|
299
|
+
});
|
|
275
300
|
if (result) {
|
|
276
301
|
if (overrides && overrides.result) {
|
|
302
|
+
logger.debug(
|
|
303
|
+
"applying overrides result() to Babel transform results",
|
|
304
|
+
);
|
|
277
305
|
result = await overrides.result.call(this, result, {
|
|
278
306
|
source,
|
|
279
307
|
map: inputSourceMap,
|
|
@@ -283,11 +311,15 @@
|
|
|
283
311
|
});
|
|
284
312
|
}
|
|
285
313
|
const { code, map, metadata, externalDependencies } = result;
|
|
286
|
-
externalDependencies
|
|
287
|
-
|
|
288
|
-
|
|
314
|
+
externalDependencies?.forEach((dep) => {
|
|
315
|
+
this.addDependency(dep);
|
|
316
|
+
logger.debug(`added '${dep}' to webpack dependencies`);
|
|
317
|
+
});
|
|
289
318
|
metadataSubscribers.forEach((subscriber) => {
|
|
290
319
|
subscribe(subscriber, metadata, this);
|
|
320
|
+
logger.debug(
|
|
321
|
+
`invoked metadata subscriber '${String(subscriber)}'`,
|
|
322
|
+
);
|
|
291
323
|
});
|
|
292
324
|
return [code, map];
|
|
293
325
|
}
|
|
@@ -295,10 +327,8 @@
|
|
|
295
327
|
return [source, inputSourceMap];
|
|
296
328
|
}
|
|
297
329
|
},
|
|
298
|
-
|
|
299
|
-
const babel = __nccwpck_require__(718);
|
|
330
|
+
635: (module) => {
|
|
300
331
|
module.exports = function injectCaller(opts, target) {
|
|
301
|
-
if (!supportsCallerOption()) return opts;
|
|
302
332
|
return Object.assign({}, opts, {
|
|
303
333
|
caller: Object.assign(
|
|
304
334
|
{
|
|
@@ -312,27 +342,11 @@
|
|
|
312
342
|
),
|
|
313
343
|
});
|
|
314
344
|
};
|
|
315
|
-
let supportsCallerOptionFlag = undefined;
|
|
316
|
-
function supportsCallerOption() {
|
|
317
|
-
if (supportsCallerOptionFlag === undefined) {
|
|
318
|
-
try {
|
|
319
|
-
babel.loadPartialConfig({
|
|
320
|
-
caller: undefined,
|
|
321
|
-
babelrc: false,
|
|
322
|
-
configFile: false,
|
|
323
|
-
});
|
|
324
|
-
supportsCallerOptionFlag = true;
|
|
325
|
-
} catch (err) {
|
|
326
|
-
supportsCallerOptionFlag = false;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
return supportsCallerOptionFlag;
|
|
330
|
-
}
|
|
331
345
|
},
|
|
332
|
-
|
|
346
|
+
694: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
333
347
|
const babel = __nccwpck_require__(718);
|
|
334
348
|
const { promisify } = __nccwpck_require__(837);
|
|
335
|
-
const LoaderError = __nccwpck_require__(
|
|
349
|
+
const LoaderError = __nccwpck_require__(69);
|
|
336
350
|
const transform = promisify(babel.transform);
|
|
337
351
|
module.exports = async function (source, options) {
|
|
338
352
|
let result;
|
|
@@ -410,7 +424,7 @@
|
|
|
410
424
|
"use strict";
|
|
411
425
|
module.exports = require("zlib");
|
|
412
426
|
},
|
|
413
|
-
|
|
427
|
+
441: (module) => {
|
|
414
428
|
"use strict";
|
|
415
429
|
module.exports = JSON.parse(
|
|
416
430
|
'{"type":"object","properties":{"cacheDirectory":{"oneOf":[{"type":"boolean"},{"type":"string"}],"default":false},"cacheIdentifier":{"type":"string"},"cacheCompression":{"type":"boolean","default":true},"customize":{"type":"string","default":null}},"additionalProperties":true}',
|
|
@@ -503,6 +517,6 @@
|
|
|
503
517
|
}
|
|
504
518
|
};
|
|
505
519
|
})();
|
|
506
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
520
|
+
var __webpack_exports__ = __nccwpck_require__(98);
|
|
507
521
|
module.exports = __webpack_exports__;
|
|
508
522
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"babel-loader","author":"Luis Couto <hello@luiscouto.pt>","version":"9.1
|
|
1
|
+
{"name":"babel-loader","author":"Luis Couto <hello@luiscouto.pt>","version":"9.2.1","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChainIdentifier, RspackChain } from '@rsbuild/core';
|
|
2
|
-
import type { BabelConfigUtils, BabelLoaderOptions, BabelTransformOptions, PluginBabelOptions } from './types';
|
|
2
|
+
import type { BabelConfigUtils, BabelLoaderOptions, BabelTransformOptions, PluginBabelOptions } from './types.js';
|
|
3
3
|
export declare const BABEL_JS_RULE = "babel-js";
|
|
4
4
|
export declare const castArray: <T>(arr?: T | T[]) => T[];
|
|
5
5
|
export declare const getBabelUtils: (config: BabelTransformOptions) => BabelConfigUtils;
|