@rsbuild/plugin-babel 1.1.1 → 1.1.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
718: (module) => {
|
|
4
4
|
const STRIP_FILENAME_RE = /^[^:]+: /;
|
|
5
5
|
const format = (err) => {
|
|
6
6
|
if (err instanceof SyntaxError) {
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
}
|
|
27
27
|
module.exports = LoaderError;
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
818: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
30
|
+
const nodeModule = __nccwpck_require__(995);
|
|
30
31
|
const os = __nccwpck_require__(857);
|
|
31
32
|
const path = __nccwpck_require__(928);
|
|
32
33
|
const zlib = __nccwpck_require__(106);
|
|
@@ -34,11 +35,18 @@
|
|
|
34
35
|
const { readFile, writeFile, mkdir } = __nccwpck_require__(943);
|
|
35
36
|
const { sync: findUpSync } = __nccwpck_require__(48);
|
|
36
37
|
const { env } = process;
|
|
37
|
-
const transform = __nccwpck_require__(
|
|
38
|
-
const serialize = __nccwpck_require__(
|
|
38
|
+
const transform = __nccwpck_require__(180);
|
|
39
|
+
const serialize = __nccwpck_require__(790);
|
|
39
40
|
let defaultCacheDirectory = null;
|
|
40
41
|
const gunzip = promisify(zlib.gunzip);
|
|
41
42
|
const gzip = promisify(zlib.gzip);
|
|
43
|
+
const findRootPackageJSON = () => {
|
|
44
|
+
if (nodeModule.findPackageJSON) {
|
|
45
|
+
return nodeModule.findPackageJSON("..", __filename);
|
|
46
|
+
} else {
|
|
47
|
+
return findUpSync("package.json");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
42
50
|
const read = async function (filename, compress) {
|
|
43
51
|
const data = await readFile(filename + (compress ? ".gz" : ""));
|
|
44
52
|
const content = compress ? await gunzip(data) : data;
|
|
@@ -129,6 +137,10 @@
|
|
|
129
137
|
}
|
|
130
138
|
logger.debug(`applying Babel transform`);
|
|
131
139
|
const result = await transform(source, options);
|
|
140
|
+
if (!result) {
|
|
141
|
+
logger.debug(`no result from Babel transform, skipping cache write`);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
132
144
|
await addTimestamps(result.externalDependencies, getFileTimestamp);
|
|
133
145
|
try {
|
|
134
146
|
logger.debug(`writing result to cache file '${file}'`);
|
|
@@ -141,7 +153,7 @@
|
|
|
141
153
|
}
|
|
142
154
|
return result;
|
|
143
155
|
};
|
|
144
|
-
module.exports = async function (params) {
|
|
156
|
+
module.exports = async function cache(params) {
|
|
145
157
|
let directory;
|
|
146
158
|
if (typeof params.cacheDirectory === "string") {
|
|
147
159
|
directory = params.cacheDirectory;
|
|
@@ -158,14 +170,19 @@
|
|
|
158
170
|
) {
|
|
159
171
|
return path.join(env.CACHE_DIR, name);
|
|
160
172
|
}
|
|
161
|
-
const rootPkgJSONPath =
|
|
173
|
+
const rootPkgJSONPath = findRootPackageJSON();
|
|
162
174
|
if (rootPkgJSONPath) {
|
|
163
|
-
return path.join(
|
|
175
|
+
return path.join(
|
|
176
|
+
path.dirname(rootPkgJSONPath),
|
|
177
|
+
"node_modules",
|
|
178
|
+
".cache",
|
|
179
|
+
name,
|
|
180
|
+
);
|
|
164
181
|
}
|
|
165
182
|
return os.tmpdir();
|
|
166
183
|
}
|
|
167
184
|
},
|
|
168
|
-
|
|
185
|
+
556: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
169
186
|
let babel;
|
|
170
187
|
try {
|
|
171
188
|
babel = __nccwpck_require__(571);
|
|
@@ -184,10 +201,10 @@
|
|
|
184
201
|
);
|
|
185
202
|
}
|
|
186
203
|
const { version } = __nccwpck_require__(344);
|
|
187
|
-
const cache = __nccwpck_require__(
|
|
188
|
-
const transform = __nccwpck_require__(
|
|
189
|
-
const injectCaller = __nccwpck_require__(
|
|
190
|
-
const schema = __nccwpck_require__(
|
|
204
|
+
const cache = __nccwpck_require__(818);
|
|
205
|
+
const transform = __nccwpck_require__(180);
|
|
206
|
+
const injectCaller = __nccwpck_require__(516);
|
|
207
|
+
const schema = __nccwpck_require__(625);
|
|
191
208
|
const { isAbsolute } = __nccwpck_require__(928);
|
|
192
209
|
const { promisify } = __nccwpck_require__(23);
|
|
193
210
|
function subscribe(subscriber, metadata, context) {
|
|
@@ -199,13 +216,14 @@
|
|
|
199
216
|
module.exports.custom = makeLoader;
|
|
200
217
|
function makeLoader(callback) {
|
|
201
218
|
const overrides = callback ? callback(babel) : undefined;
|
|
202
|
-
|
|
219
|
+
const webpackLoader = function (source, inputSourceMap) {
|
|
203
220
|
const callback = this.async();
|
|
204
221
|
loader.call(this, source, inputSourceMap, overrides).then(
|
|
205
222
|
(args) => callback(null, ...args),
|
|
206
223
|
(err) => callback(err),
|
|
207
224
|
);
|
|
208
225
|
};
|
|
226
|
+
return webpackLoader;
|
|
209
227
|
}
|
|
210
228
|
async function loader(source, inputSourceMap, overrides) {
|
|
211
229
|
const filename = this.resourcePath;
|
|
@@ -373,9 +391,10 @@
|
|
|
373
391
|
return [source, inputSourceMap];
|
|
374
392
|
}
|
|
375
393
|
},
|
|
376
|
-
|
|
394
|
+
516: (module) => {
|
|
377
395
|
module.exports = function injectCaller(opts, target) {
|
|
378
|
-
return
|
|
396
|
+
return {
|
|
397
|
+
...opts,
|
|
379
398
|
caller: Object.assign(
|
|
380
399
|
{
|
|
381
400
|
name: "babel-loader",
|
|
@@ -386,10 +405,10 @@
|
|
|
386
405
|
},
|
|
387
406
|
opts.caller,
|
|
388
407
|
),
|
|
389
|
-
}
|
|
408
|
+
};
|
|
390
409
|
};
|
|
391
410
|
},
|
|
392
|
-
|
|
411
|
+
790: (module) => {
|
|
393
412
|
var objToString = Object.prototype.toString;
|
|
394
413
|
var objKeys = Object.getOwnPropertyNames;
|
|
395
414
|
function serialize(val, isArrayProp) {
|
|
@@ -455,15 +474,15 @@
|
|
|
455
474
|
}
|
|
456
475
|
};
|
|
457
476
|
},
|
|
458
|
-
|
|
477
|
+
180: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
459
478
|
const babel = __nccwpck_require__(571);
|
|
460
479
|
const { promisify } = __nccwpck_require__(23);
|
|
461
|
-
const LoaderError = __nccwpck_require__(
|
|
462
|
-
const
|
|
463
|
-
module.exports = async function (source, options) {
|
|
480
|
+
const LoaderError = __nccwpck_require__(718);
|
|
481
|
+
const babelTransform = babel.transformAsync ?? promisify(babel.transform);
|
|
482
|
+
module.exports = async function transform(source, options) {
|
|
464
483
|
let result;
|
|
465
484
|
try {
|
|
466
|
-
result = await
|
|
485
|
+
result = await babelTransform(source, options);
|
|
467
486
|
} catch (err) {
|
|
468
487
|
throw err.message && err.codeFrame ? new LoaderError(err) : err;
|
|
469
488
|
}
|
|
@@ -793,6 +812,10 @@
|
|
|
793
812
|
"use strict";
|
|
794
813
|
module.exports = require("fs/promises");
|
|
795
814
|
},
|
|
815
|
+
995: (module) => {
|
|
816
|
+
"use strict";
|
|
817
|
+
module.exports = require("node:module");
|
|
818
|
+
},
|
|
796
819
|
857: (module) => {
|
|
797
820
|
"use strict";
|
|
798
821
|
module.exports = require("os");
|
|
@@ -809,7 +832,7 @@
|
|
|
809
832
|
"use strict";
|
|
810
833
|
module.exports = require("zlib");
|
|
811
834
|
},
|
|
812
|
-
|
|
835
|
+
625: (module) => {
|
|
813
836
|
"use strict";
|
|
814
837
|
module.exports = JSON.parse(
|
|
815
838
|
'{"title":"Babel Loader options","type":"object","properties":{"cacheDirectory":{"anyOf":[{"type":"boolean"},{"type":"string"}],"default":false},"cacheIdentifier":{"type":"string"},"cacheCompression":{"type":"boolean","default":true},"customize":{"anyOf":[{"type":"null"},{"type":"string"}],"default":null},"metadataSubscribers":{"type":"array"}},"additionalProperties":true}',
|
|
@@ -838,6 +861,6 @@
|
|
|
838
861
|
}
|
|
839
862
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
840
863
|
__nccwpck_require__.ab = __dirname + "/";
|
|
841
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
864
|
+
var __webpack_exports__ = __nccwpck_require__(556);
|
|
842
865
|
module.exports = __webpack_exports__;
|
|
843
866
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"babel-loader","author":"Luis Couto <hello@luiscouto.pt>","version":"10.
|
|
1
|
+
{"name":"babel-loader","author":"Luis Couto <hello@luiscouto.pt>","version":"10.1.0","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
package/dist/index.js
CHANGED
|
@@ -108,7 +108,7 @@ let pluginBabel = (options = {})=>({
|
|
|
108
108
|
name: PLUGIN_BABEL_NAME,
|
|
109
109
|
setup (api) {
|
|
110
110
|
let getBabelOptions = async (environment)=>{
|
|
111
|
-
let { config } = environment, mergedOptions = ((defaultOptions, userBabelConfig
|
|
111
|
+
let { config } = environment, mergedOptions = ((defaultOptions, userBabelConfig)=>{
|
|
112
112
|
if (userBabelConfig) {
|
|
113
113
|
let babelUtils = {
|
|
114
114
|
...getBabelUtils(defaultOptions),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-babel",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Babel plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,17 +32,22 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@rsbuild/core-v1": "npm:@rsbuild/core@^1.7.3",
|
|
35
|
-
"@rslib/core": "0.
|
|
36
|
-
"@types/node": "^24.
|
|
37
|
-
"babel-loader": "10.
|
|
35
|
+
"@rslib/core": "0.20.0",
|
|
36
|
+
"@types/node": "^24.12.0",
|
|
37
|
+
"babel-loader": "10.1.0",
|
|
38
38
|
"prebundle": "1.6.2",
|
|
39
39
|
"typescript": "^5.9.3",
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
40
|
+
"@scripts/test-helper": "1.0.0",
|
|
41
|
+
"@rsbuild/core": "2.0.0-beta.8"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@rsbuild/core": "^1.0.0 || ^2.0.0-0"
|
|
45
45
|
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"@rsbuild/core": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
46
51
|
"publishConfig": {
|
|
47
52
|
"access": "public",
|
|
48
53
|
"registry": "https://registry.npmjs.org/"
|