@rspack/core 0.5.9-canary-01da61e-20240411100442 → 0.6.0-canary-f5973db-20240409131230
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/dist/Compilation.d.ts +2 -0
- package/dist/Compilation.js +6 -1
- package/dist/Compiler.d.ts +3 -8
- package/dist/Compiler.js +31 -39
- package/dist/ExecuteModulePlugin.js +2 -2
- package/dist/Module.d.ts +1 -0
- package/dist/Module.js +1 -0
- package/dist/Stats.js +2 -2
- package/dist/builtin-plugin/{RSCClientEntryPlugin.d.ts → APIPlugin.d.ts} +1 -1
- package/dist/builtin-plugin/APIPlugin.js +6 -0
- package/dist/builtin-plugin/{RSCClientReferenceManifestRspackPlugin.d.ts → CssModulesPlugin.d.ts} +1 -1
- package/dist/builtin-plugin/CssModulesPlugin.js +6 -0
- package/dist/builtin-plugin/EntryPlugin.d.ts +1 -0
- package/dist/builtin-plugin/EntryPlugin.js +3 -2
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +3 -3
- package/dist/builtin-plugin/SplitChunksPlugin.js +2 -1
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -0
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +222 -0
- package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +2 -0
- package/dist/builtin-plugin/css-extract/hmr/normalize-url.js +38 -0
- package/dist/builtin-plugin/css-extract/index.d.ts +22 -0
- package/dist/builtin-plugin/css-extract/index.js +109 -0
- package/dist/builtin-plugin/css-extract/loader-options.json +32 -0
- package/dist/builtin-plugin/css-extract/loader.d.ts +15 -0
- package/dist/builtin-plugin/css-extract/loader.js +191 -0
- package/dist/builtin-plugin/css-extract/plugin-options.json +79 -0
- package/dist/builtin-plugin/css-extract/utils.d.ts +5 -0
- package/dist/builtin-plugin/css-extract/utils.js +51 -0
- package/dist/builtin-plugin/index.d.ts +4 -8
- package/dist/builtin-plugin/index.js +3 -17
- package/dist/config/adapter.js +57 -6
- package/dist/config/adapterRuleUse.d.ts +2 -2
- package/dist/config/defaults.js +65 -35
- package/dist/config/normalization.d.ts +1 -0
- package/dist/config/normalization.js +9 -1
- package/dist/config/zod.d.ts +774 -91
- package/dist/config/zod.js +47 -4
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/exports.d.ts +79 -26
- package/dist/exports.js +2 -4
- package/dist/lib/EntryOptionPlugin.js +1 -1
- package/dist/rspackOptionsApply.d.ts +0 -1
- package/dist/rspackOptionsApply.js +8 -20
- package/dist/util/comparators.d.ts +1 -1
- package/package.json +9 -6
- package/dist/builtin-plugin/RSCClientEntryPlugin.js +0 -6
- package/dist/builtin-plugin/RSCClientReferenceManifestRspackPlugin.js +0 -6
package/dist/Compilation.d.ts
CHANGED
|
@@ -90,6 +90,7 @@ export declare class Compilation {
|
|
|
90
90
|
ExecuteModuleContext
|
|
91
91
|
]>;
|
|
92
92
|
runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>;
|
|
93
|
+
afterSeal: liteTapable.AsyncSeriesHook<[], void>;
|
|
93
94
|
};
|
|
94
95
|
options: RspackOptionsNormalized;
|
|
95
96
|
outputOptions: OutputNormalized;
|
|
@@ -167,6 +168,7 @@ export declare class Compilation {
|
|
|
167
168
|
__internal__pushNativeDiagnostics(diagnostics: ExternalObject<any>): void;
|
|
168
169
|
get errors(): {
|
|
169
170
|
push: (...errs: (Error | JsStatsError | string)[]) => void;
|
|
171
|
+
readonly length: number;
|
|
170
172
|
[Symbol.iterator](): {
|
|
171
173
|
next(): {
|
|
172
174
|
done: boolean;
|
package/dist/Compilation.js
CHANGED
|
@@ -154,7 +154,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
154
154
|
statsPrinter: new tapable.SyncHook(["statsPrinter", "options"]),
|
|
155
155
|
buildModule: new liteTapable.SyncHook(["module"]),
|
|
156
156
|
executeModule: new liteTapable.SyncHook(["options", "context"]),
|
|
157
|
-
runtimeModule: new liteTapable.SyncHook(["module", "chunk"])
|
|
157
|
+
runtimeModule: new liteTapable.SyncHook(["module", "chunk"]),
|
|
158
|
+
afterSeal: new liteTapable.AsyncSeriesHook([])
|
|
158
159
|
};
|
|
159
160
|
this.compiler = compiler;
|
|
160
161
|
this.resolverFactory = compiler.resolverFactory;
|
|
@@ -274,6 +275,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
274
275
|
options.modulesSpace || (context.forToString ? 15 : Infinity);
|
|
275
276
|
options.ids = optionOrLocalFallback(options.ids, !context.forToString);
|
|
276
277
|
options.children = optionOrLocalFallback(options.children, !context.forToString);
|
|
278
|
+
options.orphanModules = optionOrLocalFallback(options.orphanModules, context.forToString ? false : true);
|
|
277
279
|
return options;
|
|
278
280
|
}
|
|
279
281
|
createStatsFactory(options) {
|
|
@@ -379,6 +381,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
379
381
|
}
|
|
380
382
|
}
|
|
381
383
|
},
|
|
384
|
+
get length() {
|
|
385
|
+
return inner.getStats().getErrors().length;
|
|
386
|
+
},
|
|
382
387
|
[Symbol.iterator]() {
|
|
383
388
|
// TODO: this is obviously a bad design, optimize this after finishing angular prototype
|
|
384
389
|
const errors = inner.getStats().getErrors();
|
package/dist/Compiler.d.ts
CHANGED
|
@@ -42,7 +42,6 @@ declare class Compiler {
|
|
|
42
42
|
};
|
|
43
43
|
compilation?: Compilation;
|
|
44
44
|
compilationParams?: CompilationParams;
|
|
45
|
-
first: boolean;
|
|
46
45
|
builtinPlugins: binding.BuiltinPlugin[];
|
|
47
46
|
root: Compiler;
|
|
48
47
|
running: boolean;
|
|
@@ -110,14 +109,10 @@ declare class Compiler {
|
|
|
110
109
|
getInfrastructureLogger(name: string | Function): Logger;
|
|
111
110
|
run(callback: Callback<Error, Stats>): void;
|
|
112
111
|
/**
|
|
113
|
-
*
|
|
112
|
+
* * Note: This is not a webpack public API, maybe removed in future.
|
|
113
|
+
* @internal
|
|
114
114
|
*/
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Safety: This method is only valid to call if the previous rebuild task is finished, or there will be data races.
|
|
118
|
-
* @deprecated This is a low-level incremental rebuild API, which shouldn't be used intentionally. Use `compiler.build` instead.
|
|
119
|
-
*/
|
|
120
|
-
rebuild(modifiedFiles?: ReadonlySet<string>, removedFiles?: ReadonlySet<string>, callback?: (error: Error | null) => void): void;
|
|
115
|
+
__internal__rebuild(modifiedFiles?: ReadonlySet<string>, removedFiles?: ReadonlySet<string>, callback?: (error: Error | null) => void): void;
|
|
121
116
|
compile(callback: Callback<Error, Compilation>): void;
|
|
122
117
|
watch(watchOptions: WatchOptions, handler: Callback<Error, Stats>): Watching;
|
|
123
118
|
purgeInputFileSystem(): void;
|
package/dist/Compiler.js
CHANGED
|
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
|
-
var _Compiler_instances, _Compiler_instance, _Compiler_disabledHooks, _Compiler_nonSkippableRegisters, _Compiler_registers, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateNonSkippableRegisters, _Compiler_decorateJsTaps, _Compiler_createHookRegisterTaps, _Compiler_createHookMapRegisterTaps, _Compiler_createCompilation, _Compiler_resetThisCompilation, _Compiler_newCompilationParams;
|
|
39
|
+
var _Compiler_instances, _Compiler_instance, _Compiler_initial, _Compiler_disabledHooks, _Compiler_nonSkippableRegisters, _Compiler_registers, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateNonSkippableRegisters, _Compiler_decorateJsTaps, _Compiler_createHookRegisterTaps, _Compiler_createHookMapRegisterTaps, _Compiler_build, _Compiler_createCompilation, _Compiler_resetThisCompilation, _Compiler_newCompilationParams;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.Compiler = void 0;
|
|
42
42
|
/**
|
|
@@ -69,7 +69,6 @@ const NormalModuleFactory_1 = require("./NormalModuleFactory");
|
|
|
69
69
|
const bindingVersionCheck_1 = require("./util/bindingVersionCheck");
|
|
70
70
|
const Watching_1 = require("./Watching");
|
|
71
71
|
const builtin_plugin_1 = require("./builtin-plugin");
|
|
72
|
-
const rspackOptionsApply_1 = require("./rspackOptionsApply");
|
|
73
72
|
const defaults_1 = require("./config/defaults");
|
|
74
73
|
const assertNotNil_1 = require("./util/assertNotNil");
|
|
75
74
|
const RuntimeGlobals_1 = require("./RuntimeGlobals");
|
|
@@ -84,7 +83,7 @@ class Compiler {
|
|
|
84
83
|
_Compiler_instance.set(this, void 0);
|
|
85
84
|
this.webpack = index_1.rspack;
|
|
86
85
|
// TODO: remove this after remove rebuild on the rust side.
|
|
87
|
-
this
|
|
86
|
+
_Compiler_initial.set(this, true);
|
|
88
87
|
_Compiler_disabledHooks.set(this, void 0);
|
|
89
88
|
_Compiler_nonSkippableRegisters.set(this, void 0);
|
|
90
89
|
_Compiler_registers.set(this, void 0);
|
|
@@ -386,36 +385,10 @@ class Compiler {
|
|
|
386
385
|
}
|
|
387
386
|
}
|
|
388
387
|
/**
|
|
389
|
-
*
|
|
388
|
+
* * Note: This is not a webpack public API, maybe removed in future.
|
|
389
|
+
* @internal
|
|
390
390
|
*/
|
|
391
|
-
|
|
392
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
393
|
-
if (error) {
|
|
394
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
395
|
-
}
|
|
396
|
-
if (!this.first) {
|
|
397
|
-
instance.rebuild(Array.from(this.modifiedFiles || []), Array.from(this.removedFiles || []), error => {
|
|
398
|
-
if (error) {
|
|
399
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
400
|
-
}
|
|
401
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
402
|
-
});
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
this.first = false;
|
|
406
|
-
instance.build(error => {
|
|
407
|
-
if (error) {
|
|
408
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
409
|
-
}
|
|
410
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* Safety: This method is only valid to call if the previous rebuild task is finished, or there will be data races.
|
|
416
|
-
* @deprecated This is a low-level incremental rebuild API, which shouldn't be used intentionally. Use `compiler.build` instead.
|
|
417
|
-
*/
|
|
418
|
-
rebuild(modifiedFiles, removedFiles, callback) {
|
|
391
|
+
__internal__rebuild(modifiedFiles, removedFiles, callback) {
|
|
419
392
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
420
393
|
if (error) {
|
|
421
394
|
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
@@ -437,7 +410,7 @@ class Compiler {
|
|
|
437
410
|
}
|
|
438
411
|
this.hooks.compile.call(params);
|
|
439
412
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_resetThisCompilation).call(this);
|
|
440
|
-
this.
|
|
413
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_build).call(this, err => {
|
|
441
414
|
if (err) {
|
|
442
415
|
return callback(err);
|
|
443
416
|
}
|
|
@@ -470,7 +443,7 @@ class Compiler {
|
|
|
470
443
|
}
|
|
471
444
|
close(callback) {
|
|
472
445
|
if (this.watching) {
|
|
473
|
-
// When there is still an active watching, close this
|
|
446
|
+
// When there is still an active watching, close this #initial
|
|
474
447
|
this.watching.close(() => {
|
|
475
448
|
this.close(callback);
|
|
476
449
|
});
|
|
@@ -497,7 +470,7 @@ class Compiler {
|
|
|
497
470
|
}
|
|
498
471
|
}
|
|
499
472
|
exports.Compiler = Compiler;
|
|
500
|
-
_Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Compiler_nonSkippableRegisters = new WeakMap(), _Compiler_registers = new WeakMap(), _Compiler_moduleExecutionResultsMap = new WeakMap(), _Compiler_instances = new WeakSet(), _Compiler_getInstance = function _Compiler_getInstance(callback) {
|
|
473
|
+
_Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Compiler_nonSkippableRegisters = new WeakMap(), _Compiler_registers = new WeakMap(), _Compiler_moduleExecutionResultsMap = new WeakMap(), _Compiler_instances = new WeakSet(), _Compiler_getInstance = function _Compiler_getInstance(callback) {
|
|
501
474
|
const error = (0, bindingVersionCheck_1.checkVersion)();
|
|
502
475
|
if (error) {
|
|
503
476
|
return callback(error);
|
|
@@ -506,10 +479,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
506
479
|
return callback(null, __classPrivateFieldGet(this, _Compiler_instance, "f"));
|
|
507
480
|
}
|
|
508
481
|
const options = this.options;
|
|
509
|
-
// TODO: remove this in v0.6
|
|
510
|
-
if (!options.experiments.rspackFuture.disableApplyEntryLazily) {
|
|
511
|
-
(0, rspackOptionsApply_1.applyEntryOptions)(this, options);
|
|
512
|
-
}
|
|
513
482
|
// TODO: remove this when drop support for builtins options
|
|
514
483
|
options.builtins = (0, builtin_plugin_1.deprecated_resolveBuiltins)(options.builtins, options);
|
|
515
484
|
const rawOptions = (0, config_1.getRawOptions)(options, this);
|
|
@@ -599,6 +568,7 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
599
568
|
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkAsset, () => this.compilation.hooks.chunkAsset, queried => ({ chunk, filename }) => queried.call(Chunk_1.Chunk.__from_binding(chunk, this.compilation), filename)),
|
|
600
569
|
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationProcessAssets, () => this.compilation.hooks.processAssets, queried => async () => await queried.promise(this.compilation.assets)),
|
|
601
570
|
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () => this.compilation.hooks.afterProcessAssets, queried => () => queried.call(this.compilation.assets)),
|
|
571
|
+
registerCompilationAfterSealTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterSeal, () => this.compilation.hooks.afterSeal, queried => async () => await queried.promise()),
|
|
602
572
|
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
603
573
|
const normalizedResolveData = {
|
|
604
574
|
request: resolveData.request,
|
|
@@ -751,6 +721,28 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
751
721
|
getTaps.registerKind = registerKind;
|
|
752
722
|
getTaps.getHookMap = getHookMap;
|
|
753
723
|
return getTaps;
|
|
724
|
+
}, _Compiler_build = function _Compiler_build(callback) {
|
|
725
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
726
|
+
if (error) {
|
|
727
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
728
|
+
}
|
|
729
|
+
if (!__classPrivateFieldGet(this, _Compiler_initial, "f")) {
|
|
730
|
+
instance.rebuild(Array.from(this.modifiedFiles || []), Array.from(this.removedFiles || []), error => {
|
|
731
|
+
if (error) {
|
|
732
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
733
|
+
}
|
|
734
|
+
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
735
|
+
});
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
__classPrivateFieldSet(this, _Compiler_initial, false, "f");
|
|
739
|
+
instance.build(error => {
|
|
740
|
+
if (error) {
|
|
741
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
742
|
+
}
|
|
743
|
+
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
744
|
+
});
|
|
745
|
+
});
|
|
754
746
|
}, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
|
|
755
747
|
const compilation = new Compilation_1.Compilation(this, native);
|
|
756
748
|
compilation.name = this.name;
|
|
@@ -13,10 +13,10 @@ class ExecuteModulePlugin {
|
|
|
13
13
|
const moduleObject = options.moduleObject;
|
|
14
14
|
const source = options.codeGenerationResult.get("javascript");
|
|
15
15
|
try {
|
|
16
|
-
const fn = node_vm_1.default.runInThisContext(`(function(module, __webpack_exports__, ${_1.RuntimeGlobals.require}) {\n${source}\n})`, {
|
|
16
|
+
const fn = node_vm_1.default.runInThisContext(`(function(module, __webpack_module__, __webpack_exports__, exports, ${_1.RuntimeGlobals.require}) {\n${source}\n})`, {
|
|
17
17
|
filename: moduleObject.id
|
|
18
18
|
});
|
|
19
|
-
fn.call(moduleObject.exports, moduleObject, moduleObject.exports, context.__webpack_require__);
|
|
19
|
+
fn.call(moduleObject.exports, moduleObject, moduleObject, moduleObject.exports, moduleObject.exports, context.__webpack_require__);
|
|
20
20
|
}
|
|
21
21
|
catch (e) {
|
|
22
22
|
let err = e instanceof Error ? e : new Error(e);
|
package/dist/Module.d.ts
CHANGED
package/dist/Module.js
CHANGED
|
@@ -21,6 +21,7 @@ class Module {
|
|
|
21
21
|
constructor(module) {
|
|
22
22
|
_Module_inner.set(this, void 0);
|
|
23
23
|
__classPrivateFieldSet(this, _Module_inner, module, "f");
|
|
24
|
+
this.rawRequest = module.rawRequest;
|
|
24
25
|
}
|
|
25
26
|
get context() {
|
|
26
27
|
return __classPrivateFieldGet(this, _Module_inner, "f").context;
|
package/dist/Stats.js
CHANGED
|
@@ -103,8 +103,8 @@ function normalizeStatsPreset(options) {
|
|
|
103
103
|
}
|
|
104
104
|
exports.normalizeStatsPreset = normalizeStatsPreset;
|
|
105
105
|
function presetToOptions(name) {
|
|
106
|
-
const
|
|
107
|
-
switch (
|
|
106
|
+
const preset = (typeof name === "string" && name.toLowerCase()) || name;
|
|
107
|
+
switch (preset) {
|
|
108
108
|
case "none":
|
|
109
109
|
return {
|
|
110
110
|
all: false
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.APIPlugin = void 0;
|
|
4
|
+
const binding_1 = require("@rspack/binding");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
exports.APIPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.APIPlugin, () => { });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CssModulesPlugin = void 0;
|
|
4
|
+
const binding_1 = require("@rspack/binding");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
exports.CssModulesPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.CssModulesPlugin, () => { }, "compilation");
|
|
@@ -9,6 +9,7 @@ export type EntryOptions = {
|
|
|
9
9
|
baseUri?: string;
|
|
10
10
|
filename?: FilenameTemplate;
|
|
11
11
|
library?: LibraryOptions;
|
|
12
|
+
dependOn?: string[];
|
|
12
13
|
};
|
|
13
14
|
export declare const EntryPlugin: {
|
|
14
15
|
new (context: string, entry: string, options?: string | EntryOptions | undefined): {
|
|
@@ -12,7 +12,7 @@ exports.EntryPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.EntryPlugin
|
|
|
12
12
|
entry,
|
|
13
13
|
options: getRawEntryOptions(entryOptions)
|
|
14
14
|
};
|
|
15
|
-
});
|
|
15
|
+
}, "make");
|
|
16
16
|
function getRawEntryOptions(entry) {
|
|
17
17
|
const runtime = entry.runtime;
|
|
18
18
|
const chunkLoading = entry.chunkLoading;
|
|
@@ -26,6 +26,7 @@ function getRawEntryOptions(entry) {
|
|
|
26
26
|
: undefined,
|
|
27
27
|
asyncChunks: entry.asyncChunks,
|
|
28
28
|
filename: entry.filename,
|
|
29
|
-
library: entry.library && (0, config_1.getRawLibrary)(entry.library)
|
|
29
|
+
library: entry.library && (0, config_1.getRawLibrary)(entry.library),
|
|
30
|
+
dependOn: entry.dependOn
|
|
30
31
|
};
|
|
31
32
|
}
|
|
@@ -4,7 +4,7 @@ export declare const ExternalsPlugin: {
|
|
|
4
4
|
context?: string | undefined;
|
|
5
5
|
dependencyType?: string | undefined;
|
|
6
6
|
request?: string | undefined;
|
|
7
|
-
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "promise" | "
|
|
7
|
+
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "global" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
|
|
8
8
|
context?: string | undefined;
|
|
9
9
|
dependencyType?: string | undefined;
|
|
10
10
|
request?: string | undefined;
|
|
@@ -12,7 +12,7 @@ export declare const ExternalsPlugin: {
|
|
|
12
12
|
context?: string | undefined;
|
|
13
13
|
dependencyType?: string | undefined;
|
|
14
14
|
request?: string | undefined;
|
|
15
|
-
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "promise" | "
|
|
15
|
+
}, args_1: (args_0: Error | undefined, args_1: string | boolean | string[] | Record<string, string | string[]> | undefined, args_2: "module" | "promise" | "script" | "commonjs" | "global" | "import" | "amd" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "node-commonjs" | undefined, ...args_3: unknown[]) => void, ...args_2: unknown[]) => unknown) | ((args_0: {
|
|
16
16
|
context?: string | undefined;
|
|
17
17
|
dependencyType?: string | undefined;
|
|
18
18
|
request?: string | undefined;
|
|
@@ -22,7 +22,7 @@ declare const htmlRspackPluginOptions: z.ZodObject<{
|
|
|
22
22
|
templateParameters?: Record<string, string> | undefined;
|
|
23
23
|
inject?: boolean | "head" | "body" | undefined;
|
|
24
24
|
publicPath?: string | undefined;
|
|
25
|
-
scriptLoading?: "
|
|
25
|
+
scriptLoading?: "blocking" | "defer" | "module" | undefined;
|
|
26
26
|
chunks?: string[] | undefined;
|
|
27
27
|
excludedChunks?: string[] | undefined;
|
|
28
28
|
sri?: "sha256" | "sha384" | "sha512" | undefined;
|
|
@@ -37,7 +37,7 @@ declare const htmlRspackPluginOptions: z.ZodObject<{
|
|
|
37
37
|
templateParameters?: Record<string, string> | undefined;
|
|
38
38
|
inject?: boolean | "head" | "body" | undefined;
|
|
39
39
|
publicPath?: string | undefined;
|
|
40
|
-
scriptLoading?: "
|
|
40
|
+
scriptLoading?: "blocking" | "defer" | "module" | undefined;
|
|
41
41
|
chunks?: string[] | undefined;
|
|
42
42
|
excludedChunks?: string[] | undefined;
|
|
43
43
|
sri?: "sha256" | "sha384" | "sha512" | undefined;
|
|
@@ -55,7 +55,7 @@ export declare const HtmlRspackPlugin: {
|
|
|
55
55
|
templateParameters?: Record<string, string> | undefined;
|
|
56
56
|
inject?: boolean | "head" | "body" | undefined;
|
|
57
57
|
publicPath?: string | undefined;
|
|
58
|
-
scriptLoading?: "
|
|
58
|
+
scriptLoading?: "blocking" | "defer" | "module" | undefined;
|
|
59
59
|
chunks?: string[] | undefined;
|
|
60
60
|
excludedChunks?: string[] | undefined;
|
|
61
61
|
sri?: "sha256" | "sha384" | "sha512" | undefined;
|
|
@@ -65,10 +65,11 @@ function toRawSplitChunksOptions(sc, compiler) {
|
|
|
65
65
|
return chunks;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
const { name, chunks, cacheGroups = {}, fallbackCacheGroup, ...passThrough } = sc;
|
|
68
|
+
const { name, chunks, defaultSizeTypes, cacheGroups = {}, fallbackCacheGroup, ...passThrough } = sc;
|
|
69
69
|
return {
|
|
70
70
|
name: getName(name),
|
|
71
71
|
chunks: getChunks(chunks),
|
|
72
|
+
defaultSizeTypes: defaultSizeTypes || ["javascript", "unknown"],
|
|
72
73
|
cacheGroups: Object.entries(cacheGroups)
|
|
73
74
|
.filter(([_key, group]) => group !== false)
|
|
74
75
|
.map(([key, group]) => {
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-env browser */
|
|
3
|
+
/*
|
|
4
|
+
eslint-disable
|
|
5
|
+
no-console,
|
|
6
|
+
func-names
|
|
7
|
+
*/
|
|
8
|
+
/** @typedef {any} TODO */
|
|
9
|
+
const normalizeUrl = require("./normalize-url");
|
|
10
|
+
const srcByModuleId = Object.create(null);
|
|
11
|
+
const noDocument = typeof document === "undefined";
|
|
12
|
+
const { forEach } = Array.prototype;
|
|
13
|
+
/**
|
|
14
|
+
* @param {function} fn
|
|
15
|
+
* @param {number} time
|
|
16
|
+
* @returns {(function(): void)|*}
|
|
17
|
+
*/
|
|
18
|
+
function debounce(fn, time) {
|
|
19
|
+
let timeout = 0;
|
|
20
|
+
return function () {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
const self = this;
|
|
23
|
+
// eslint-disable-next-line prefer-rest-params
|
|
24
|
+
const args = arguments;
|
|
25
|
+
const functionCall = function functionCall() {
|
|
26
|
+
return fn.apply(self, args);
|
|
27
|
+
};
|
|
28
|
+
clearTimeout(timeout);
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
timeout = setTimeout(functionCall, time);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function noop() { }
|
|
34
|
+
/**
|
|
35
|
+
* @param {TODO} moduleId
|
|
36
|
+
* @returns {TODO}
|
|
37
|
+
*/
|
|
38
|
+
function getCurrentScriptUrl(moduleId) {
|
|
39
|
+
let src = srcByModuleId[moduleId];
|
|
40
|
+
if (!src) {
|
|
41
|
+
if (document.currentScript) {
|
|
42
|
+
({ src } = /** @type {HTMLScriptElement} */ (document.currentScript));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const scripts = document.getElementsByTagName("script");
|
|
46
|
+
const lastScriptTag = scripts[scripts.length - 1];
|
|
47
|
+
if (lastScriptTag) {
|
|
48
|
+
({ src } = lastScriptTag);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
srcByModuleId[moduleId] = src;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @param {string} fileMap
|
|
55
|
+
* @returns {null | string[]}
|
|
56
|
+
*/
|
|
57
|
+
return function (fileMap) {
|
|
58
|
+
if (!src) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const splitResult = src.split(/([^\\/]+)\.js$/);
|
|
62
|
+
const filename = splitResult && splitResult[1];
|
|
63
|
+
if (!filename) {
|
|
64
|
+
return [src.replace(".js", ".css")];
|
|
65
|
+
}
|
|
66
|
+
if (!fileMap) {
|
|
67
|
+
return [src.replace(".js", ".css")];
|
|
68
|
+
}
|
|
69
|
+
return fileMap.split(",").map(mapRule => {
|
|
70
|
+
const reg = new RegExp(`${filename}\\.js$`, "g");
|
|
71
|
+
return normalizeUrl(src.replace(reg, `${mapRule.replace(/{fileName}/g, filename)}.css`));
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @param {TODO} el
|
|
77
|
+
* @param {string} [url]
|
|
78
|
+
*/
|
|
79
|
+
function updateCss(el, url) {
|
|
80
|
+
if (!url) {
|
|
81
|
+
if (!el.href) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// eslint-disable-next-line
|
|
85
|
+
url = el.href.split("?")[0];
|
|
86
|
+
}
|
|
87
|
+
if (!isUrlRequest(/** @type {string} */ (url))) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (el.isLoaded === false) {
|
|
91
|
+
// We seem to be about to replace a css link that hasn't loaded yet.
|
|
92
|
+
// We're probably changing the same file more than once.
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!url || !(url.indexOf(".css") > -1)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// eslint-disable-next-line no-param-reassign
|
|
99
|
+
el.visited = true;
|
|
100
|
+
const newEl = el.cloneNode();
|
|
101
|
+
newEl.isLoaded = false;
|
|
102
|
+
newEl.addEventListener("load", () => {
|
|
103
|
+
if (newEl.isLoaded) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
newEl.isLoaded = true;
|
|
107
|
+
el.parentNode.removeChild(el);
|
|
108
|
+
});
|
|
109
|
+
newEl.addEventListener("error", () => {
|
|
110
|
+
if (newEl.isLoaded) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
newEl.isLoaded = true;
|
|
114
|
+
el.parentNode.removeChild(el);
|
|
115
|
+
});
|
|
116
|
+
newEl.href = `${url}?${Date.now()}`;
|
|
117
|
+
if (el.nextSibling) {
|
|
118
|
+
el.parentNode.insertBefore(newEl, el.nextSibling);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
el.parentNode.appendChild(newEl);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @param {string} href
|
|
126
|
+
* @param {TODO} src
|
|
127
|
+
* @returns {TODO}
|
|
128
|
+
*/
|
|
129
|
+
function getReloadUrl(href, src) {
|
|
130
|
+
let ret;
|
|
131
|
+
// eslint-disable-next-line no-param-reassign
|
|
132
|
+
href = normalizeUrl(href);
|
|
133
|
+
src.some(
|
|
134
|
+
/**
|
|
135
|
+
* @param {string} url
|
|
136
|
+
*/
|
|
137
|
+
// eslint-disable-next-line array-callback-return
|
|
138
|
+
url => {
|
|
139
|
+
if (href.indexOf(src) > -1) {
|
|
140
|
+
ret = url;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return ret;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @param {string} [src]
|
|
147
|
+
* @returns {boolean}
|
|
148
|
+
*/
|
|
149
|
+
function reloadStyle(src) {
|
|
150
|
+
if (!src) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
const elements = document.querySelectorAll("link");
|
|
154
|
+
let loaded = false;
|
|
155
|
+
forEach.call(elements, el => {
|
|
156
|
+
if (!el.href) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const url = getReloadUrl(el.href, src);
|
|
160
|
+
if (!isUrlRequest(url)) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (el.visited === true) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (url) {
|
|
167
|
+
updateCss(el, url);
|
|
168
|
+
loaded = true;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return loaded;
|
|
172
|
+
}
|
|
173
|
+
function reloadAll() {
|
|
174
|
+
const elements = document.querySelectorAll("link");
|
|
175
|
+
forEach.call(elements, el => {
|
|
176
|
+
if (el.visited === true) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
updateCss(el);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @param {string} url
|
|
184
|
+
* @returns {boolean}
|
|
185
|
+
*/
|
|
186
|
+
function isUrlRequest(url) {
|
|
187
|
+
// An URL is not an request if
|
|
188
|
+
// It is not http or https
|
|
189
|
+
if (!/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url)) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @param {TODO} moduleId
|
|
196
|
+
* @param {TODO} options
|
|
197
|
+
* @returns {TODO}
|
|
198
|
+
*/
|
|
199
|
+
module.exports = function (moduleId, options) {
|
|
200
|
+
if (noDocument) {
|
|
201
|
+
console.log("no window.document found, will not HMR CSS");
|
|
202
|
+
return noop;
|
|
203
|
+
}
|
|
204
|
+
const getScriptSrc = getCurrentScriptUrl(moduleId);
|
|
205
|
+
function update() {
|
|
206
|
+
const src = getScriptSrc(options.filename);
|
|
207
|
+
const reloaded = reloadStyle(src);
|
|
208
|
+
if (options.locals) {
|
|
209
|
+
console.log("[HMR] Detected local css modules. Reload all css");
|
|
210
|
+
reloadAll();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (reloaded) {
|
|
214
|
+
console.log("[HMR] css reload %s", src.join(" "));
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
console.log("[HMR] Reload all css");
|
|
218
|
+
reloadAll();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return debounce(update, 50);
|
|
222
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* @param {string[]} pathComponents
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
function normalizeUrl(pathComponents) {
|
|
8
|
+
return pathComponents
|
|
9
|
+
.reduce(function (accumulator, item) {
|
|
10
|
+
switch (item) {
|
|
11
|
+
case "..":
|
|
12
|
+
accumulator.pop();
|
|
13
|
+
break;
|
|
14
|
+
case ".":
|
|
15
|
+
break;
|
|
16
|
+
default:
|
|
17
|
+
accumulator.push(item);
|
|
18
|
+
}
|
|
19
|
+
return accumulator;
|
|
20
|
+
}, /** @type {string[]} */ ([]))
|
|
21
|
+
.join("/");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} urlString
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
module.exports = function (urlString) {
|
|
28
|
+
urlString = urlString.trim();
|
|
29
|
+
if (/^data:/i.test(urlString)) {
|
|
30
|
+
return urlString;
|
|
31
|
+
}
|
|
32
|
+
var protocol = urlString.indexOf("//") !== -1 ? urlString.split("//")[0] + "//" : "";
|
|
33
|
+
var components = urlString.replace(new RegExp(protocol, "i"), "").split("/");
|
|
34
|
+
var host = components[0].toLowerCase().replace(/\.$/, "");
|
|
35
|
+
components[0] = "";
|
|
36
|
+
var path = normalizeUrl(components);
|
|
37
|
+
return protocol + host + path;
|
|
38
|
+
};
|