@rspack/core 0.5.9-canary-498d329-20240328011704 → 0.5.9-canary-8778e17-20240328104834
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.js +76 -86
- package/dist/Module.d.ts +1 -2
- package/dist/NormalModuleFactory.d.ts +6 -6
- package/dist/NormalModuleFactory.js +5 -3
- package/dist/exports.d.ts +1 -1
- package/dist/exports.js +3 -1
- package/dist/lite-tapable/index.d.ts +25 -0
- package/dist/lite-tapable/index.js +70 -1
- package/package.json +4 -4
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,
|
|
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;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.Compiler = void 0;
|
|
42
42
|
/**
|
|
@@ -515,19 +515,19 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
515
515
|
const rawOptions = (0, config_1.getRawOptions)(options, this);
|
|
516
516
|
const instanceBinding = require("@rspack/binding");
|
|
517
517
|
__classPrivateFieldSet(this, _Compiler_registers, {
|
|
518
|
-
registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
518
|
+
registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerThisCompilation, () => this.hooks.thisCompilation, queried => (native) => {
|
|
519
519
|
if (this.compilation === undefined) {
|
|
520
520
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createCompilation).call(this, native);
|
|
521
521
|
}
|
|
522
522
|
queried.call(this.compilation, this.compilationParams);
|
|
523
523
|
}),
|
|
524
|
-
registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
525
|
-
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
526
|
-
registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
527
|
-
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
528
|
-
registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
529
|
-
registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
530
|
-
registerCompilerAssetEmittedTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
524
|
+
registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerCompilation, () => this.hooks.compilation, queried => () => queried.call(this.compilation, this.compilationParams)),
|
|
525
|
+
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerMake, () => this.hooks.make, queried => async () => await queried.promise(this.compilation)),
|
|
526
|
+
registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerFinishMake, () => this.hooks.finishMake, queried => async () => await queried.promise(this.compilation)),
|
|
527
|
+
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerShouldEmit, () => this.hooks.shouldEmit, queried => () => queried.call(this.compilation)),
|
|
528
|
+
registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerEmit, () => this.hooks.emit, queried => async () => await queried.promise(this.compilation)),
|
|
529
|
+
registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAfterEmit, () => this.hooks.afterEmit, queried => async () => await queried.promise(this.compilation)),
|
|
530
|
+
registerCompilerAssetEmittedTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAssetEmitted, () => this.hooks.assetEmitted, queried => async ({ filename, targetPath, outputPath }) => await queried.promise(filename, {
|
|
531
531
|
compilation: this.compilation,
|
|
532
532
|
targetPath,
|
|
533
533
|
outputPath,
|
|
@@ -540,7 +540,7 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
540
540
|
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.buffer();
|
|
541
541
|
}
|
|
542
542
|
})),
|
|
543
|
-
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
543
|
+
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeModule, () => this.compilation.hooks.runtimeModule, queried => ({ module, chunk }) => {
|
|
544
544
|
var _a, _b;
|
|
545
545
|
const originSource = (_a = module.source) === null || _a === void 0 ? void 0 : _a.source;
|
|
546
546
|
queried.call(module, Chunk_1.Chunk.__from_binding(chunk, this.compilation));
|
|
@@ -550,10 +550,10 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
550
550
|
}
|
|
551
551
|
return;
|
|
552
552
|
}),
|
|
553
|
-
registerCompilationBuildModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
554
|
-
registerCompilationStillValidModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
555
|
-
registerCompilationSucceedModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
556
|
-
registerCompilationExecuteModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
553
|
+
registerCompilationBuildModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).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_createHookRegisterTaps).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_createHookRegisterTaps).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_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationExecuteModule, () => this.compilation.hooks.executeModule, queried => ({ entry, id, codegenResults, runtimeModules }) => {
|
|
557
557
|
const __webpack_require__ = (id) => {
|
|
558
558
|
const cached = moduleCache[id];
|
|
559
559
|
if (cached !== undefined) {
|
|
@@ -591,15 +591,15 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
591
591
|
const executeResult = __webpack_require__(entry);
|
|
592
592
|
__classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").set(id, executeResult);
|
|
593
593
|
}),
|
|
594
|
-
registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
595
|
-
registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
596
|
-
registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
597
|
-
registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
598
|
-
registerCompilationOptimizeChunkModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
599
|
-
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
600
|
-
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
601
|
-
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
602
|
-
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
594
|
+
registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).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_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeModules, () => this.compilation.hooks.optimizeModules, queried => () => queried.call(this.compilation.modules)),
|
|
596
|
+
registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterOptimizeModules, () => this.compilation.hooks.afterOptimizeModules, queried => () => queried.call(this.compilation.modules)),
|
|
597
|
+
registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).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_createHookRegisterTaps).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_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
|
+
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
|
+
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () => this.compilation.hooks.afterProcessAssets, queried => () => queried.call(this.compilation.assets)),
|
|
602
|
+
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
603
603
|
const normalizedResolveData = {
|
|
604
604
|
request: resolveData.request,
|
|
605
605
|
context: resolveData.context,
|
|
@@ -612,20 +612,32 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
612
612
|
resolveData.context = normalizedResolveData.context;
|
|
613
613
|
return [ret, resolveData];
|
|
614
614
|
}),
|
|
615
|
-
|
|
615
|
+
registerNormalModuleFactoryResolveForSchemeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookMapRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryResolveForScheme, () => this.compilationParams.normalModuleFactory.hooks.resolveForScheme, queried => async (args) => {
|
|
616
|
+
const ret = await queried
|
|
617
|
+
.for(args.scheme)
|
|
618
|
+
.promise(args.resourceData);
|
|
619
|
+
return [ret, args.resourceData];
|
|
620
|
+
}),
|
|
621
|
+
registerNormalModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryAfterResolve, () => this.compilationParams.normalModuleFactory.hooks.afterResolve, queried => async (arg) => {
|
|
616
622
|
const data = {
|
|
617
623
|
request: arg.request,
|
|
618
624
|
context: arg.context,
|
|
619
625
|
fileDependencies: arg.fileDependencies,
|
|
620
626
|
missingDependencies: arg.missingDependencies,
|
|
621
627
|
contextDependencies: arg.contextDependencies,
|
|
622
|
-
factoryMeta: arg.factoryMeta,
|
|
623
628
|
createData: arg.createData
|
|
624
629
|
};
|
|
625
630
|
const ret = await queried.promise(data);
|
|
626
631
|
return [ret, data.createData];
|
|
627
632
|
}),
|
|
628
|
-
|
|
633
|
+
registerNormalModuleFactoryCreateModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryCreateModule, () => this.compilationParams.normalModuleFactory.hooks.createModule, queried => async (args) => {
|
|
634
|
+
const data = {
|
|
635
|
+
...args,
|
|
636
|
+
settings: {}
|
|
637
|
+
};
|
|
638
|
+
await queried.promise(data, {});
|
|
639
|
+
}),
|
|
640
|
+
registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => this.compilationParams.contextModuleFactory.hooks.beforeResolve, queried => async (arg) => {
|
|
629
641
|
const data = {
|
|
630
642
|
request: arg.request,
|
|
631
643
|
context: arg.context,
|
|
@@ -636,29 +648,26 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
636
648
|
const ret = await queried.promise(data);
|
|
637
649
|
return [ret, data];
|
|
638
650
|
}),
|
|
639
|
-
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
651
|
+
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryAfterResolve, () => this.compilationParams.contextModuleFactory.hooks.afterResolve, queried => async (arg) => {
|
|
640
652
|
const data = {
|
|
641
653
|
request: arg.request,
|
|
642
654
|
context: arg.context,
|
|
643
655
|
fileDependencies: arg.fileDependencies,
|
|
644
656
|
missingDependencies: arg.missingDependencies,
|
|
645
657
|
contextDependencies: arg.contextDependencies,
|
|
646
|
-
factoryMeta: arg.factoryMeta,
|
|
647
658
|
createData: arg.createData
|
|
648
659
|
};
|
|
649
660
|
return await queried.promise(data);
|
|
650
661
|
})
|
|
651
662
|
}, "f");
|
|
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");
|
|
663
|
+
__classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins, __classPrivateFieldGet(this, _Compiler_registers, "f"), (0, fileSystem_1.createThreadsafeNodeFSFromRaw)(this.outputFileSystem)), "f");
|
|
656
664
|
callback(null, __classPrivateFieldGet(this, _Compiler_instance, "f"));
|
|
657
665
|
}, _Compiler_updateNonSkippableRegisters = function _Compiler_updateNonSkippableRegisters() {
|
|
658
666
|
const kinds = [];
|
|
659
|
-
for (const { getHook, registerKind } of Object.values(__classPrivateFieldGet(this, _Compiler_registers, "f"))) {
|
|
660
|
-
const
|
|
661
|
-
|
|
667
|
+
for (const { getHook, getHookMap, registerKind } of Object.values(__classPrivateFieldGet(this, _Compiler_registers, "f"))) {
|
|
668
|
+
const get = getHook !== null && getHook !== void 0 ? getHook : getHookMap;
|
|
669
|
+
const hookOrMap = get();
|
|
670
|
+
if (hookOrMap.isUsed()) {
|
|
662
671
|
kinds.push(registerKind);
|
|
663
672
|
}
|
|
664
673
|
}
|
|
@@ -668,53 +677,7 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
668
677
|
__classPrivateFieldSet(this, _Compiler_nonSkippableRegisters, kinds, "f");
|
|
669
678
|
});
|
|
670
679
|
}
|
|
671
|
-
},
|
|
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) {
|
|
680
|
+
}, _Compiler_decorateJsTaps = function _Compiler_decorateJsTaps(jsTaps) {
|
|
718
681
|
if (jsTaps.length > 0) {
|
|
719
682
|
const last = jsTaps[jsTaps.length - 1];
|
|
720
683
|
const old = last.function;
|
|
@@ -722,17 +685,15 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
722
685
|
const result = old(...args);
|
|
723
686
|
if (result && typeof result.then === "function") {
|
|
724
687
|
return result.then((r) => {
|
|
725
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
726
688
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateNonSkippableRegisters).call(this);
|
|
727
689
|
return r;
|
|
728
690
|
});
|
|
729
691
|
}
|
|
730
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
731
692
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateNonSkippableRegisters).call(this);
|
|
732
693
|
return result;
|
|
733
694
|
};
|
|
734
695
|
}
|
|
735
|
-
},
|
|
696
|
+
}, _Compiler_createHookRegisterTaps = function _Compiler_createHookRegisterTaps(registerKind, getHook, createTap) {
|
|
736
697
|
const getTaps = (stages) => {
|
|
737
698
|
const hook = getHook();
|
|
738
699
|
if (!hook.isUsed())
|
|
@@ -755,12 +716,41 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
755
716
|
stage: liteTapable.safeStage(from + 1)
|
|
756
717
|
});
|
|
757
718
|
}
|
|
758
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m",
|
|
719
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_decorateJsTaps).call(this, jsTaps);
|
|
759
720
|
return jsTaps;
|
|
760
721
|
};
|
|
761
722
|
getTaps.registerKind = registerKind;
|
|
762
723
|
getTaps.getHook = getHook;
|
|
763
724
|
return getTaps;
|
|
725
|
+
}, _Compiler_createHookMapRegisterTaps = function _Compiler_createHookMapRegisterTaps(registerKind, getHookMap, createTap) {
|
|
726
|
+
const getTaps = (stages) => {
|
|
727
|
+
const map = getHookMap();
|
|
728
|
+
if (!map.isUsed())
|
|
729
|
+
return [];
|
|
730
|
+
const breakpoints = [
|
|
731
|
+
liteTapable.minStage,
|
|
732
|
+
...stages,
|
|
733
|
+
liteTapable.maxStage
|
|
734
|
+
];
|
|
735
|
+
const jsTaps = [];
|
|
736
|
+
for (let i = 0; i < breakpoints.length - 1; i++) {
|
|
737
|
+
const from = breakpoints[i];
|
|
738
|
+
const to = breakpoints[i + 1];
|
|
739
|
+
const stageRange = [from, to];
|
|
740
|
+
const queried = map.queryStageRange(stageRange);
|
|
741
|
+
if (!queried.isUsed())
|
|
742
|
+
continue;
|
|
743
|
+
jsTaps.push({
|
|
744
|
+
function: createTap(queried),
|
|
745
|
+
stage: liteTapable.safeStage(from + 1)
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_decorateJsTaps).call(this, jsTaps);
|
|
749
|
+
return jsTaps;
|
|
750
|
+
};
|
|
751
|
+
getTaps.registerKind = registerKind;
|
|
752
|
+
getTaps.getHookMap = getHookMap;
|
|
753
|
+
return getTaps;
|
|
764
754
|
}, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
|
|
765
755
|
const compilation = new Compilation_1.Compilation(this, native);
|
|
766
756
|
compilation.name = this.name;
|
package/dist/Module.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsCodegenerationResult, JsCodegenerationResults, JsCreateData,
|
|
1
|
+
import { JsCodegenerationResult, JsCodegenerationResults, JsCreateData, JsModule } from "@rspack/binding";
|
|
2
2
|
import { Source } from "webpack-sources";
|
|
3
3
|
export type ResourceData = {
|
|
4
4
|
resource: string;
|
|
@@ -16,7 +16,6 @@ export type ResolveData = {
|
|
|
16
16
|
fileDependencies: string[];
|
|
17
17
|
missingDependencies: string[];
|
|
18
18
|
contextDependencies: string[];
|
|
19
|
-
factoryMeta?: JsFactoryMeta;
|
|
20
19
|
createData?: CreateData;
|
|
21
20
|
};
|
|
22
21
|
export declare class Module {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { AsyncSeriesBailHook, HookMap } from "tapable";
|
|
2
1
|
import * as liteTapable from "./lite-tapable";
|
|
3
2
|
import type * as binding from "@rspack/binding";
|
|
4
3
|
import { ResolveData, ResourceDataWithData } from "./Module";
|
|
5
|
-
type
|
|
4
|
+
export type NormalModuleCreateData = binding.JsNormalModuleFactoryCreateModuleArgs & {
|
|
6
5
|
settings: {};
|
|
7
|
-
matchResource: string;
|
|
8
6
|
};
|
|
9
7
|
export declare class NormalModuleFactory {
|
|
10
8
|
hooks: {
|
|
11
|
-
resolveForScheme: HookMap<AsyncSeriesBailHook<[ResourceDataWithData], true | void>>;
|
|
9
|
+
resolveForScheme: liteTapable.HookMap<liteTapable.AsyncSeriesBailHook<[ResourceDataWithData], true | void>>;
|
|
12
10
|
beforeResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>;
|
|
13
11
|
afterResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>;
|
|
14
|
-
createModule: AsyncSeriesBailHook<[
|
|
12
|
+
createModule: liteTapable.AsyncSeriesBailHook<[
|
|
13
|
+
NormalModuleCreateData,
|
|
14
|
+
{}
|
|
15
|
+
], void>;
|
|
15
16
|
};
|
|
16
17
|
constructor();
|
|
17
18
|
}
|
|
18
|
-
export {};
|
|
@@ -24,7 +24,6 @@ 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");
|
|
28
27
|
const liteTapable = __importStar(require("./lite-tapable"));
|
|
29
28
|
class NormalModuleFactory {
|
|
30
29
|
constructor() {
|
|
@@ -32,7 +31,7 @@ class NormalModuleFactory {
|
|
|
32
31
|
// /** @type {AsyncSeriesBailHook<[ResolveData], Module | false | void>} */
|
|
33
32
|
// resolve: new AsyncSeriesBailHook(["resolveData"]),
|
|
34
33
|
// /** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>>} */
|
|
35
|
-
resolveForScheme: new
|
|
34
|
+
resolveForScheme: new liteTapable.HookMap(() => new liteTapable.AsyncSeriesBailHook(["resourceData"])),
|
|
36
35
|
// /** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>>} */
|
|
37
36
|
// resolveInScheme: new HookMap(
|
|
38
37
|
// () => new AsyncSeriesBailHook(["resourceData", "resolveData"])
|
|
@@ -44,7 +43,10 @@ class NormalModuleFactory {
|
|
|
44
43
|
// /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
|
|
45
44
|
afterResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
|
|
46
45
|
// /** @type {AsyncSeriesBailHook<[ResolveData["createData"], ResolveData], Module | void>} */
|
|
47
|
-
createModule: new
|
|
46
|
+
createModule: new liteTapable.AsyncSeriesBailHook([
|
|
47
|
+
"createData",
|
|
48
|
+
"resolveData"
|
|
49
|
+
])
|
|
48
50
|
// /** @type {SyncWaterfallHook<[Module, ResolveData["createData"], ResolveData], Module>} */
|
|
49
51
|
// module: new SyncWaterfallHook(["module", "createData", "resolveData"]),
|
|
50
52
|
// 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
|
|
14
|
+
export { MultiStats } from "./MultiStats";
|
|
15
15
|
export type { ChunkGroup } from "./ChunkGroup";
|
|
16
16
|
export type { NormalModuleFactory } from "./NormalModuleFactory";
|
|
17
17
|
export { NormalModule } from "./NormalModule";
|
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.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;
|
|
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.MultiStats = 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,6 +20,8 @@ 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; } });
|
|
23
25
|
var NormalModule_1 = require("./NormalModule");
|
|
24
26
|
Object.defineProperty(exports, "NormalModule", { enumerable: true, get: function () { return NormalModule_1.NormalModule; } });
|
|
25
27
|
var ModuleFilenameHelpers_1 = require("./lib/ModuleFilenameHelpers");
|
|
@@ -112,4 +112,29 @@ 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
|
+
}
|
|
115
140
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsyncSeriesBailHook = exports.AsyncSeriesHook = exports.AsyncParallelHook = exports.SyncBailHook = exports.SyncHook = exports.QueriedHook = exports.safeStage = exports.maxStage = exports.minStage = exports.Hook = void 0;
|
|
3
|
+
exports.QueriedHookMap = exports.HookMap = 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,3 +578,72 @@ 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-8778e17-20240328104834",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A Fast Rust-based Web Bundler",
|
|
@@ -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/
|
|
60
|
-
"@rspack/
|
|
59
|
+
"@rspack/plugin-minify": "^0.5.9-canary-8778e17-20240328104834",
|
|
60
|
+
"@rspack/core": "0.5.9-canary-8778e17-20240328104834"
|
|
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-8778e17-20240328104834"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@swc/helpers": ">=0.5.1"
|