@rspack/core 0.5.9-canary-48aa3b9-20240401005625 → 0.5.9-canary-c269a3b-20240401072545
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/Compiler.d.ts +8 -3
- package/dist/Compiler.js +119 -105
- package/dist/Module.d.ts +2 -1
- package/dist/NormalModuleFactory.d.ts +6 -6
- package/dist/NormalModuleFactory.js +3 -5
- package/dist/exports.d.ts +1 -2
- package/dist/exports.js +1 -5
- package/dist/lite-tapable/index.d.ts +0 -25
- package/dist/lite-tapable/index.js +1 -70
- package/package.json +5 -5
- package/dist/lib/NormalModuleReplacementPlugin.d.ts +0 -19
- package/dist/lib/NormalModuleReplacementPlugin.js +0 -75
package/dist/Compiler.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ declare class Compiler {
|
|
|
42
42
|
};
|
|
43
43
|
compilation?: Compilation;
|
|
44
44
|
compilationParams?: CompilationParams;
|
|
45
|
+
first: boolean;
|
|
45
46
|
builtinPlugins: binding.BuiltinPlugin[];
|
|
46
47
|
root: Compiler;
|
|
47
48
|
running: boolean;
|
|
@@ -109,10 +110,14 @@ declare class Compiler {
|
|
|
109
110
|
getInfrastructureLogger(name: string | Function): Logger;
|
|
110
111
|
run(callback: Callback<Error, Stats>): void;
|
|
111
112
|
/**
|
|
112
|
-
*
|
|
113
|
-
* @internal
|
|
113
|
+
* Safety: This method is only valid to call if the previous rebuild task is finished, or there will be data races.
|
|
114
114
|
*/
|
|
115
|
-
|
|
115
|
+
build(callback?: (error: Error | null) => void): void;
|
|
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;
|
|
116
121
|
compile(callback: Callback<Error, Compilation>): void;
|
|
117
122
|
watch(watchOptions: WatchOptions, handler: Callback<Error, Stats>): Watching;
|
|
118
123
|
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,
|
|
39
|
+
var _Compiler_instances, _Compiler_instance, _Compiler_disabledHooks, _Compiler_nonSkippableRegisters, _Compiler_registers, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateNonSkippableRegisters, _Compiler_updateDisabledHooks, _Compiler_contextModuleFactoryAfterResolve, _Compiler_normalModuleFactoryCreateModule, _Compiler_normalModuleFactoryResolveForScheme, _Compiler_decorateUpdateDisabledHooks, _Compiler_createRegisterTaps, _Compiler_createCompilation, _Compiler_resetThisCompilation, _Compiler_newCompilationParams;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.Compiler = void 0;
|
|
42
42
|
/**
|
|
@@ -84,7 +84,7 @@ class Compiler {
|
|
|
84
84
|
_Compiler_instance.set(this, void 0);
|
|
85
85
|
this.webpack = index_1.rspack;
|
|
86
86
|
// TODO: remove this after remove rebuild on the rust side.
|
|
87
|
-
|
|
87
|
+
this.first = true;
|
|
88
88
|
_Compiler_disabledHooks.set(this, void 0);
|
|
89
89
|
_Compiler_nonSkippableRegisters.set(this, void 0);
|
|
90
90
|
_Compiler_registers.set(this, void 0);
|
|
@@ -386,10 +386,36 @@ class Compiler {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
389
|
-
*
|
|
390
|
-
* @internal
|
|
389
|
+
* Safety: This method is only valid to call if the previous rebuild task is finished, or there will be data races.
|
|
391
390
|
*/
|
|
392
|
-
|
|
391
|
+
build(callback) {
|
|
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) {
|
|
393
419
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
394
420
|
if (error) {
|
|
395
421
|
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
@@ -411,7 +437,7 @@ class Compiler {
|
|
|
411
437
|
}
|
|
412
438
|
this.hooks.compile.call(params);
|
|
413
439
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_resetThisCompilation).call(this);
|
|
414
|
-
|
|
440
|
+
this.build(err => {
|
|
415
441
|
if (err) {
|
|
416
442
|
return callback(err);
|
|
417
443
|
}
|
|
@@ -444,7 +470,7 @@ class Compiler {
|
|
|
444
470
|
}
|
|
445
471
|
close(callback) {
|
|
446
472
|
if (this.watching) {
|
|
447
|
-
// When there is still an active watching, close this
|
|
473
|
+
// When there is still an active watching, close this first
|
|
448
474
|
this.watching.close(() => {
|
|
449
475
|
this.close(callback);
|
|
450
476
|
});
|
|
@@ -471,7 +497,7 @@ class Compiler {
|
|
|
471
497
|
}
|
|
472
498
|
}
|
|
473
499
|
exports.Compiler = Compiler;
|
|
474
|
-
_Compiler_instance = new WeakMap(),
|
|
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) {
|
|
475
501
|
const error = (0, bindingVersionCheck_1.checkVersion)();
|
|
476
502
|
if (error) {
|
|
477
503
|
return callback(error);
|
|
@@ -489,19 +515,19 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
489
515
|
const rawOptions = (0, config_1.getRawOptions)(options, this);
|
|
490
516
|
const instanceBinding = require("@rspack/binding");
|
|
491
517
|
__classPrivateFieldSet(this, _Compiler_registers, {
|
|
492
|
-
registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
518
|
+
registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerThisCompilation, () => this.hooks.thisCompilation, queried => (native) => {
|
|
493
519
|
if (this.compilation === undefined) {
|
|
494
520
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createCompilation).call(this, native);
|
|
495
521
|
}
|
|
496
522
|
queried.call(this.compilation, this.compilationParams);
|
|
497
523
|
}),
|
|
498
|
-
registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
499
|
-
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
500
|
-
registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
501
|
-
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
502
|
-
registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
503
|
-
registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
504
|
-
registerCompilerAssetEmittedTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
524
|
+
registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerCompilation, () => this.hooks.compilation, queried => () => queried.call(this.compilation, this.compilationParams)),
|
|
525
|
+
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerMake, () => this.hooks.make, queried => async () => await queried.promise(this.compilation)),
|
|
526
|
+
registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerFinishMake, () => this.hooks.finishMake, queried => async () => await queried.promise(this.compilation)),
|
|
527
|
+
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerShouldEmit, () => this.hooks.shouldEmit, queried => () => queried.call(this.compilation)),
|
|
528
|
+
registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerEmit, () => this.hooks.emit, queried => async () => await queried.promise(this.compilation)),
|
|
529
|
+
registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAfterEmit, () => this.hooks.afterEmit, queried => async () => await queried.promise(this.compilation)),
|
|
530
|
+
registerCompilerAssetEmittedTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAssetEmitted, () => this.hooks.assetEmitted, queried => async ({ filename, targetPath, outputPath }) => await queried.promise(filename, {
|
|
505
531
|
compilation: this.compilation,
|
|
506
532
|
targetPath,
|
|
507
533
|
outputPath,
|
|
@@ -514,7 +540,7 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
514
540
|
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.buffer();
|
|
515
541
|
}
|
|
516
542
|
})),
|
|
517
|
-
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
543
|
+
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeModule, () => this.compilation.hooks.runtimeModule, queried => ({ module, chunk }) => {
|
|
518
544
|
var _a, _b;
|
|
519
545
|
const originSource = (_a = module.source) === null || _a === void 0 ? void 0 : _a.source;
|
|
520
546
|
queried.call(module, Chunk_1.Chunk.__from_binding(chunk, this.compilation));
|
|
@@ -524,10 +550,10 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
524
550
|
}
|
|
525
551
|
return;
|
|
526
552
|
}),
|
|
527
|
-
registerCompilationBuildModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
528
|
-
registerCompilationStillValidModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
529
|
-
registerCompilationSucceedModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
530
|
-
registerCompilationExecuteModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
553
|
+
registerCompilationBuildModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationBuildModule, () => this.compilation.hooks.buildModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
554
|
+
registerCompilationStillValidModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationStillValidModule, () => this.compilation.hooks.stillValidModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
555
|
+
registerCompilationSucceedModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationSucceedModule, () => this.compilation.hooks.succeedModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
556
|
+
registerCompilationExecuteModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationExecuteModule, () => this.compilation.hooks.executeModule, queried => ({ entry, id, codegenResults, runtimeModules }) => {
|
|
531
557
|
const __webpack_require__ = (id) => {
|
|
532
558
|
const cached = moduleCache[id];
|
|
533
559
|
if (cached !== undefined) {
|
|
@@ -565,15 +591,15 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
565
591
|
const executeResult = __webpack_require__(entry);
|
|
566
592
|
__classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").set(id, executeResult);
|
|
567
593
|
}),
|
|
568
|
-
registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
569
|
-
registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
570
|
-
registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
571
|
-
registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
572
|
-
registerCompilationOptimizeChunkModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
573
|
-
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
574
|
-
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
575
|
-
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
576
|
-
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
594
|
+
registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationFinishModules, () => this.compilation.hooks.finishModules, queried => async () => await queried.promise(this.compilation.modules)),
|
|
595
|
+
registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeModules, () => this.compilation.hooks.optimizeModules, queried => () => queried.call(this.compilation.modules)),
|
|
596
|
+
registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterOptimizeModules, () => this.compilation.hooks.afterOptimizeModules, queried => () => queried.call(this.compilation.modules)),
|
|
597
|
+
registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeTree, () => this.compilation.hooks.optimizeTree, queried => async () => await queried.promise(this.compilation.chunks, this.compilation.modules)),
|
|
598
|
+
registerCompilationOptimizeChunkModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeChunkModules, () => this.compilation.hooks.optimizeChunkModules, queried => async () => await queried.promise(this.compilation.chunks, this.compilation.modules)),
|
|
599
|
+
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkAsset, () => this.compilation.hooks.chunkAsset, queried => ({ chunk, filename }) => queried.call(Chunk_1.Chunk.__from_binding(chunk, this.compilation), filename)),
|
|
600
|
+
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationProcessAssets, () => this.compilation.hooks.processAssets, queried => async () => await queried.promise(this.compilation.assets)),
|
|
601
|
+
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () => this.compilation.hooks.afterProcessAssets, queried => () => queried.call(this.compilation.assets)),
|
|
602
|
+
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
577
603
|
const normalizedResolveData = {
|
|
578
604
|
request: resolveData.request,
|
|
579
605
|
context: resolveData.context,
|
|
@@ -586,32 +612,20 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
586
612
|
resolveData.context = normalizedResolveData.context;
|
|
587
613
|
return [ret, resolveData];
|
|
588
614
|
}),
|
|
589
|
-
|
|
590
|
-
const ret = await queried
|
|
591
|
-
.for(args.scheme)
|
|
592
|
-
.promise(args.resourceData);
|
|
593
|
-
return [ret, args.resourceData];
|
|
594
|
-
}),
|
|
595
|
-
registerNormalModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryAfterResolve, () => this.compilationParams.normalModuleFactory.hooks.afterResolve, queried => async (arg) => {
|
|
615
|
+
registerNormalModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryAfterResolve, () => this.compilationParams.normalModuleFactory.hooks.afterResolve, queried => async (arg) => {
|
|
596
616
|
const data = {
|
|
597
617
|
request: arg.request,
|
|
598
618
|
context: arg.context,
|
|
599
619
|
fileDependencies: arg.fileDependencies,
|
|
600
620
|
missingDependencies: arg.missingDependencies,
|
|
601
621
|
contextDependencies: arg.contextDependencies,
|
|
622
|
+
factoryMeta: arg.factoryMeta,
|
|
602
623
|
createData: arg.createData
|
|
603
624
|
};
|
|
604
625
|
const ret = await queried.promise(data);
|
|
605
626
|
return [ret, data.createData];
|
|
606
627
|
}),
|
|
607
|
-
|
|
608
|
-
const data = {
|
|
609
|
-
...args,
|
|
610
|
-
settings: {}
|
|
611
|
-
};
|
|
612
|
-
await queried.promise(data, {});
|
|
613
|
-
}),
|
|
614
|
-
registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => this.compilationParams.contextModuleFactory.hooks.beforeResolve, queried => async (arg) => {
|
|
628
|
+
registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => this.compilationParams.contextModuleFactory.hooks.beforeResolve, queried => async (arg) => {
|
|
615
629
|
const data = {
|
|
616
630
|
request: arg.request,
|
|
617
631
|
context: arg.context,
|
|
@@ -622,26 +636,29 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
622
636
|
const ret = await queried.promise(data);
|
|
623
637
|
return [ret, data];
|
|
624
638
|
}),
|
|
625
|
-
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
639
|
+
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryAfterResolve, () => this.compilationParams.contextModuleFactory.hooks.afterResolve, queried => async (arg) => {
|
|
626
640
|
const data = {
|
|
627
641
|
request: arg.request,
|
|
628
642
|
context: arg.context,
|
|
629
643
|
fileDependencies: arg.fileDependencies,
|
|
630
644
|
missingDependencies: arg.missingDependencies,
|
|
631
645
|
contextDependencies: arg.contextDependencies,
|
|
646
|
+
factoryMeta: arg.factoryMeta,
|
|
632
647
|
createData: arg.createData
|
|
633
648
|
};
|
|
634
649
|
return await queried.promise(data);
|
|
635
650
|
})
|
|
636
651
|
}, "f");
|
|
637
|
-
__classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins,
|
|
652
|
+
__classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins, {
|
|
653
|
+
normalModuleFactoryCreateModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryCreateModule).bind(this),
|
|
654
|
+
normalModuleFactoryResolveForScheme: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryResolveForScheme).bind(this)
|
|
655
|
+
}, __classPrivateFieldGet(this, _Compiler_registers, "f"), (0, fileSystem_1.createThreadsafeNodeFSFromRaw)(this.outputFileSystem)), "f");
|
|
638
656
|
callback(null, __classPrivateFieldGet(this, _Compiler_instance, "f"));
|
|
639
657
|
}, _Compiler_updateNonSkippableRegisters = function _Compiler_updateNonSkippableRegisters() {
|
|
640
658
|
const kinds = [];
|
|
641
|
-
for (const { getHook,
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
if (hookOrMap.isUsed()) {
|
|
659
|
+
for (const { getHook, registerKind } of Object.values(__classPrivateFieldGet(this, _Compiler_registers, "f"))) {
|
|
660
|
+
const hook = getHook();
|
|
661
|
+
if (hook.isUsed()) {
|
|
645
662
|
kinds.push(registerKind);
|
|
646
663
|
}
|
|
647
664
|
}
|
|
@@ -651,7 +668,53 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
651
668
|
__classPrivateFieldSet(this, _Compiler_nonSkippableRegisters, kinds, "f");
|
|
652
669
|
});
|
|
653
670
|
}
|
|
654
|
-
},
|
|
671
|
+
}, _Compiler_updateDisabledHooks = function _Compiler_updateDisabledHooks(callback) {
|
|
672
|
+
var _a, _b;
|
|
673
|
+
const disabledHooks = [];
|
|
674
|
+
const hookMap = {
|
|
675
|
+
normalModuleFactoryCreateModule: (_a = this.compilationParams) === null || _a === void 0 ? void 0 : _a.normalModuleFactory.hooks.createModule,
|
|
676
|
+
normalModuleFactoryResolveForScheme: (_b = this.compilationParams) === null || _b === void 0 ? void 0 : _b.normalModuleFactory.hooks.resolveForScheme
|
|
677
|
+
};
|
|
678
|
+
for (const [name, hook] of Object.entries(hookMap)) {
|
|
679
|
+
if (typeof hook !== "undefined" &&
|
|
680
|
+
(hook.taps
|
|
681
|
+
? !hook.isUsed()
|
|
682
|
+
: hook._map
|
|
683
|
+
? /* hook map */ hook._map.size === 0
|
|
684
|
+
: false)) {
|
|
685
|
+
disabledHooks.push(name);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
// disabledHooks is in order
|
|
689
|
+
if (__classPrivateFieldGet(this, _Compiler_disabledHooks, "f").join() !== disabledHooks.join()) {
|
|
690
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
691
|
+
if (error) {
|
|
692
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
693
|
+
}
|
|
694
|
+
instance.setDisabledHooks(disabledHooks);
|
|
695
|
+
__classPrivateFieldSet(this, _Compiler_disabledHooks, disabledHooks, "f");
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
}, _Compiler_contextModuleFactoryAfterResolve = async function _Compiler_contextModuleFactoryAfterResolve(resourceData) {
|
|
699
|
+
let res = await this.compilationParams.contextModuleFactory.hooks.afterResolve.promise(resourceData);
|
|
700
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
701
|
+
return res;
|
|
702
|
+
}, _Compiler_normalModuleFactoryCreateModule = async function _Compiler_normalModuleFactoryCreateModule(createData) {
|
|
703
|
+
const data = Object.assign({}, createData, {
|
|
704
|
+
settings: {},
|
|
705
|
+
matchResource: createData.resourceResolveData.resource
|
|
706
|
+
});
|
|
707
|
+
const nmfHooks = this.compilationParams.normalModuleFactory.hooks;
|
|
708
|
+
await (nmfHooks === null || nmfHooks === void 0 ? void 0 : nmfHooks.createModule.promise(data, {}));
|
|
709
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
710
|
+
}, _Compiler_normalModuleFactoryResolveForScheme = async function _Compiler_normalModuleFactoryResolveForScheme(input) {
|
|
711
|
+
let stop = await this.compilationParams.normalModuleFactory.hooks.resolveForScheme.for(input.scheme).promise(input.resourceData);
|
|
712
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
713
|
+
return {
|
|
714
|
+
resourceData: input.resourceData,
|
|
715
|
+
stop: stop === true
|
|
716
|
+
};
|
|
717
|
+
}, _Compiler_decorateUpdateDisabledHooks = function _Compiler_decorateUpdateDisabledHooks(jsTaps) {
|
|
655
718
|
if (jsTaps.length > 0) {
|
|
656
719
|
const last = jsTaps[jsTaps.length - 1];
|
|
657
720
|
const old = last.function;
|
|
@@ -659,15 +722,17 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
659
722
|
const result = old(...args);
|
|
660
723
|
if (result && typeof result.then === "function") {
|
|
661
724
|
return result.then((r) => {
|
|
725
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
662
726
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateNonSkippableRegisters).call(this);
|
|
663
727
|
return r;
|
|
664
728
|
});
|
|
665
729
|
}
|
|
730
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
666
731
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateNonSkippableRegisters).call(this);
|
|
667
732
|
return result;
|
|
668
733
|
};
|
|
669
734
|
}
|
|
670
|
-
},
|
|
735
|
+
}, _Compiler_createRegisterTaps = function _Compiler_createRegisterTaps(registerKind, getHook, createTap) {
|
|
671
736
|
const getTaps = (stages) => {
|
|
672
737
|
const hook = getHook();
|
|
673
738
|
if (!hook.isUsed())
|
|
@@ -690,63 +755,12 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
690
755
|
stage: liteTapable.safeStage(from + 1)
|
|
691
756
|
});
|
|
692
757
|
}
|
|
693
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
758
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_decorateUpdateDisabledHooks).call(this, jsTaps);
|
|
694
759
|
return jsTaps;
|
|
695
760
|
};
|
|
696
761
|
getTaps.registerKind = registerKind;
|
|
697
762
|
getTaps.getHook = getHook;
|
|
698
763
|
return getTaps;
|
|
699
|
-
}, _Compiler_createHookMapRegisterTaps = function _Compiler_createHookMapRegisterTaps(registerKind, getHookMap, createTap) {
|
|
700
|
-
const getTaps = (stages) => {
|
|
701
|
-
const map = getHookMap();
|
|
702
|
-
if (!map.isUsed())
|
|
703
|
-
return [];
|
|
704
|
-
const breakpoints = [
|
|
705
|
-
liteTapable.minStage,
|
|
706
|
-
...stages,
|
|
707
|
-
liteTapable.maxStage
|
|
708
|
-
];
|
|
709
|
-
const jsTaps = [];
|
|
710
|
-
for (let i = 0; i < breakpoints.length - 1; i++) {
|
|
711
|
-
const from = breakpoints[i];
|
|
712
|
-
const to = breakpoints[i + 1];
|
|
713
|
-
const stageRange = [from, to];
|
|
714
|
-
const queried = map.queryStageRange(stageRange);
|
|
715
|
-
if (!queried.isUsed())
|
|
716
|
-
continue;
|
|
717
|
-
jsTaps.push({
|
|
718
|
-
function: createTap(queried),
|
|
719
|
-
stage: liteTapable.safeStage(from + 1)
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_decorateJsTaps).call(this, jsTaps);
|
|
723
|
-
return jsTaps;
|
|
724
|
-
};
|
|
725
|
-
getTaps.registerKind = registerKind;
|
|
726
|
-
getTaps.getHookMap = getHookMap;
|
|
727
|
-
return getTaps;
|
|
728
|
-
}, _Compiler_build = function _Compiler_build(callback) {
|
|
729
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
730
|
-
if (error) {
|
|
731
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
732
|
-
}
|
|
733
|
-
if (!__classPrivateFieldGet(this, _Compiler_initial, "f")) {
|
|
734
|
-
instance.rebuild(Array.from(this.modifiedFiles || []), Array.from(this.removedFiles || []), error => {
|
|
735
|
-
if (error) {
|
|
736
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
737
|
-
}
|
|
738
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
739
|
-
});
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
__classPrivateFieldSet(this, _Compiler_initial, false, "f");
|
|
743
|
-
instance.build(error => {
|
|
744
|
-
if (error) {
|
|
745
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
746
|
-
}
|
|
747
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
748
|
-
});
|
|
749
|
-
});
|
|
750
764
|
}, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
|
|
751
765
|
const compilation = new Compilation_1.Compilation(this, native);
|
|
752
766
|
compilation.name = this.name;
|
package/dist/Module.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsCodegenerationResult, JsCodegenerationResults, JsCreateData, JsModule } from "@rspack/binding";
|
|
1
|
+
import { JsCodegenerationResult, JsCodegenerationResults, JsCreateData, JsFactoryMeta, JsModule } from "@rspack/binding";
|
|
2
2
|
import { Source } from "webpack-sources";
|
|
3
3
|
export type ResourceData = {
|
|
4
4
|
resource: string;
|
|
@@ -16,6 +16,7 @@ export type ResolveData = {
|
|
|
16
16
|
fileDependencies: string[];
|
|
17
17
|
missingDependencies: string[];
|
|
18
18
|
contextDependencies: string[];
|
|
19
|
+
factoryMeta?: JsFactoryMeta;
|
|
19
20
|
createData?: CreateData;
|
|
20
21
|
};
|
|
21
22
|
export declare class Module {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import { AsyncSeriesBailHook, HookMap } from "tapable";
|
|
1
2
|
import * as liteTapable from "./lite-tapable";
|
|
2
3
|
import type * as binding from "@rspack/binding";
|
|
3
4
|
import { ResolveData, ResourceDataWithData } from "./Module";
|
|
4
|
-
|
|
5
|
+
type CreateModuleData = binding.CreateModuleData & {
|
|
5
6
|
settings: {};
|
|
7
|
+
matchResource: string;
|
|
6
8
|
};
|
|
7
9
|
export declare class NormalModuleFactory {
|
|
8
10
|
hooks: {
|
|
9
|
-
resolveForScheme:
|
|
11
|
+
resolveForScheme: HookMap<AsyncSeriesBailHook<[ResourceDataWithData], true | void>>;
|
|
10
12
|
beforeResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>;
|
|
11
13
|
afterResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>;
|
|
12
|
-
createModule:
|
|
13
|
-
NormalModuleCreateData,
|
|
14
|
-
{}
|
|
15
|
-
], void>;
|
|
14
|
+
createModule: AsyncSeriesBailHook<[CreateModuleData, {}], void>;
|
|
16
15
|
};
|
|
17
16
|
constructor();
|
|
18
17
|
}
|
|
18
|
+
export {};
|
|
@@ -24,6 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.NormalModuleFactory = void 0;
|
|
27
|
+
const tapable_1 = require("tapable");
|
|
27
28
|
const liteTapable = __importStar(require("./lite-tapable"));
|
|
28
29
|
class NormalModuleFactory {
|
|
29
30
|
constructor() {
|
|
@@ -31,7 +32,7 @@ class NormalModuleFactory {
|
|
|
31
32
|
// /** @type {AsyncSeriesBailHook<[ResolveData], Module | false | void>} */
|
|
32
33
|
// resolve: new AsyncSeriesBailHook(["resolveData"]),
|
|
33
34
|
// /** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>>} */
|
|
34
|
-
resolveForScheme: new
|
|
35
|
+
resolveForScheme: new tapable_1.HookMap(() => new tapable_1.AsyncSeriesBailHook(["resourceData"])),
|
|
35
36
|
// /** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>>} */
|
|
36
37
|
// resolveInScheme: new HookMap(
|
|
37
38
|
// () => new AsyncSeriesBailHook(["resourceData", "resolveData"])
|
|
@@ -43,10 +44,7 @@ class NormalModuleFactory {
|
|
|
43
44
|
// /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
|
|
44
45
|
afterResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
|
|
45
46
|
// /** @type {AsyncSeriesBailHook<[ResolveData["createData"], ResolveData], Module | void>} */
|
|
46
|
-
createModule: new
|
|
47
|
-
"createData",
|
|
48
|
-
"resolveData"
|
|
49
|
-
])
|
|
47
|
+
createModule: new tapable_1.AsyncSeriesBailHook(["createData", "resolveData"])
|
|
50
48
|
// /** @type {SyncWaterfallHook<[Module, ResolveData["createData"], ResolveData], Module>} */
|
|
51
49
|
// module: new SyncWaterfallHook(["module", "createData", "resolveData"]),
|
|
52
50
|
// createParser: new HookMap(() => new SyncBailHook(["parserOptions"])),
|
package/dist/exports.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { RspackOptionsApply, RspackOptionsApply as WebpackOptionsApply };
|
|
|
11
11
|
export { RuntimeGlobals } from "./RuntimeGlobals";
|
|
12
12
|
export { Stats } from "./Stats";
|
|
13
13
|
export type { StatsCompilation, StatsAsset, StatsChunk, StatsError, StatsModule, StatsWarnings } from "./Stats";
|
|
14
|
-
export { MultiStats } from "./MultiStats";
|
|
14
|
+
export type { MultiStats } from "./MultiStats";
|
|
15
15
|
export type { ChunkGroup } from "./ChunkGroup";
|
|
16
16
|
export type { NormalModuleFactory } from "./NormalModuleFactory";
|
|
17
17
|
export { NormalModule } from "./NormalModule";
|
|
@@ -765,7 +765,6 @@ export { HotModuleReplacementPlugin } from "./builtin-plugin";
|
|
|
765
765
|
export { LoaderOptionsPlugin } from "./lib/LoaderOptionsPlugin";
|
|
766
766
|
export { LoaderTargetPlugin } from "./lib/LoaderTargetPlugin";
|
|
767
767
|
export { EnvironmentPlugin } from "./lib/EnvironmentPlugin";
|
|
768
|
-
export { NormalModuleReplacementPlugin } from "./lib/NormalModuleReplacementPlugin";
|
|
769
768
|
import NodeTemplatePlugin from "./node/NodeTemplatePlugin";
|
|
770
769
|
export declare const node: {
|
|
771
770
|
NodeTargetPlugin: {
|
package/dist/exports.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EvalDevToolModulePlugin = exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.SwcCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.
|
|
6
|
+
exports.EvalDevToolModulePlugin = exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.SwcCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.EnvironmentPlugin = exports.LoaderTargetPlugin = exports.LoaderOptionsPlugin = exports.HotModuleReplacementPlugin = exports.ExternalsPlugin = exports.EntryPlugin = exports.ProgressPlugin = exports.DefinePlugin = exports.ProvidePlugin = exports.BannerPlugin = exports.EntryOptionPlugin = exports.experimental_cleanupGlobalTrace = exports.experimental_registerGlobalTrace = exports.util = exports.config = exports.sources = exports.WebpackError = exports.Template = exports.ModuleFilenameHelpers = exports.NormalModule = exports.Stats = exports.RuntimeGlobals = exports.WebpackOptionsApply = exports.RspackOptionsApply = exports.MultiCompiler = exports.Compilation = exports.Compiler = exports.rspackVersion = exports.version = void 0;
|
|
7
7
|
const { version: rspackVersion, webpackVersion } = require("../package.json");
|
|
8
8
|
exports.rspackVersion = rspackVersion;
|
|
9
9
|
exports.version = webpackVersion;
|
|
@@ -20,8 +20,6 @@ var RuntimeGlobals_1 = require("./RuntimeGlobals");
|
|
|
20
20
|
Object.defineProperty(exports, "RuntimeGlobals", { enumerable: true, get: function () { return RuntimeGlobals_1.RuntimeGlobals; } });
|
|
21
21
|
var Stats_1 = require("./Stats");
|
|
22
22
|
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return Stats_1.Stats; } });
|
|
23
|
-
var MultiStats_1 = require("./MultiStats");
|
|
24
|
-
Object.defineProperty(exports, "MultiStats", { enumerable: true, get: function () { return MultiStats_1.MultiStats; } });
|
|
25
23
|
var NormalModule_1 = require("./NormalModule");
|
|
26
24
|
Object.defineProperty(exports, "NormalModule", { enumerable: true, get: function () { return NormalModule_1.NormalModule; } });
|
|
27
25
|
var ModuleFilenameHelpers_1 = require("./lib/ModuleFilenameHelpers");
|
|
@@ -67,8 +65,6 @@ var LoaderTargetPlugin_1 = require("./lib/LoaderTargetPlugin");
|
|
|
67
65
|
Object.defineProperty(exports, "LoaderTargetPlugin", { enumerable: true, get: function () { return LoaderTargetPlugin_1.LoaderTargetPlugin; } });
|
|
68
66
|
var EnvironmentPlugin_1 = require("./lib/EnvironmentPlugin");
|
|
69
67
|
Object.defineProperty(exports, "EnvironmentPlugin", { enumerable: true, get: function () { return EnvironmentPlugin_1.EnvironmentPlugin; } });
|
|
70
|
-
var NormalModuleReplacementPlugin_1 = require("./lib/NormalModuleReplacementPlugin");
|
|
71
|
-
Object.defineProperty(exports, "NormalModuleReplacementPlugin", { enumerable: true, get: function () { return NormalModuleReplacementPlugin_1.NormalModuleReplacementPlugin; } });
|
|
72
68
|
const NodeTemplatePlugin_1 = __importDefault(require("./node/NodeTemplatePlugin"));
|
|
73
69
|
const builtin_plugin_8 = require("./builtin-plugin");
|
|
74
70
|
exports.node = { NodeTargetPlugin: builtin_plugin_8.NodeTargetPlugin, NodeTemplatePlugin: NodeTemplatePlugin_1.default };
|
|
@@ -112,29 +112,4 @@ export declare class AsyncSeriesBailHook<T, R, AdditionalOptions = UnsetAddition
|
|
|
112
112
|
tapAsync(options: Options<AdditionalOptions>, fn: FnWithCallback<T, void>): void;
|
|
113
113
|
tapPromise(options: Options<AdditionalOptions>, fn: Fn<T, void>): void;
|
|
114
114
|
}
|
|
115
|
-
export type HookMapKey = any;
|
|
116
|
-
export type HookFactory<H> = (key: HookMapKey, hook?: H) => H;
|
|
117
|
-
export interface HookMapInterceptor<H> {
|
|
118
|
-
factory?: HookFactory<H>;
|
|
119
|
-
}
|
|
120
|
-
export declare class HookMap<H extends Hook<any, any, any>> {
|
|
121
|
-
_map: Map<HookMapKey, H>;
|
|
122
|
-
_factory: HookFactory<H>;
|
|
123
|
-
name?: string;
|
|
124
|
-
_interceptors: HookMapInterceptor<H>[];
|
|
125
|
-
constructor(factory: HookFactory<H>, name?: string);
|
|
126
|
-
get(key: HookMapKey): H | undefined;
|
|
127
|
-
for(key: HookMapKey): H;
|
|
128
|
-
intercept(interceptor: HookMapInterceptor<H>): void;
|
|
129
|
-
isUsed(): boolean;
|
|
130
|
-
queryStageRange(stageRange: StageRange): QueriedHookMap<H>;
|
|
131
|
-
}
|
|
132
|
-
export declare class QueriedHookMap<H extends Hook<any, any, any>> {
|
|
133
|
-
stageRange: StageRange;
|
|
134
|
-
hookMap: HookMap<H>;
|
|
135
|
-
constructor(stageRange: StageRange, hookMap: HookMap<H>);
|
|
136
|
-
get(key: HookMapKey): QueriedHook<any, any, any> | undefined;
|
|
137
|
-
for(key: HookMapKey): QueriedHook<any, any, any>;
|
|
138
|
-
isUsed(): boolean;
|
|
139
|
-
}
|
|
140
115
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AsyncSeriesBailHook = exports.AsyncSeriesHook = exports.AsyncParallelHook = exports.SyncBailHook = exports.SyncHook = exports.QueriedHook = exports.safeStage = exports.maxStage = exports.minStage = exports.Hook = void 0;
|
|
4
4
|
class Hook {
|
|
5
5
|
constructor(args, name) {
|
|
6
6
|
this.args = args;
|
|
@@ -578,72 +578,3 @@ class AsyncSeriesBailHook extends Hook {
|
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
exports.AsyncSeriesBailHook = AsyncSeriesBailHook;
|
|
581
|
-
const defaultFactory = (key, hook) => hook;
|
|
582
|
-
class HookMap {
|
|
583
|
-
constructor(factory, name) {
|
|
584
|
-
this._map = new Map();
|
|
585
|
-
this.name = name;
|
|
586
|
-
this._factory = factory;
|
|
587
|
-
this._interceptors = [];
|
|
588
|
-
}
|
|
589
|
-
get(key) {
|
|
590
|
-
return this._map.get(key);
|
|
591
|
-
}
|
|
592
|
-
for(key) {
|
|
593
|
-
const hook = this.get(key);
|
|
594
|
-
if (hook !== undefined) {
|
|
595
|
-
return hook;
|
|
596
|
-
}
|
|
597
|
-
let newHook = this._factory(key);
|
|
598
|
-
const interceptors = this._interceptors;
|
|
599
|
-
for (let i = 0; i < interceptors.length; i++) {
|
|
600
|
-
const factory = interceptors[i].factory;
|
|
601
|
-
if (factory) {
|
|
602
|
-
newHook = factory(key, newHook);
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
this._map.set(key, newHook);
|
|
606
|
-
return newHook;
|
|
607
|
-
}
|
|
608
|
-
intercept(interceptor) {
|
|
609
|
-
this._interceptors.push(Object.assign({
|
|
610
|
-
factory: defaultFactory
|
|
611
|
-
}, interceptor));
|
|
612
|
-
}
|
|
613
|
-
isUsed() {
|
|
614
|
-
for (const key of this._map.keys()) {
|
|
615
|
-
const hook = this.get(key);
|
|
616
|
-
if (hook === null || hook === void 0 ? void 0 : hook.isUsed()) {
|
|
617
|
-
return true;
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
return false;
|
|
621
|
-
}
|
|
622
|
-
queryStageRange(stageRange) {
|
|
623
|
-
return new QueriedHookMap(stageRange, this);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
exports.HookMap = HookMap;
|
|
627
|
-
class QueriedHookMap {
|
|
628
|
-
constructor(stageRange, hookMap) {
|
|
629
|
-
this.stageRange = stageRange;
|
|
630
|
-
this.hookMap = hookMap;
|
|
631
|
-
}
|
|
632
|
-
get(key) {
|
|
633
|
-
var _a;
|
|
634
|
-
return (_a = this.hookMap.get(key)) === null || _a === void 0 ? void 0 : _a.queryStageRange(this.stageRange);
|
|
635
|
-
}
|
|
636
|
-
for(key) {
|
|
637
|
-
return this.hookMap.for(key).queryStageRange(this.stageRange);
|
|
638
|
-
}
|
|
639
|
-
isUsed() {
|
|
640
|
-
var _a;
|
|
641
|
-
for (const key in this.hookMap._map.keys()) {
|
|
642
|
-
if ((_a = this.get(key)) === null || _a === void 0 ? void 0 : _a.isUsed()) {
|
|
643
|
-
return true;
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
return false;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
exports.QueriedHookMap = QueriedHookMap;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/core",
|
|
3
|
-
"version": "0.5.9-canary-
|
|
3
|
+
"version": "0.5.9-canary-c269a3b-20240401072545",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Fast Rust-based Web Bundler",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"directory": "packages/rspack"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@swc/plugin-remove-console": "1.5.
|
|
32
|
+
"@swc/plugin-remove-console": "^1.5.114",
|
|
33
33
|
"@types/watchpack": "^2.4.0",
|
|
34
34
|
"@types/webpack-sources": "3.2.3",
|
|
35
35
|
"@types/ws": "8.5.10",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"styled-components": "^6.0.8",
|
|
57
57
|
"terser": "5.27.2",
|
|
58
58
|
"wast-loader": "^1.11.4",
|
|
59
|
-
"@rspack/core": "0.5.9-canary-
|
|
60
|
-
"@rspack/plugin-minify": "^0.5.9-canary-
|
|
59
|
+
"@rspack/core": "0.5.9-canary-c269a3b-20240401072545",
|
|
60
|
+
"@rspack/plugin-minify": "^0.5.9-canary-c269a3b-20240401072545"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@module-federation/runtime-tools": "0.0.8",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"webpack-sources": "3.2.3",
|
|
73
73
|
"zod": "^3.21.4",
|
|
74
74
|
"zod-validation-error": "1.3.1",
|
|
75
|
-
"@rspack/binding": "0.5.9-canary-
|
|
75
|
+
"@rspack/binding": "0.5.9-canary-c269a3b-20240401072545"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@swc/helpers": ">=0.5.1"
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Based on [webpack/lib/NormalModuleReplacementPlugin.js]{@link https://github.com/webpack/webpack/blob/29cc4ead7eb6aafc3a5f6d0b10ce41d33d1ad874/lib/NormalModuleReplacementPlugin.js}
|
|
3
|
-
* Licensed with [MIT License]{@link http://www.opensource.org/licenses/mit-license.php}
|
|
4
|
-
* Original Author Tobias Koppers @sokra
|
|
5
|
-
*/
|
|
6
|
-
import { Compiler } from "../Compiler";
|
|
7
|
-
import { ResolveData } from "../Module";
|
|
8
|
-
type ModuleReplacer = (createData: ResolveData) => void;
|
|
9
|
-
export declare class NormalModuleReplacementPlugin {
|
|
10
|
-
readonly resourceRegExp: RegExp;
|
|
11
|
-
readonly newResource: string | ModuleReplacer;
|
|
12
|
-
/**
|
|
13
|
-
* @param {RegExp} resourceRegExp the resource matcher
|
|
14
|
-
* @param {string|ModuleReplacer} newResource the resource replacement
|
|
15
|
-
*/
|
|
16
|
-
constructor(resourceRegExp: RegExp, newResource: string | ModuleReplacer);
|
|
17
|
-
apply(compiler: Compiler): void;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Based on [webpack/lib/NormalModuleReplacementPlugin.js]{@link https://github.com/webpack/webpack/blob/29cc4ead7eb6aafc3a5f6d0b10ce41d33d1ad874/lib/NormalModuleReplacementPlugin.js}
|
|
4
|
-
* Licensed with [MIT License]{@link http://www.opensource.org/licenses/mit-license.php}
|
|
5
|
-
* Original Author Tobias Koppers @sokra
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
-
if (mod && mod.__esModule) return mod;
|
|
25
|
-
var result = {};
|
|
26
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
-
__setModuleDefault(result, mod);
|
|
28
|
-
return result;
|
|
29
|
-
};
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.NormalModuleReplacementPlugin = void 0;
|
|
32
|
-
const NodePath = __importStar(require("node:path"));
|
|
33
|
-
class NormalModuleReplacementPlugin {
|
|
34
|
-
/**
|
|
35
|
-
* @param {RegExp} resourceRegExp the resource matcher
|
|
36
|
-
* @param {string|ModuleReplacer} newResource the resource replacement
|
|
37
|
-
*/
|
|
38
|
-
constructor(resourceRegExp, newResource) {
|
|
39
|
-
this.resourceRegExp = resourceRegExp;
|
|
40
|
-
this.newResource = newResource;
|
|
41
|
-
}
|
|
42
|
-
apply(compiler) {
|
|
43
|
-
const { resourceRegExp, newResource } = this;
|
|
44
|
-
compiler.hooks.normalModuleFactory.tap("NormalModuleReplacementPlugin", nmf => {
|
|
45
|
-
nmf.hooks.beforeResolve.tap("NormalModuleReplacementPlugin", result => {
|
|
46
|
-
if (resourceRegExp.test(result.request)) {
|
|
47
|
-
if (typeof newResource === "function") {
|
|
48
|
-
newResource(result);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
result.request = newResource;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
nmf.hooks.afterResolve.tap("NormalModuleReplacementPlugin", result => {
|
|
56
|
-
const createData = result.createData || {};
|
|
57
|
-
if (resourceRegExp.test(createData.resource || "")) {
|
|
58
|
-
if (typeof newResource === "function") {
|
|
59
|
-
newResource(result);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
if (NodePath.posix.isAbsolute(newResource) ||
|
|
63
|
-
NodePath.win32.isAbsolute(newResource)) {
|
|
64
|
-
createData.resource = newResource;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
createData.resource = NodePath.join(NodePath.dirname(createData.resource || ""), newResource);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.NormalModuleReplacementPlugin = NormalModuleReplacementPlugin;
|