@rspack/core 1.0.0-alpha.0 → 1.0.0-alpha.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/enhanced-resolve/index.js +11 -11
- package/compiled/zod-validation-error/index.d.ts +4 -170
- package/compiled/zod-validation-error/index.js +4 -4154
- package/dist/Compilation.d.ts +12 -10
- package/dist/Compilation.js +13 -10
- package/dist/Compiler.d.ts +25 -27
- package/dist/Compiler.js +42 -24
- package/dist/ContextModuleFactory.d.ts +1 -1
- package/dist/ContextModuleFactory.js +1 -1
- package/dist/MultiCompiler.d.ts +11 -11
- package/dist/MultiCompiler.js +30 -13
- package/dist/NormalModule.d.ts +7 -3
- package/dist/NormalModule.js +27 -4
- package/dist/NormalModuleFactory.d.ts +2 -1
- package/dist/NormalModuleFactory.js +2 -1
- package/dist/ResolverFactory.d.ts +3 -3
- package/dist/ResolverFactory.js +1 -1
- package/dist/Stats.d.ts +2 -0
- package/dist/Stats.js +6 -0
- package/dist/Watching.d.ts +1 -1
- package/dist/builtin-loader/swc/index.d.ts +0 -2
- package/dist/builtin-loader/swc/index.js +1 -3
- package/dist/builtin-loader/swc/types.d.ts +0 -2
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -1
- package/dist/builtin-plugin/SplitChunksPlugin.js +11 -2
- package/dist/config/adapter.js +7 -6
- package/dist/config/adapterRuleUse.js +0 -3
- package/dist/config/zod.d.ts +585 -162
- package/dist/config/zod.js +4 -2
- package/dist/exports.d.ts +8 -1
- package/dist/exports.js +10 -5
- package/dist/lib/Cache.d.ts +3 -3
- package/dist/lib/Cache.js +1 -1
- package/dist/loader-runner/index.js +9 -5
- package/dist/node/nodeConsole.js +26 -3
- package/dist/rspack.d.ts +1 -1
- package/dist/stats/StatsFactory.d.ts +2 -2
- package/dist/stats/StatsFactory.js +12 -12
- package/dist/stats/StatsPrinter.d.ts +1 -1
- package/dist/stats/StatsPrinter.js +8 -8
- package/dist/util/SplitChunkSize.d.ts +5 -0
- package/dist/util/SplitChunkSize.js +18 -0
- package/package.json +6 -6
- package/dist/builtin-loader/swc/preact.d.ts +0 -6
- package/dist/builtin-loader/swc/preact.js +0 -15
- package/dist/lite-tapable/index.d.ts +0 -146
- package/dist/lite-tapable/index.js +0 -752
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveReact = exports.resolvePluginImport = void 0;
|
|
4
4
|
var pluginImport_1 = require("./pluginImport");
|
|
5
5
|
Object.defineProperty(exports, "resolvePluginImport", { enumerable: true, get: function () { return pluginImport_1.resolvePluginImport; } });
|
|
6
6
|
var react_1 = require("./react");
|
|
7
7
|
Object.defineProperty(exports, "resolveReact", { enumerable: true, get: function () { return react_1.resolveReact; } });
|
|
8
|
-
var preact_1 = require("./preact");
|
|
9
|
-
Object.defineProperty(exports, "resolvePreact", { enumerable: true, get: function () { return preact_1.resolvePreact; } });
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* license at https://github.com/swc-project/swc/blob/main/LICENSE
|
|
4
4
|
*/
|
|
5
5
|
import type { PluginImportOptions } from "./pluginImport";
|
|
6
|
-
import type { PreactOptions } from "./preact";
|
|
7
6
|
import type { ReactOptions } from "./react";
|
|
8
7
|
export type JscTarget = "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "esnext";
|
|
9
8
|
export type SwcLoaderParserConfig = SwcLoaderTsParserConfig | SwcLoaderEsParserConfig;
|
|
@@ -442,6 +441,5 @@ export type SwcLoaderOptions = {
|
|
|
442
441
|
*/
|
|
443
442
|
rspackExperiments?: {
|
|
444
443
|
import?: PluginImportOptions;
|
|
445
|
-
preact?: PreactOptions;
|
|
446
444
|
};
|
|
447
445
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
|
|
2
|
+
import * as liteTapable from "@rspack/lite-tapable";
|
|
2
3
|
import { Compilation } from "../Compilation";
|
|
3
|
-
import * as liteTapable from "../lite-tapable";
|
|
4
4
|
import { RspackBuiltinPlugin } from "./base";
|
|
5
5
|
import Hash = require("../util/hash");
|
|
6
6
|
import { Chunk } from "../Chunk";
|
|
@@ -25,8 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.JavascriptModulesPlugin = void 0;
|
|
27
27
|
const binding_1 = require("@rspack/binding");
|
|
28
|
+
const liteTapable = __importStar(require("@rspack/lite-tapable"));
|
|
28
29
|
const Compilation_1 = require("../Compilation");
|
|
29
|
-
const liteTapable = __importStar(require("../lite-tapable"));
|
|
30
30
|
const base_1 = require("./base");
|
|
31
31
|
const compilationHooksMap = new WeakMap();
|
|
32
32
|
class JavascriptModulesPlugin extends base_1.RspackBuiltinPlugin {
|
|
@@ -5,7 +5,7 @@ const binding_1 = require("@rspack/binding");
|
|
|
5
5
|
const base_1 = require("./base");
|
|
6
6
|
exports.LightningCssMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.LightningCssMinimizerRspackPlugin, (options) => {
|
|
7
7
|
return {
|
|
8
|
-
errorRecovery: options?.errorRecovery ??
|
|
8
|
+
errorRecovery: options?.errorRecovery ?? true,
|
|
9
9
|
unusedSymbols: options?.unusedSymbols ?? [],
|
|
10
10
|
removeUnusedLocalIdents: options?.removeUnusedLocalIdents ?? true,
|
|
11
11
|
browserslist: options?.browserslist ?? ["defaults"]
|
|
@@ -8,6 +8,7 @@ const assert_1 = __importDefault(require("assert"));
|
|
|
8
8
|
const binding_1 = require("@rspack/binding");
|
|
9
9
|
const Chunk_1 = require("../Chunk");
|
|
10
10
|
const Module_1 = require("../Module");
|
|
11
|
+
const SplitChunkSize_1 = require("../util/SplitChunkSize");
|
|
11
12
|
const base_1 = require("./base");
|
|
12
13
|
class SplitChunksPlugin extends base_1.RspackBuiltinPlugin {
|
|
13
14
|
constructor(options) {
|
|
@@ -65,7 +66,7 @@ function toRawSplitChunksOptions(sc, compiler) {
|
|
|
65
66
|
return chunks;
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
|
-
const { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, ...passThrough } = sc;
|
|
69
|
+
const { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, minSize, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = sc;
|
|
69
70
|
return {
|
|
70
71
|
name: getName(name),
|
|
71
72
|
chunks: getChunks(chunks),
|
|
@@ -74,12 +75,16 @@ function toRawSplitChunksOptions(sc, compiler) {
|
|
|
74
75
|
.filter(([_key, group]) => group !== false)
|
|
75
76
|
.map(([key, group]) => {
|
|
76
77
|
group = group;
|
|
77
|
-
const { test, name, chunks, ...passThrough } = group;
|
|
78
|
+
const { test, name, chunks, minSize, maxSize, maxAsyncSize, maxInitialSize, ...passThrough } = group;
|
|
78
79
|
const rawGroup = {
|
|
79
80
|
key,
|
|
80
81
|
test: getTest(test),
|
|
81
82
|
name: getName(name),
|
|
82
83
|
chunks: getChunks(chunks),
|
|
84
|
+
minSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(minSize),
|
|
85
|
+
maxSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxSize),
|
|
86
|
+
maxAsyncSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
87
|
+
maxInitialSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
83
88
|
...passThrough
|
|
84
89
|
};
|
|
85
90
|
return rawGroup;
|
|
@@ -88,6 +93,10 @@ function toRawSplitChunksOptions(sc, compiler) {
|
|
|
88
93
|
chunks: getChunks(chunks),
|
|
89
94
|
...fallbackCacheGroup
|
|
90
95
|
},
|
|
96
|
+
minSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(minSize),
|
|
97
|
+
maxSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxSize),
|
|
98
|
+
maxAsyncSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxAsyncSize),
|
|
99
|
+
maxInitialSize: SplitChunkSize_1.JsSplitChunkSizes.__to_binding(maxInitialSize),
|
|
91
100
|
...passThrough
|
|
92
101
|
};
|
|
93
102
|
}
|
package/dist/config/adapter.js
CHANGED
|
@@ -214,7 +214,7 @@ function getRawModule(module, options) {
|
|
|
214
214
|
{ rules: module.defaultRules },
|
|
215
215
|
{ rules: module.rules }
|
|
216
216
|
];
|
|
217
|
-
const rules = ruleSet.map((rule, index) => getRawModuleRule(rule, `ruleSet[${index}]`, options));
|
|
217
|
+
const rules = ruleSet.map((rule, index) => getRawModuleRule(rule, `ruleSet[${index}]`, options, "javascript/auto"));
|
|
218
218
|
return {
|
|
219
219
|
rules,
|
|
220
220
|
parser: getRawParserOptionsByModuleType(module.parser),
|
|
@@ -248,7 +248,7 @@ function tryMatch(payload, condition) {
|
|
|
248
248
|
}
|
|
249
249
|
return false;
|
|
250
250
|
}
|
|
251
|
-
const getRawModuleRule = (rule, path, options) => {
|
|
251
|
+
const getRawModuleRule = (rule, path, options, upperType) => {
|
|
252
252
|
// Rule.loader is a shortcut to Rule.use: [ { loader } ].
|
|
253
253
|
// See: https://webpack.js.org/configuration/module/#ruleloader
|
|
254
254
|
if (rule.loader) {
|
|
@@ -300,17 +300,17 @@ const getRawModuleRule = (rule, path, options) => {
|
|
|
300
300
|
: (0, adapterRuleUse_1.createRawModuleRuleUses)(rule.use ?? [], `${path}.use`, options),
|
|
301
301
|
type: rule.type,
|
|
302
302
|
parser: rule.parser
|
|
303
|
-
? getRawParserOptions(rule.parser, rule.type ??
|
|
303
|
+
? getRawParserOptions(rule.parser, rule.type ?? upperType)
|
|
304
304
|
: undefined,
|
|
305
305
|
generator: rule.generator
|
|
306
|
-
? getRawGeneratorOptions(rule.generator, rule.type ??
|
|
306
|
+
? getRawGeneratorOptions(rule.generator, rule.type ?? upperType)
|
|
307
307
|
: undefined,
|
|
308
308
|
resolve: rule.resolve ? getRawResolve(rule.resolve) : undefined,
|
|
309
309
|
oneOf: rule.oneOf
|
|
310
|
-
? rule.oneOf.map((rule, index) => getRawModuleRule(rule, `${path}.oneOf[${index}]`, options))
|
|
310
|
+
? rule.oneOf.map((rule, index) => getRawModuleRule(rule, `${path}.oneOf[${index}]`, options, rule.type ?? upperType))
|
|
311
311
|
: undefined,
|
|
312
312
|
rules: rule.rules
|
|
313
|
-
? rule.rules.map((rule, index) => getRawModuleRule(rule, `${path}.rules[${index}]`, options))
|
|
313
|
+
? rule.rules.map((rule, index) => getRawModuleRule(rule, `${path}.rules[${index}]`, options, rule.type ?? upperType))
|
|
314
314
|
: undefined,
|
|
315
315
|
enforce: rule.enforce
|
|
316
316
|
};
|
|
@@ -453,6 +453,7 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
453
453
|
dynamicImportMode: parser.dynamicImportMode ?? "lazy",
|
|
454
454
|
dynamicImportPreload: parser.dynamicImportPreload?.toString() ?? "false",
|
|
455
455
|
dynamicImportPrefetch: parser.dynamicImportPrefetch?.toString() ?? "false",
|
|
456
|
+
dynamicImportFetchPriority: parser.dynamicImportFetchPriority?.toString(),
|
|
456
457
|
url: parser.url === false
|
|
457
458
|
? "false"
|
|
458
459
|
: parser.url === "relative"
|
|
@@ -19,9 +19,6 @@ const getSwcLoaderOptions = (o, options) => {
|
|
|
19
19
|
if (expr.import || expr.pluginImport) {
|
|
20
20
|
expr.import = (0, builtin_loader_1.resolvePluginImport)(expr.import || expr.pluginImport);
|
|
21
21
|
}
|
|
22
|
-
if (expr.preact) {
|
|
23
|
-
expr.preact = (0, builtin_loader_1.resolvePreact)(expr.preact);
|
|
24
|
-
}
|
|
25
22
|
}
|
|
26
23
|
return o;
|
|
27
24
|
};
|