@rspack/core 1.0.0-alpha.5 → 1.0.0-beta.0
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/zod/index.d.ts +138 -52
- package/compiled/zod/index.js +300 -103
- package/compiled/zod/package.json +1 -1
- package/compiled/zod-validation-error/index.js +6 -6
- package/dist/Compilation.d.ts +21 -3
- package/dist/Compilation.js +64 -49
- package/dist/Compiler.js +28 -28
- package/dist/ErrorHelpers.js +2 -4
- package/dist/Module.js +2 -6
- package/dist/ModuleTypeConstants.d.ts +45 -69
- package/dist/ModuleTypeConstants.js +24 -77
- package/dist/Stats.js +4 -6
- package/dist/Template.d.ts +31 -147
- package/dist/Template.js +40 -236
- package/dist/builtin-loader/lightningcss/index.d.ts +89 -0
- package/dist/builtin-loader/lightningcss/index.js +175 -0
- package/dist/builtin-plugin/BannerPlugin.d.ts +24 -48
- package/dist/builtin-plugin/DefinePlugin.js +9 -13
- package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +24 -0
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +8 -8
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +10 -3
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +4 -1
- package/dist/builtin-plugin/SplitChunksPlugin.js +5 -15
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +15 -23
- package/dist/builtin-plugin/base.js +1 -3
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -3
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +17 -66
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +2 -0
- package/dist/builtin-plugin/css-extract/hmr/{normalize-url.js → normalizeUrl.js} +15 -24
- package/dist/builtin-plugin/css-extract/loader.js +5 -5
- package/dist/config/adapter.d.ts +1 -1
- package/dist/config/adapter.js +24 -23
- package/dist/config/adapterRuleUse.d.ts +5 -5
- package/dist/config/adapterRuleUse.js +23 -1
- package/dist/config/browserslistTargetHandler.d.ts +17 -15
- package/dist/config/browserslistTargetHandler.js +27 -33
- package/dist/config/defaults.js +20 -21
- package/dist/config/normalization.d.ts +2 -0
- package/dist/config/normalization.js +5 -5
- package/dist/config/target.d.ts +48 -109
- package/dist/config/target.js +50 -86
- package/dist/config/zod.d.ts +2391 -2205
- package/dist/config/zod.js +28 -18
- package/dist/container/ContainerPlugin.d.ts +7 -7
- package/dist/container/options.js +1 -1
- package/dist/exports.d.ts +4 -4
- package/dist/exports.js +2 -2
- package/dist/lib/CacheFacade.js +1 -0
- package/dist/lib/ModuleFilenameHelpers.js +1 -3
- package/dist/lib/cache/mergeEtags.js +5 -11
- package/dist/lib/formatLocation.js +3 -5
- package/dist/loader-runner/LoaderLoadingError.d.ts +11 -1
- package/dist/loader-runner/LoaderLoadingError.js +3 -5
- package/dist/loader-runner/index.js +7 -9
- package/dist/loader-runner/loadLoader.d.ts +11 -2
- package/dist/loader-runner/loadLoader.js +17 -19
- package/dist/logging/createConsoleLogger.js +2 -6
- package/dist/logging/truncateArgs.js +5 -9
- package/dist/node/nodeConsole.js +1 -3
- package/dist/stats/DefaultStatsFactoryPlugin.js +17 -7
- package/dist/stats/DefaultStatsPresetPlugin.js +4 -4
- package/dist/stats/DefaultStatsPrinterPlugin.js +11 -16
- package/dist/stats/StatsFactory.js +13 -17
- package/dist/stats/StatsPrinter.js +7 -9
- package/dist/util/AssetInfo.js +11 -7
- package/dist/util/SplitChunkSize.js +1 -1
- package/dist/util/cleverMerge.d.ts +33 -57
- package/dist/util/cleverMerge.js +89 -145
- package/dist/util/comparators.js +3 -5
- package/dist/util/createHash.d.ts +4 -3
- package/dist/util/createHash.js +31 -45
- package/dist/util/fs.js +9 -13
- package/dist/util/hash/BatchedHash.d.ts +24 -9
- package/dist/util/hash/BatchedHash.js +16 -13
- package/dist/util/hash/index.d.ts +9 -9
- package/dist/util/hash/index.js +14 -11
- package/dist/util/hash/md4.d.ts +29 -2
- package/dist/util/hash/md4.js +7 -3
- package/dist/util/hash/wasm-hash.d.ts +52 -5
- package/dist/util/hash/wasm-hash.js +19 -22
- package/dist/util/hash/xxhash64.d.ts +29 -2
- package/dist/util/hash/xxhash64.js +7 -3
- package/dist/util/identifier.js +9 -15
- package/dist/util/index.js +1 -1
- package/dist/util/memoize.js +7 -9
- package/package.json +9 -8
- package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +0 -2
package/dist/config/zod.js
CHANGED
|
@@ -4,6 +4,11 @@ exports.rspackOptions = exports.externalsType = void 0;
|
|
|
4
4
|
const zod_1 = require("../../compiled/zod");
|
|
5
5
|
const Chunk_1 = require("../Chunk");
|
|
6
6
|
const Module_1 = require("../Module");
|
|
7
|
+
const filenameTemplate = zod_1.z.string();
|
|
8
|
+
const filename = filenameTemplate.or(zod_1.z
|
|
9
|
+
.function()
|
|
10
|
+
.args(zod_1.z.custom(), zod_1.z.custom().optional())
|
|
11
|
+
.returns(zod_1.z.string()));
|
|
7
12
|
//#region Name
|
|
8
13
|
const name = zod_1.z.string();
|
|
9
14
|
//#endregion
|
|
@@ -26,8 +31,7 @@ const falsy = zod_1.z.union([
|
|
|
26
31
|
]);
|
|
27
32
|
//#endregion
|
|
28
33
|
//#region Entry
|
|
29
|
-
const
|
|
30
|
-
const publicPath = zod_1.z.literal("auto").or(rawPublicPath);
|
|
34
|
+
const publicPath = zod_1.z.literal("auto").or(filename);
|
|
31
35
|
const baseUri = zod_1.z.string();
|
|
32
36
|
const chunkLoadingType = zod_1.z
|
|
33
37
|
.enum(["jsonp", "import-scripts", "require", "async-node", "import"])
|
|
@@ -89,12 +93,7 @@ const libraryOptions = zod_1.z.strictObject({
|
|
|
89
93
|
umdNamedDefine: umdNamedDefine.optional()
|
|
90
94
|
});
|
|
91
95
|
const library = libraryName.or(libraryOptions).optional();
|
|
92
|
-
const
|
|
93
|
-
const filename = filenameTemplate.or(zod_1.z
|
|
94
|
-
.function()
|
|
95
|
-
.args(zod_1.z.custom(), zod_1.z.custom().optional())
|
|
96
|
-
.returns(zod_1.z.string()));
|
|
97
|
-
const entryFilename = filenameTemplate;
|
|
96
|
+
const entryFilename = filename;
|
|
98
97
|
const entryRuntime = zod_1.z.literal(false).or(zod_1.z.string());
|
|
99
98
|
const entryItem = zod_1.z.string().or(zod_1.z.array(zod_1.z.string()));
|
|
100
99
|
const entryDependOn = zod_1.z.string().or(zod_1.z.array(zod_1.z.string()));
|
|
@@ -221,6 +220,8 @@ const output = zod_1.z.strictObject({
|
|
|
221
220
|
devtoolNamespace: devtoolNamespace.optional(),
|
|
222
221
|
devtoolModuleFilenameTemplate: devtoolModuleFilenameTemplate.optional(),
|
|
223
222
|
devtoolFallbackModuleFilenameTemplate: devtoolFallbackModuleFilenameTemplate.optional(),
|
|
223
|
+
chunkLoadTimeout: zod_1.z.number().optional(),
|
|
224
|
+
charset: zod_1.z.boolean().optional(),
|
|
224
225
|
environment: environment.optional()
|
|
225
226
|
});
|
|
226
227
|
//#endregion
|
|
@@ -390,7 +391,7 @@ const assetInlineGeneratorOptions = zod_1.z.strictObject({
|
|
|
390
391
|
});
|
|
391
392
|
const assetResourceGeneratorOptions = zod_1.z.strictObject({
|
|
392
393
|
emit: zod_1.z.boolean().optional(),
|
|
393
|
-
filename:
|
|
394
|
+
filename: filename.optional(),
|
|
394
395
|
publicPath: publicPath.optional()
|
|
395
396
|
});
|
|
396
397
|
const assetGeneratorOptions = assetInlineGeneratorOptions.merge(assetResourceGeneratorOptions);
|
|
@@ -519,7 +520,12 @@ const externalItemObjectUnknown = zod_1.z.record(externalItemValue);
|
|
|
519
520
|
const externalItemFunctionData = zod_1.z.strictObject({
|
|
520
521
|
context: zod_1.z.string().optional(),
|
|
521
522
|
dependencyType: zod_1.z.string().optional(),
|
|
522
|
-
request: zod_1.z.string().optional()
|
|
523
|
+
request: zod_1.z.string().optional(),
|
|
524
|
+
contextInfo: zod_1.z
|
|
525
|
+
.strictObject({
|
|
526
|
+
issuer: zod_1.z.string()
|
|
527
|
+
})
|
|
528
|
+
.optional()
|
|
523
529
|
});
|
|
524
530
|
const externalItem = zod_1.z
|
|
525
531
|
.string()
|
|
@@ -617,12 +623,19 @@ const snapshotOptions = zod_1.z.strictObject({});
|
|
|
617
623
|
const cacheOptions = zod_1.z.boolean();
|
|
618
624
|
//#endregion
|
|
619
625
|
//#region Stats
|
|
626
|
+
const statsPresets = zod_1.z.enum([
|
|
627
|
+
"normal",
|
|
628
|
+
"none",
|
|
629
|
+
"verbose",
|
|
630
|
+
"errors-only",
|
|
631
|
+
"errors-warnings",
|
|
632
|
+
"minimal",
|
|
633
|
+
"detailed",
|
|
634
|
+
"summary"
|
|
635
|
+
]);
|
|
620
636
|
const statsOptions = zod_1.z.strictObject({
|
|
621
637
|
all: zod_1.z.boolean().optional(),
|
|
622
|
-
preset: zod_1.z
|
|
623
|
-
.boolean()
|
|
624
|
-
.or(zod_1.z.enum(["normal", "none", "verbose", "errors-only", "errors-warnings"]))
|
|
625
|
-
.optional(),
|
|
638
|
+
preset: zod_1.z.boolean().or(statsPresets).optional(),
|
|
626
639
|
assets: zod_1.z.boolean().optional(),
|
|
627
640
|
chunks: zod_1.z.boolean().optional(),
|
|
628
641
|
modules: zod_1.z.boolean().optional(),
|
|
@@ -713,10 +726,7 @@ const statsOptions = zod_1.z.strictObject({
|
|
|
713
726
|
errorStack: zod_1.z.boolean().optional(),
|
|
714
727
|
moduleTrace: zod_1.z.boolean().optional()
|
|
715
728
|
});
|
|
716
|
-
const statsValue = zod_1.z
|
|
717
|
-
.enum(["none", "errors-only", "errors-warnings", "normal", "verbose"])
|
|
718
|
-
.or(zod_1.z.boolean())
|
|
719
|
-
.or(statsOptions);
|
|
729
|
+
const statsValue = zod_1.z.boolean().or(statsPresets).or(statsOptions);
|
|
720
730
|
const plugin = zod_1.z.union([
|
|
721
731
|
zod_1.z.custom(),
|
|
722
732
|
zod_1.z.custom(),
|
|
@@ -28,19 +28,19 @@ export declare class ContainerPlugin extends RspackBuiltinPlugin {
|
|
|
28
28
|
shareScope: string;
|
|
29
29
|
library: {
|
|
30
30
|
type: string;
|
|
31
|
+
name?: string | string[] | {
|
|
32
|
+
commonjs?: string | undefined;
|
|
33
|
+
amd?: string | undefined;
|
|
34
|
+
root?: string | string[] | undefined;
|
|
35
|
+
} | undefined;
|
|
31
36
|
amdContainer?: string | undefined;
|
|
32
37
|
auxiliaryComment?: string | {
|
|
33
|
-
amd?: string | undefined;
|
|
34
38
|
commonjs?: string | undefined;
|
|
35
|
-
|
|
39
|
+
amd?: string | undefined;
|
|
36
40
|
root?: string | undefined;
|
|
41
|
+
commonjs2?: string | undefined;
|
|
37
42
|
} | undefined;
|
|
38
43
|
export?: string | string[] | undefined;
|
|
39
|
-
name?: string | string[] | {
|
|
40
|
-
amd?: string | undefined;
|
|
41
|
-
commonjs?: string | undefined;
|
|
42
|
-
root?: string | string[] | undefined;
|
|
43
|
-
} | undefined;
|
|
44
44
|
umdNamedDefine?: boolean | undefined;
|
|
45
45
|
};
|
|
46
46
|
runtime: string | false | undefined;
|
package/dist/exports.d.ts
CHANGED
|
@@ -18,8 +18,7 @@ export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule,
|
|
|
18
18
|
export { Stats } from "./Stats";
|
|
19
19
|
import * as ModuleFilenameHelpers from "./lib/ModuleFilenameHelpers";
|
|
20
20
|
export { ModuleFilenameHelpers };
|
|
21
|
-
|
|
22
|
-
export { Template };
|
|
21
|
+
export { Template } from "./Template";
|
|
23
22
|
export declare const WebpackError: ErrorConstructor;
|
|
24
23
|
export type { Watching } from "./Watching";
|
|
25
24
|
import sources = require("../compiled/webpack-sources");
|
|
@@ -34,8 +33,8 @@ type Config = {
|
|
|
34
33
|
export declare const config: Config;
|
|
35
34
|
export type * from "./config";
|
|
36
35
|
export declare const util: {
|
|
37
|
-
createHash: (algorithm:
|
|
38
|
-
cleverMerge: <
|
|
36
|
+
createHash: (algorithm: "debug" | "md4" | "xxhash64" | (string & {}) | "native-md4" | (new () => import("./util/hash").default)) => import("./util/hash").default;
|
|
37
|
+
cleverMerge: <First, Second>(first: First, second: Second) => First | Second | (First & Second);
|
|
39
38
|
};
|
|
40
39
|
export { default as EntryOptionPlugin } from "./lib/EntryOptionPlugin";
|
|
41
40
|
export { type OutputFileSystem } from "./util/fs";
|
|
@@ -148,6 +147,7 @@ export { EvalSourceMapDevToolPlugin } from "./builtin-plugin";
|
|
|
148
147
|
export { EvalDevToolModulePlugin } from "./builtin-plugin";
|
|
149
148
|
export { CssExtractRspackPlugin } from "./builtin-plugin";
|
|
150
149
|
export type { SwcLoaderEnvConfig, SwcLoaderEsParserConfig, SwcLoaderJscConfig, SwcLoaderModuleConfig, SwcLoaderOptions, SwcLoaderParserConfig, SwcLoaderTransformConfig, SwcLoaderTsParserConfig } from "./builtin-loader/swc/index";
|
|
150
|
+
export { type LoaderOptions as LightningcssLoaderOptions, type FeatureOptions as LightningcssFeatureOptions } from "./builtin-loader/lightningcss/index";
|
|
151
151
|
import { cleanupGlobalTrace, registerGlobalTrace } from "@rspack/binding";
|
|
152
152
|
interface Experiments {
|
|
153
153
|
globalTrace: {
|
package/dist/exports.js
CHANGED
|
@@ -52,8 +52,8 @@ Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { r
|
|
|
52
52
|
const ModuleFilenameHelpers = __importStar(require("./lib/ModuleFilenameHelpers"));
|
|
53
53
|
exports.ModuleFilenameHelpers = ModuleFilenameHelpers;
|
|
54
54
|
// API extractor not working with some re-exports, see: https://github.com/microsoft/fluentui/issues/20694
|
|
55
|
-
|
|
56
|
-
exports
|
|
55
|
+
var Template_1 = require("./Template");
|
|
56
|
+
Object.defineProperty(exports, "Template", { enumerable: true, get: function () { return Template_1.Template; } });
|
|
57
57
|
exports.WebpackError = Error;
|
|
58
58
|
const sources = require("../compiled/webpack-sources");
|
|
59
59
|
exports.sources = sources;
|
package/dist/lib/CacheFacade.js
CHANGED
|
@@ -52,6 +52,7 @@ class MultiItemCache {
|
|
|
52
52
|
getPromise() {
|
|
53
53
|
// @ts-expect-error
|
|
54
54
|
const next = i => {
|
|
55
|
+
// @ts-ignore if your typescript version >= 5.5, this line will throw an error
|
|
55
56
|
return this._items[i].getPromise().then(result => {
|
|
56
57
|
if (result !== undefined)
|
|
57
58
|
return result;
|
|
@@ -27,9 +27,7 @@ const matchPart = (str, test) => {
|
|
|
27
27
|
if (Array.isArray(test)) {
|
|
28
28
|
return test.map(exports.asRegExp).some(regExp => regExp.test(str));
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
return (0, exports.asRegExp)(test).test(str);
|
|
32
|
-
}
|
|
30
|
+
return (0, exports.asRegExp)(test).test(str);
|
|
33
31
|
};
|
|
34
32
|
exports.matchPart = matchPart;
|
|
35
33
|
/**
|
|
@@ -29,11 +29,9 @@ const mergeEtags = (a, b) => {
|
|
|
29
29
|
if (typeof b === "string") {
|
|
30
30
|
return `${a}|${b}`;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
a = temp;
|
|
36
|
-
}
|
|
32
|
+
const temp = b;
|
|
33
|
+
b = a;
|
|
34
|
+
a = temp;
|
|
37
35
|
}
|
|
38
36
|
else {
|
|
39
37
|
if (typeof b !== "string") {
|
|
@@ -48,9 +46,7 @@ const mergeEtags = (a, b) => {
|
|
|
48
46
|
map.set(b, newMergedEtag);
|
|
49
47
|
return newMergedEtag;
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
return mergedEtag;
|
|
53
|
-
}
|
|
49
|
+
return mergedEtag;
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
// a is object, b is string
|
|
@@ -64,8 +60,6 @@ const mergeEtags = (a, b) => {
|
|
|
64
60
|
map.set(b, newMergedEtag);
|
|
65
61
|
return newMergedEtag;
|
|
66
62
|
}
|
|
67
|
-
|
|
68
|
-
return mergedEtag;
|
|
69
|
-
}
|
|
63
|
+
return mergedEtag;
|
|
70
64
|
};
|
|
71
65
|
module.exports = mergeEtags;
|
|
@@ -16,7 +16,7 @@ const formatPosition = pos => {
|
|
|
16
16
|
if ("line" in pos && "column" in pos) {
|
|
17
17
|
return `${pos.line}:${pos.column}`;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
if ("line" in pos) {
|
|
20
20
|
return `${pos.line}:?`;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -37,7 +37,7 @@ const formatLocation = loc => {
|
|
|
37
37
|
loc.start.line === loc.end.line) {
|
|
38
38
|
return `${formatPosition(loc.start)}-${loc.end.column}`;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
if (typeof loc.start === "object" &&
|
|
41
41
|
typeof loc.start.line === "number" &&
|
|
42
42
|
typeof loc.start.column !== "number" &&
|
|
43
43
|
typeof loc.end === "object" &&
|
|
@@ -45,9 +45,7 @@ const formatLocation = loc => {
|
|
|
45
45
|
typeof loc.end.column !== "number") {
|
|
46
46
|
return `${loc.start.line}-${loc.end.line}`;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
return `${formatPosition(loc.start)}-${formatPosition(loc.end)}`;
|
|
50
|
-
}
|
|
48
|
+
return `${formatPosition(loc.start)}-${formatPosition(loc.end)}`;
|
|
51
49
|
}
|
|
52
50
|
if ("start" in loc && loc.start) {
|
|
53
51
|
return formatPosition(loc.start);
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The following code is from
|
|
3
|
+
* https://github.com/webpack/loader-runner
|
|
4
|
+
*
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
* Author Tobias Koppers @sokra
|
|
7
|
+
* Copyright (c) JS Foundation and other contributors
|
|
8
|
+
* https://github.com/webpack/loader-runner/blob/main/LICENSE
|
|
9
|
+
*/
|
|
2
10
|
declare class LoadingLoaderError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
3
12
|
}
|
|
13
|
+
export default LoadingLoaderError;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* The following code is from
|
|
3
4
|
* https://github.com/webpack/loader-runner
|
|
@@ -7,15 +8,12 @@
|
|
|
7
8
|
* Copyright (c) JS Foundation and other contributors
|
|
8
9
|
* https://github.com/webpack/loader-runner/blob/main/LICENSE
|
|
9
10
|
*/
|
|
10
|
-
"
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
12
|
class LoadingLoaderError extends Error {
|
|
12
|
-
/**
|
|
13
|
-
* @param {string=} message
|
|
14
|
-
*/
|
|
15
13
|
constructor(message) {
|
|
16
14
|
super(message);
|
|
17
15
|
this.name = "LoaderRunnerError";
|
|
18
16
|
Error.captureStackTrace(this, this.constructor);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
|
|
19
|
+
exports.default = LoadingLoaderError;
|
|
@@ -293,7 +293,6 @@ async function runLoaders(compiler, context) {
|
|
|
293
293
|
const contextDependencies = context.contextDependencies;
|
|
294
294
|
const missingDependencies = context.missingDependencies;
|
|
295
295
|
const buildDependencies = context.buildDependencies;
|
|
296
|
-
const assetFilenames = context.assetFilenames;
|
|
297
296
|
/// Construct `loaderContext`
|
|
298
297
|
const loaderContext = {};
|
|
299
298
|
loaderContext.loaders = context.loaderItems.map(item => {
|
|
@@ -356,7 +355,6 @@ async function runLoaders(compiler, context) {
|
|
|
356
355
|
if (res.cacheable === false) {
|
|
357
356
|
this.cacheable(false);
|
|
358
357
|
}
|
|
359
|
-
assetFilenames.push(...res.assets);
|
|
360
358
|
resolve(compiler.__internal__getModuleExecutionResult(res.id));
|
|
361
359
|
}
|
|
362
360
|
});
|
|
@@ -384,7 +382,6 @@ async function runLoaders(compiler, context) {
|
|
|
384
382
|
if (res.cacheable === false) {
|
|
385
383
|
this.cacheable(false);
|
|
386
384
|
}
|
|
387
|
-
assetFilenames.push(...res.assets);
|
|
388
385
|
callback(undefined, compiler.__internal__getModuleExecutionResult(res.id));
|
|
389
386
|
}
|
|
390
387
|
});
|
|
@@ -560,9 +557,12 @@ async function runLoaders(compiler, context) {
|
|
|
560
557
|
// @ts-expect-error webpack-sources type declaration is wrong
|
|
561
558
|
content);
|
|
562
559
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
560
|
+
// @ts-expect-error
|
|
561
|
+
compiler._lastCompilation.__internal__emit_asset_from_loader(name,
|
|
562
|
+
// @ts-expect-error
|
|
563
|
+
source,
|
|
564
|
+
// @ts-expect-error
|
|
565
|
+
assetInfo, context._moduleIdentifier);
|
|
566
566
|
};
|
|
567
567
|
loaderContext.fs = compiler.inputFileSystem;
|
|
568
568
|
const getAbsolutify = (0, memoize_1.memoize)(() => identifier_1.absolutify.bindCache(compiler.root));
|
|
@@ -709,9 +709,7 @@ function utf8BufferToString(buf) {
|
|
|
709
709
|
if (str.charCodeAt(0) === 0xfeff) {
|
|
710
710
|
return str.slice(1);
|
|
711
711
|
}
|
|
712
|
-
|
|
713
|
-
return str;
|
|
714
|
-
}
|
|
712
|
+
return str;
|
|
715
713
|
}
|
|
716
714
|
function convertArgs(args, raw) {
|
|
717
715
|
if (!raw && Buffer.isBuffer(args[0]))
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The following code is from
|
|
3
|
+
* https://github.com/webpack/loader-runner
|
|
4
|
+
*
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
* Author Tobias Koppers @sokra
|
|
7
|
+
* Copyright (c) JS Foundation and other contributors
|
|
8
|
+
* https://github.com/webpack/loader-runner/blob/main/LICENSE
|
|
9
|
+
*/
|
|
10
|
+
import type { LoaderObject } from ".";
|
|
11
|
+
export default function loadLoader(loader: LoaderObject, callback: (err: unknown) => void): void;
|
|
@@ -8,19 +8,20 @@
|
|
|
8
8
|
* Copyright (c) JS Foundation and other contributors
|
|
9
9
|
* https://github.com/webpack/loader-runner/blob/main/LICENSE
|
|
10
10
|
*/
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const LoaderLoadingError_1 = __importDefault(require("./LoaderLoadingError"));
|
|
16
|
+
var url = undefined;
|
|
17
|
+
function loadLoader(loader, callback) {
|
|
16
18
|
if (loader.type === "module") {
|
|
17
19
|
try {
|
|
18
20
|
if (url === undefined)
|
|
19
21
|
url = require("node:url");
|
|
20
22
|
var loaderUrl = url.pathToFileURL(loader.path);
|
|
21
|
-
/** @type {Promise<any>} */
|
|
22
23
|
var modulePromise = eval("import(" + JSON.stringify(loaderUrl.toString()) + ")");
|
|
23
|
-
modulePromise.then(module => {
|
|
24
|
+
modulePromise.then((module) => {
|
|
24
25
|
handleResult(loader, module, callback);
|
|
25
26
|
}, callback);
|
|
26
27
|
return;
|
|
@@ -36,28 +37,25 @@ module.exports = function loadLoader(loader, callback) {
|
|
|
36
37
|
catch (e) {
|
|
37
38
|
// it is possible for node to choke on a require if the FD descriptor
|
|
38
39
|
// limit has been reached. give it a chance to recover.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// @ts-expect-error
|
|
40
|
+
if (e instanceof Error &&
|
|
41
|
+
e.code === "EMFILE") {
|
|
42
42
|
var retry = loadLoader.bind(null, loader, callback);
|
|
43
43
|
if (typeof setImmediate === "function") {
|
|
44
44
|
// node >= 0.9.0
|
|
45
|
-
return setImmediate(retry);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
// node < 0.9.0
|
|
49
|
-
return process.nextTick(retry);
|
|
45
|
+
return void setImmediate(retry);
|
|
50
46
|
}
|
|
47
|
+
// node < 0.9.0
|
|
48
|
+
return process.nextTick(retry);
|
|
51
49
|
}
|
|
52
50
|
return callback(e);
|
|
53
51
|
}
|
|
54
52
|
return handleResult(loader, module, callback);
|
|
55
53
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
54
|
+
}
|
|
55
|
+
exports.default = loadLoader;
|
|
58
56
|
function handleResult(loader, module, callback) {
|
|
59
57
|
if (typeof module !== "function" && typeof module !== "object") {
|
|
60
|
-
return callback(new
|
|
58
|
+
return callback(new LoaderLoadingError_1.default("Module '" +
|
|
61
59
|
loader.path +
|
|
62
60
|
"' is not a loader (export function or es6 module)"));
|
|
63
61
|
}
|
|
@@ -66,7 +64,7 @@ function handleResult(loader, module, callback) {
|
|
|
66
64
|
loader.raw = module.raw;
|
|
67
65
|
if (typeof loader.normal !== "function" &&
|
|
68
66
|
typeof loader.pitch !== "function") {
|
|
69
|
-
return callback(new
|
|
67
|
+
return callback(new LoaderLoadingError_1.default("Module '" +
|
|
70
68
|
loader.path +
|
|
71
69
|
"' is not a loader (must have normal or pitch function)"));
|
|
72
70
|
}
|
|
@@ -87,13 +87,9 @@ module.exports = ({ level = "info", debug = false, console }) => {
|
|
|
87
87
|
if (args.length > 0 && typeof args[0] === "string") {
|
|
88
88
|
return [`[${name}] ${args[0]}`, ...args.slice(1)];
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
return [`[${name}]`, ...args];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
return [];
|
|
90
|
+
return [`[${name}]`, ...args];
|
|
96
91
|
}
|
|
92
|
+
return [];
|
|
97
93
|
};
|
|
98
94
|
const debug = debugFilters.some(f => f(name));
|
|
99
95
|
switch (type) {
|
|
@@ -30,12 +30,10 @@ const truncateArgs = (args, maxLength) => {
|
|
|
30
30
|
if (availableLength >= args[0].length) {
|
|
31
31
|
return args;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
if (availableLength > 3) {
|
|
34
34
|
return ["..." + args[0].slice(-availableLength + 3)];
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
return [args[0].slice(-availableLength)];
|
|
38
|
-
}
|
|
36
|
+
return [args[0].slice(-availableLength)];
|
|
39
37
|
}
|
|
40
38
|
// Check if there is space for at least 4 chars per arg
|
|
41
39
|
// @ts-expect-error
|
|
@@ -76,15 +74,13 @@ const truncateArgs = (args, maxLength) => {
|
|
|
76
74
|
if (str.length === length) {
|
|
77
75
|
return str;
|
|
78
76
|
}
|
|
79
|
-
|
|
77
|
+
if (length > 5) {
|
|
80
78
|
return "..." + str.slice(-length + 3);
|
|
81
79
|
}
|
|
82
|
-
|
|
80
|
+
if (length > 0) {
|
|
83
81
|
return str.slice(-length);
|
|
84
82
|
}
|
|
85
|
-
|
|
86
|
-
return "";
|
|
87
|
-
}
|
|
83
|
+
return "";
|
|
88
84
|
});
|
|
89
85
|
};
|
|
90
86
|
exports.truncateArgs = truncateArgs;
|
package/dist/node/nodeConsole.js
CHANGED
|
@@ -50,9 +50,7 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|
|
50
50
|
str.replace(/\n/g, colorSuffix + "\n" + prefix + colorPrefix) +
|
|
51
51
|
colorSuffix);
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
return prefix + str.replace(/\n/g, "\n" + prefix);
|
|
55
|
-
}
|
|
53
|
+
return prefix + str.replace(/\n/g, "\n" + prefix);
|
|
56
54
|
};
|
|
57
55
|
const clearStatusMessage = () => {
|
|
58
56
|
if (hasStatusMessage) {
|
|
@@ -261,7 +261,7 @@ const MODULES_GROUPERS = (type) => ({
|
|
|
261
261
|
if (groupModulesByType) {
|
|
262
262
|
return [module.moduleType.split("/", 1)[0]];
|
|
263
263
|
}
|
|
264
|
-
|
|
264
|
+
if (module.moduleType === "runtime") {
|
|
265
265
|
return ["runtime"];
|
|
266
266
|
}
|
|
267
267
|
},
|
|
@@ -395,16 +395,21 @@ const RESULT_SORTERS = {
|
|
|
395
395
|
"compilation.assets": ASSET_SORTERS,
|
|
396
396
|
"asset.related": ASSET_SORTERS
|
|
397
397
|
};
|
|
398
|
+
const MODULES_SORTER = {
|
|
399
|
+
_: comparators => {
|
|
400
|
+
comparators.push((0, comparators_1.compareSelect)((m) => m.depth, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.preOrderIndex, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.identifier, compareIds));
|
|
401
|
+
}
|
|
402
|
+
};
|
|
398
403
|
const SORTERS = {
|
|
399
404
|
"compilation.chunks": {
|
|
400
405
|
_: comparators => {
|
|
401
406
|
comparators.push((0, comparators_1.compareSelect)((c) => c.id, compareIds));
|
|
402
407
|
}
|
|
403
408
|
},
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
409
|
+
"compilation.modules": MODULES_SORTER,
|
|
410
|
+
"chunk.rootModules": MODULES_SORTER,
|
|
411
|
+
"chunk.modules": MODULES_SORTER,
|
|
412
|
+
"module.modules": MODULES_SORTER,
|
|
408
413
|
// not support module.reasons (missing Module.identifier())
|
|
409
414
|
"chunk.origins": {
|
|
410
415
|
_: comparators => {
|
|
@@ -665,7 +670,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
665
670
|
// compilationFileToChunks
|
|
666
671
|
// compilationAuxiliaryFileToChunks
|
|
667
672
|
});
|
|
668
|
-
const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace
|
|
673
|
+
const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace ?? Number.POSITIVE_INFINITY);
|
|
669
674
|
object.assets = limited.children;
|
|
670
675
|
object.filteredAssets = limited.filteredChildren;
|
|
671
676
|
},
|
|
@@ -807,7 +812,12 @@ const SIMPLE_EXTRACTORS = {
|
|
|
807
812
|
object.moduleType = module.moduleType;
|
|
808
813
|
// TODO: object.layer = module.layer;
|
|
809
814
|
object.size = module.size;
|
|
810
|
-
|
|
815
|
+
const sizes = module.sizes.map(({ sourceType, size }) => [
|
|
816
|
+
sourceType,
|
|
817
|
+
size
|
|
818
|
+
]);
|
|
819
|
+
sizes.sort((a, b) => -compareIds(a, b));
|
|
820
|
+
object.sizes = Object.fromEntries(sizes);
|
|
811
821
|
object.built = module.built;
|
|
812
822
|
object.codeGenerated = module.codeGenerated;
|
|
813
823
|
object.buildTimeExecuted = module.buildTimeExecuted;
|
|
@@ -43,7 +43,7 @@ const NAMED_PRESETS = {
|
|
|
43
43
|
// warningsSpace: Infinity,
|
|
44
44
|
modulesSpace: Number.POSITIVE_INFINITY,
|
|
45
45
|
// chunkModulesSpace: Infinity,
|
|
46
|
-
|
|
46
|
+
assetsSpace: Number.POSITIVE_INFINITY,
|
|
47
47
|
// reasonsSpace: Infinity,
|
|
48
48
|
children: true
|
|
49
49
|
},
|
|
@@ -69,8 +69,8 @@ const NAMED_PRESETS = {
|
|
|
69
69
|
// exclude: false,
|
|
70
70
|
// errorsSpace: 1000,
|
|
71
71
|
// warningsSpace: 1000,
|
|
72
|
-
modulesSpace: 1000
|
|
73
|
-
|
|
72
|
+
modulesSpace: 1000,
|
|
73
|
+
assetsSpace: 1000
|
|
74
74
|
// reasonsSpace: 1000
|
|
75
75
|
},
|
|
76
76
|
minimal: {
|
|
@@ -82,7 +82,7 @@ const NAMED_PRESETS = {
|
|
|
82
82
|
// warningsSpace: 0,
|
|
83
83
|
modulesSpace: 0,
|
|
84
84
|
assets: true,
|
|
85
|
-
|
|
85
|
+
assetsSpace: 0,
|
|
86
86
|
errors: true,
|
|
87
87
|
errorsCount: true,
|
|
88
88
|
warnings: true,
|
|
@@ -19,7 +19,7 @@ const printSizes = (sizes, { formatSize = (n) => `${n}` }) => {
|
|
|
19
19
|
if (keys.length > 1) {
|
|
20
20
|
return keys.map(key => `${formatSize(sizes[key])} (${key})`).join(" ");
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
if (keys.length === 1) {
|
|
23
23
|
return formatSize(sizes[keys[0]]);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
@@ -242,9 +242,7 @@ const SIMPLE_PRINTERS = {
|
|
|
242
242
|
providedExportsCount === usedExports.length) {
|
|
243
243
|
return cyan(formatFlag("all exports used"));
|
|
244
244
|
}
|
|
245
|
-
|
|
246
|
-
return cyan(formatFlag(`only some exports used: ${usedExports.join(", ")}`));
|
|
247
|
-
}
|
|
245
|
+
return cyan(formatFlag(`only some exports used: ${usedExports.join(", ")}`));
|
|
248
246
|
}
|
|
249
247
|
}
|
|
250
248
|
},
|
|
@@ -909,23 +907,20 @@ const AVAILABLE_FORMATS = {
|
|
|
909
907
|
];
|
|
910
908
|
if (time < times[3])
|
|
911
909
|
return `${time}${unit}`;
|
|
912
|
-
|
|
910
|
+
if (time < times[2])
|
|
913
911
|
return bold(`${time}${unit}`);
|
|
914
|
-
|
|
912
|
+
if (time < times[1])
|
|
915
913
|
return green(`${time}${unit}`);
|
|
916
|
-
|
|
914
|
+
if (time < times[0])
|
|
917
915
|
return yellow(`${time}${unit}`);
|
|
918
|
-
|
|
919
|
-
return red(`${time}${unit}`);
|
|
916
|
+
return red(`${time}${unit}`);
|
|
920
917
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
unit = " s";
|
|
926
|
-
}
|
|
927
|
-
return `${boldQuantity ? bold(timeStr) : timeStr}${unit}`;
|
|
918
|
+
let timeStr = time.toString();
|
|
919
|
+
if (time > 1000) {
|
|
920
|
+
timeStr = `${(time / 1000).toFixed(2)}`;
|
|
921
|
+
unit = " s";
|
|
928
922
|
}
|
|
923
|
+
return `${boldQuantity ? bold(timeStr) : timeStr}${unit}`;
|
|
929
924
|
},
|
|
930
925
|
formatError: (msg, { green, yellow, red }) => {
|
|
931
926
|
let message = msg;
|