@rspack/core 0.5.9-canary-8fd75cb-20240326041944 → 0.5.9-canary-845e837-20240327011520

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.
@@ -10,7 +10,7 @@
10
10
  */
11
11
  import * as tapable from "tapable";
12
12
  import { Source } from "webpack-sources";
13
- import type { ExternalObject, JsAssetInfo, JsCompatSource, JsCompilation, JsModule, JsRuntimeModule, JsStatsChunk, JsStatsError, PathData } from "@rspack/binding";
13
+ import type { ExternalObject, JsAssetInfo, JsCompilation, JsModule, JsRuntimeModule, JsStatsChunk, JsStatsError, PathData } from "@rspack/binding";
14
14
  import { RspackOptionsNormalized, StatsOptions, OutputNormalized, StatsValue, RspackPluginInstance, Filename } from "./config";
15
15
  import * as liteTapable from "./lite-tapable";
16
16
  import { ContextModuleFactory } from "./ContextModuleFactory";
@@ -141,13 +141,6 @@ export declare class Compilation {
141
141
  * @param {AssetInfo | function(AssetInfo): AssetInfo} assetInfoUpdateOrFunction new asset info or function converting old to new
142
142
  */
143
143
  updateAsset(filename: string, newSourceOrFunction: Source | ((source: Source) => Source), assetInfoUpdateOrFunction: AssetInfo | ((assetInfo: AssetInfo) => AssetInfo)): void;
144
- /**
145
- *
146
- * @param moduleIdentifier moduleIdentifier of the module you want to modify
147
- * @param source
148
- * @returns true if the setting is success, false if failed.
149
- */
150
- setNoneAstModuleSource(moduleIdentifier: string, source: JsCompatSource): boolean;
151
144
  /**
152
145
  * Emit an not existing asset. Trying to emit an asset that already exists will throw an error.
153
146
  *
@@ -312,15 +312,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
312
312
  ? jsAssetInfo => (0, util_1.toJsAssetInfo)(assetInfoUpdateOrFunction(jsAssetInfo))
313
313
  : (0, util_1.toJsAssetInfo)(assetInfoUpdateOrFunction));
314
314
  }
315
- /**
316
- *
317
- * @param moduleIdentifier moduleIdentifier of the module you want to modify
318
- * @param source
319
- * @returns true if the setting is success, false if failed.
320
- */
321
- setNoneAstModuleSource(moduleIdentifier, source) {
322
- return __classPrivateFieldGet(this, _Compilation_inner, "f").setNoneAstModuleSource(moduleIdentifier, source);
323
- }
324
315
  /**
325
316
  * Emit an not existing asset. Trying to emit an asset that already exists will throw an error.
326
317
  *
package/dist/Compiler.js CHANGED
@@ -36,9 +36,19 @@ 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_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateDisabledHooks, _Compiler_afterProcessAssets, _Compiler_afterResolve, _Compiler_contextModuleFactoryBeforeResolve, _Compiler_contextModuleFactoryAfterResolve, _Compiler_normalModuleFactoryCreateModule, _Compiler_normalModuleFactoryResolveForScheme, _Compiler_optimizeChunkModules, _Compiler_optimizeTree, _Compiler_decorateUpdateDisabledHooks, _Compiler_createRegisterTaps, _Compiler_createCompilation, _Compiler_resetThisCompilation, _Compiler_newCompilationParams;
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
+ /**
43
+ * The following code is modified based on
44
+ * https://github.com/webpack/webpack/blob/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/Compiler.js
45
+ *
46
+ * MIT Licensed
47
+ * Author Tobias Koppers @sokra
48
+ * Copyright (c) JS Foundation and other contributors
49
+ * https://github.com/webpack/webpack/blob/main/LICENSE
50
+ */
51
+ const binding = __importStar(require("@rspack/binding"));
42
52
  const index_1 = require("./index");
43
53
  const fs_1 = __importDefault(require("fs"));
44
54
  const tapable = __importStar(require("tapable"));
@@ -58,7 +68,6 @@ const Logger_1 = require("./logging/Logger");
58
68
  const NormalModuleFactory_1 = require("./NormalModuleFactory");
59
69
  const bindingVersionCheck_1 = require("./util/bindingVersionCheck");
60
70
  const Watching_1 = require("./Watching");
61
- const NormalModule_1 = require("./NormalModule");
62
71
  const builtin_plugin_1 = require("./builtin-plugin");
63
72
  const rspackOptionsApply_1 = require("./rspackOptionsApply");
64
73
  const defaults_1 = require("./config/defaults");
@@ -77,6 +86,8 @@ class Compiler {
77
86
  // TODO: remove this after remove rebuild on the rust side.
78
87
  this.first = true;
79
88
  _Compiler_disabledHooks.set(this, void 0);
89
+ _Compiler_nonSkippableRegisters.set(this, void 0);
90
+ _Compiler_registers.set(this, void 0);
80
91
  _Compiler_moduleExecutionResultsMap.set(this, void 0);
81
92
  this.outputFileSystem = fs_1.default;
82
93
  this.options = options;
@@ -132,6 +143,7 @@ class Compiler {
132
143
  this.modifiedFiles = undefined;
133
144
  this.removedFiles = undefined;
134
145
  __classPrivateFieldSet(this, _Compiler_disabledHooks, [], "f");
146
+ __classPrivateFieldSet(this, _Compiler_nonSkippableRegisters, [], "f");
135
147
  __classPrivateFieldSet(this, _Compiler_moduleExecutionResultsMap, new Map(), "f");
136
148
  new ExecuteModulePlugin_1.default().apply(this);
137
149
  }
@@ -484,7 +496,7 @@ class Compiler {
484
496
  }
485
497
  }
486
498
  exports.Compiler = Compiler;
487
- _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Compiler_moduleExecutionResultsMap = new WeakMap(), _Compiler_instances = new WeakSet(), _Compiler_getInstance = function _Compiler_getInstance(callback) {
499
+ _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) {
488
500
  const error = (0, bindingVersionCheck_1.checkVersion)();
489
501
  if (error) {
490
502
  return callback(error);
@@ -501,26 +513,20 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
501
513
  options.builtins = (0, builtin_plugin_1.deprecated_resolveBuiltins)(options.builtins, options);
502
514
  const rawOptions = (0, config_1.getRawOptions)(options, this);
503
515
  const instanceBinding = require("@rspack/binding");
504
- __classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins, {
505
- normalModuleFactoryCreateModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryCreateModule).bind(this),
506
- normalModuleFactoryResolveForScheme: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryResolveForScheme).bind(this),
507
- afterResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterResolve).bind(this),
508
- contextModuleFactoryBeforeResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_contextModuleFactoryBeforeResolve).bind(this),
509
- contextModuleFactoryAfterResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_contextModuleFactoryAfterResolve).bind(this)
510
- }, {
511
- registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.thisCompilation, queried => (native) => {
516
+ __classPrivateFieldSet(this, _Compiler_registers, {
517
+ registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerThisCompilation, () => this.hooks.thisCompilation, queried => (native) => {
512
518
  if (this.compilation === undefined) {
513
519
  __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createCompilation).call(this, native);
514
520
  }
515
521
  queried.call(this.compilation, this.compilationParams);
516
522
  }),
517
- registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.compilation, queried => () => queried.call(this.compilation, this.compilationParams)),
518
- registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.make, queried => async () => await queried.promise(this.compilation)),
519
- registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.finishMake, queried => async () => await queried.promise(this.compilation)),
520
- registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.shouldEmit, queried => () => queried.call(this.compilation)),
521
- registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.emit, queried => async () => await queried.promise(this.compilation)),
522
- registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.afterEmit, queried => async () => await queried.promise(this.compilation)),
523
- registerCompilerAssetEmittedTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.assetEmitted, queried => async ({ filename, targetPath, outputPath }) => await queried.promise(filename, {
523
+ registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerCompilation, () => this.hooks.compilation, queried => () => queried.call(this.compilation, this.compilationParams)),
524
+ registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerMake, () => this.hooks.make, queried => async () => await queried.promise(this.compilation)),
525
+ registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerFinishMake, () => this.hooks.finishMake, queried => async () => await queried.promise(this.compilation)),
526
+ registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerShouldEmit, () => this.hooks.shouldEmit, queried => () => queried.call(this.compilation)),
527
+ registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerEmit, () => this.hooks.emit, queried => async () => await queried.promise(this.compilation)),
528
+ registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAfterEmit, () => this.hooks.afterEmit, queried => async () => await queried.promise(this.compilation)),
529
+ 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, {
524
530
  compilation: this.compilation,
525
531
  targetPath,
526
532
  outputPath,
@@ -533,7 +539,7 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
533
539
  return (_a = this.source) === null || _a === void 0 ? void 0 : _a.buffer();
534
540
  }
535
541
  })),
536
- registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.runtimeModule, queried => ({ module, chunk }) => {
542
+ registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeModule, () => this.compilation.hooks.runtimeModule, queried => ({ module, chunk }) => {
537
543
  var _a, _b;
538
544
  const originSource = (_a = module.source) === null || _a === void 0 ? void 0 : _a.source;
539
545
  queried.call(module, Chunk_1.Chunk.__from_binding(chunk, this.compilation));
@@ -543,10 +549,10 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
543
549
  }
544
550
  return;
545
551
  }),
546
- registerCompilationBuildModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.buildModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
547
- registerCompilationStillValidModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.stillValidModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
548
- registerCompilationSucceedModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.succeedModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
549
- registerCompilationExecuteModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.executeModule, queried => ({ entry, id, codegenResults, runtimeModules }) => {
552
+ 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))),
553
+ 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))),
554
+ 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))),
555
+ registerCompilationExecuteModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationExecuteModule, () => this.compilation.hooks.executeModule, queried => ({ entry, id, codegenResults, runtimeModules }) => {
550
556
  const __webpack_require__ = (id) => {
551
557
  const cached = moduleCache[id];
552
558
  if (cached !== undefined) {
@@ -584,15 +590,15 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
584
590
  const executeResult = __webpack_require__(entry);
585
591
  __classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").set(id, executeResult);
586
592
  }),
587
- registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.finishModules, queried => async () => await queried.promise(this.compilation.modules)),
588
- registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.optimizeModules, queried => () => queried.call(this.compilation.modules)),
589
- registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.afterOptimizeModules, queried => () => queried.call(this.compilation.modules)),
590
- registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.optimizeTree, queried => async () => await queried.promise(this.compilation.chunks, this.compilation.modules)),
591
- registerCompilationOptimizeChunkModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.optimizeChunkModules, queried => async () => await queried.promise(this.compilation.chunks, this.compilation.modules)),
592
- registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.chunkAsset, queried => ({ chunk, filename }) => queried.call(Chunk_1.Chunk.__from_binding(chunk, this.compilation), filename)),
593
- registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.processAssets, queried => async () => await queried.promise(this.compilation.assets)),
594
- registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.afterProcessAssets, queried => () => queried.call(this.compilation.assets)),
595
- registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
593
+ 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)),
594
+ registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeModules, () => this.compilation.hooks.optimizeModules, queried => () => queried.call(this.compilation.modules)),
595
+ registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterOptimizeModules, () => this.compilation.hooks.afterOptimizeModules, queried => () => queried.call(this.compilation.modules)),
596
+ 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)),
597
+ 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)),
598
+ 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)),
599
+ 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)),
600
+ registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () => this.compilation.hooks.afterProcessAssets, queried => () => queried.call(this.compilation.assets)),
601
+ registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
596
602
  const normalizedResolveData = {
597
603
  request: resolveData.request,
598
604
  context: resolveData.context,
@@ -604,18 +610,59 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
604
610
  resolveData.request = normalizedResolveData.request;
605
611
  resolveData.context = normalizedResolveData.context;
606
612
  return [ret, resolveData];
613
+ }),
614
+ registerNormalModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryAfterResolve, () => this.compilationParams.normalModuleFactory.hooks.afterResolve, queried => async (arg) => {
615
+ const data = {
616
+ request: arg.request,
617
+ context: arg.context,
618
+ fileDependencies: arg.fileDependencies,
619
+ missingDependencies: arg.missingDependencies,
620
+ contextDependencies: arg.contextDependencies,
621
+ factoryMeta: arg.factoryMeta,
622
+ createData: arg.createData
623
+ };
624
+ const ret = await queried.promise(data);
625
+ return [ret, data.createData];
626
+ }),
627
+ registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => this.compilationParams.contextModuleFactory.hooks.beforeResolve, queried => async (arg) => {
628
+ const data = {
629
+ request: arg.request,
630
+ context: arg.context,
631
+ fileDependencies: [],
632
+ missingDependencies: [],
633
+ contextDependencies: []
634
+ };
635
+ const ret = await queried.promise(data);
636
+ return [ret, data];
607
637
  })
608
- }, (0, fileSystem_1.createThreadsafeNodeFSFromRaw)(this.outputFileSystem)), "f");
638
+ }, "f");
639
+ __classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins, {
640
+ normalModuleFactoryCreateModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryCreateModule).bind(this),
641
+ normalModuleFactoryResolveForScheme: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryResolveForScheme).bind(this),
642
+ contextModuleFactoryAfterResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_contextModuleFactoryAfterResolve).bind(this)
643
+ }, __classPrivateFieldGet(this, _Compiler_registers, "f"), (0, fileSystem_1.createThreadsafeNodeFSFromRaw)(this.outputFileSystem)), "f");
609
644
  callback(null, __classPrivateFieldGet(this, _Compiler_instance, "f"));
645
+ }, _Compiler_updateNonSkippableRegisters = function _Compiler_updateNonSkippableRegisters() {
646
+ const kinds = [];
647
+ for (const { getHook, registerKind } of Object.values(__classPrivateFieldGet(this, _Compiler_registers, "f"))) {
648
+ const hook = getHook();
649
+ if (hook.isUsed()) {
650
+ kinds.push(registerKind);
651
+ }
652
+ }
653
+ if (__classPrivateFieldGet(this, _Compiler_nonSkippableRegisters, "f").join() !== kinds.join()) {
654
+ __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
655
+ instance.setNonSkippableRegisters(kinds);
656
+ __classPrivateFieldSet(this, _Compiler_nonSkippableRegisters, kinds, "f");
657
+ });
658
+ }
610
659
  }, _Compiler_updateDisabledHooks = function _Compiler_updateDisabledHooks(callback) {
611
- var _a, _b, _c, _d, _e;
660
+ var _a, _b, _c;
612
661
  const disabledHooks = [];
613
662
  const hookMap = {
614
- afterResolve: (_a = this.compilationParams) === null || _a === void 0 ? void 0 : _a.normalModuleFactory.hooks.afterResolve,
615
- contextModuleFactoryBeforeResolve: (_b = this.compilationParams) === null || _b === void 0 ? void 0 : _b.contextModuleFactory.hooks.beforeResolve,
616
- contextModuleFactoryAfterResolve: (_c = this.compilationParams) === null || _c === void 0 ? void 0 : _c.contextModuleFactory.hooks.afterResolve,
617
- normalModuleFactoryCreateModule: (_d = this.compilationParams) === null || _d === void 0 ? void 0 : _d.normalModuleFactory.hooks.createModule,
618
- normalModuleFactoryResolveForScheme: (_e = this.compilationParams) === null || _e === void 0 ? void 0 : _e.normalModuleFactory.hooks.resolveForScheme
663
+ contextModuleFactoryAfterResolve: (_a = this.compilationParams) === null || _a === void 0 ? void 0 : _a.contextModuleFactory.hooks.afterResolve,
664
+ normalModuleFactoryCreateModule: (_b = this.compilationParams) === null || _b === void 0 ? void 0 : _b.normalModuleFactory.hooks.createModule,
665
+ normalModuleFactoryResolveForScheme: (_c = this.compilationParams) === null || _c === void 0 ? void 0 : _c.normalModuleFactory.hooks.resolveForScheme
619
666
  };
620
667
  for (const [name, hook] of Object.entries(hookMap)) {
621
668
  if (typeof hook !== "undefined" &&
@@ -637,24 +684,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
637
684
  __classPrivateFieldSet(this, _Compiler_disabledHooks, disabledHooks, "f");
638
685
  });
639
686
  }
640
- }, _Compiler_afterProcessAssets = async function _Compiler_afterProcessAssets() {
641
- await this.compilation.hooks.afterProcessAssets.promise(this.compilation.assets);
642
- __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
643
- }, _Compiler_afterResolve = async function _Compiler_afterResolve(resolveData) {
644
- let res = await this.compilationParams.normalModuleFactory.hooks.afterResolve.promise(resolveData);
645
- NormalModule_1.NormalModule.getCompilationHooks(this.compilation).loader.tap("sideEffectFreePropPlugin", (loaderContext) => {
646
- loaderContext._module = {
647
- factoryMeta: {
648
- sideEffectFree: !!resolveData.factoryMeta.sideEffectFree
649
- }
650
- };
651
- });
652
- __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
653
- return [res, resolveData.createData];
654
- }, _Compiler_contextModuleFactoryBeforeResolve = async function _Compiler_contextModuleFactoryBeforeResolve(resourceData) {
655
- let res = await this.compilationParams.contextModuleFactory.hooks.beforeResolve.promise(resourceData);
656
- __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
657
- return res;
658
687
  }, _Compiler_contextModuleFactoryAfterResolve = async function _Compiler_contextModuleFactoryAfterResolve(resourceData) {
659
688
  let res = await this.compilationParams.contextModuleFactory.hooks.afterResolve.promise(resourceData);
660
689
  __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
@@ -674,12 +703,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
674
703
  resourceData: input.resourceData,
675
704
  stop: stop === true
676
705
  };
677
- }, _Compiler_optimizeChunkModules = async function _Compiler_optimizeChunkModules() {
678
- await this.compilation.hooks.optimizeChunkModules.promise(this.compilation.chunks, this.compilation.modules);
679
- __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
680
- }, _Compiler_optimizeTree = async function _Compiler_optimizeTree() {
681
- await this.compilation.hooks.optimizeTree.promise(this.compilation.chunks, this.compilation.modules);
682
- __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
683
706
  }, _Compiler_decorateUpdateDisabledHooks = function _Compiler_decorateUpdateDisabledHooks(jsTaps) {
684
707
  if (jsTaps.length > 0) {
685
708
  const last = jsTaps[jsTaps.length - 1];
@@ -689,15 +712,17 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
689
712
  if (result && typeof result.then === "function") {
690
713
  return result.then((r) => {
691
714
  __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
715
+ __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateNonSkippableRegisters).call(this);
692
716
  return r;
693
717
  });
694
718
  }
695
719
  __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
720
+ __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateNonSkippableRegisters).call(this);
696
721
  return result;
697
722
  };
698
723
  }
699
- }, _Compiler_createRegisterTaps = function _Compiler_createRegisterTaps(getHook, createTap) {
700
- return stages => {
724
+ }, _Compiler_createRegisterTaps = function _Compiler_createRegisterTaps(registerKind, getHook, createTap) {
725
+ const getTaps = (stages) => {
701
726
  const hook = getHook();
702
727
  if (!hook.isUsed())
703
728
  return [];
@@ -722,6 +747,9 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
722
747
  __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_decorateUpdateDisabledHooks).call(this, jsTaps);
723
748
  return jsTaps;
724
749
  };
750
+ getTaps.registerKind = registerKind;
751
+ getTaps.getHook = getHook;
752
+ return getTaps;
725
753
  }, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
726
754
  const compilation = new Compilation_1.Compilation(this, native);
727
755
  compilation.name = this.name;
@@ -1,13 +1,10 @@
1
1
  import { AsyncSeriesBailHook } from "tapable";
2
- type ResolveData = {
3
- context?: string;
4
- request: string;
5
- };
2
+ import * as liteTapable from "./lite-tapable";
3
+ import { ResolveData } from "./Module";
6
4
  export declare class ContextModuleFactory {
7
5
  hooks: {
8
- beforeResolve: AsyncSeriesBailHook<[ResolveData], boolean | void>;
9
- afterResolve: AsyncSeriesBailHook<[ResolveData], boolean | void>;
6
+ beforeResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>;
7
+ afterResolve: AsyncSeriesBailHook<[ResolveData], false | void>;
10
8
  };
11
9
  constructor();
12
10
  }
13
- export {};
@@ -1,7 +1,31 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.ContextModuleFactory = void 0;
4
27
  const tapable_1 = require("tapable");
28
+ const liteTapable = __importStar(require("./lite-tapable"));
5
29
  class ContextModuleFactory {
6
30
  constructor() {
7
31
  this.hooks = {
@@ -18,7 +42,7 @@ class ContextModuleFactory {
18
42
  // /** @type {AsyncSeriesBailHook<[ResolveData], Module>} */
19
43
  // factorize: new AsyncSeriesBailHook(["resolveData"]),
20
44
  // /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
21
- beforeResolve: new tapable_1.AsyncSeriesBailHook(["resolveData"]),
45
+ beforeResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
22
46
  afterResolve: new tapable_1.AsyncSeriesBailHook(["resolveData"])
23
47
  // /** @type {AsyncSeriesBailHook<[ResolveData["createData"], ResolveData], Module | void>} */
24
48
  // createModule: new AsyncSeriesBailHook(["createData", "resolveData"]),
package/dist/Module.d.ts CHANGED
@@ -1,5 +1,24 @@
1
- import { JsCodegenerationResult, JsCodegenerationResults, JsModule } from "@rspack/binding";
1
+ import { JsCodegenerationResult, JsCodegenerationResults, JsCreateData, JsFactoryMeta, JsModule } from "@rspack/binding";
2
2
  import { Source } from "webpack-sources";
3
+ export type ResourceData = {
4
+ resource: string;
5
+ path: string;
6
+ query?: string;
7
+ fragment?: string;
8
+ };
9
+ export type ResourceDataWithData = ResourceData & {
10
+ data?: Record<string, any>;
11
+ };
12
+ export type CreateData = Partial<JsCreateData>;
13
+ export type ResolveData = {
14
+ context: string;
15
+ request: string;
16
+ fileDependencies: string[];
17
+ missingDependencies: string[];
18
+ contextDependencies: string[];
19
+ factoryMeta?: JsFactoryMeta;
20
+ createData?: CreateData;
21
+ };
3
22
  export declare class Module {
4
23
  #private;
5
24
  _originalSource?: Source;
@@ -1,22 +1,7 @@
1
1
  import { AsyncSeriesBailHook, HookMap } from "tapable";
2
2
  import * as liteTapable from "./lite-tapable";
3
3
  import type * as binding from "@rspack/binding";
4
- type ResourceData = {
5
- resource: string;
6
- path: string;
7
- query?: string;
8
- fragment?: string;
9
- };
10
- type ResourceDataWithData = ResourceData & {
11
- data?: Record<string, any>;
12
- };
13
- type ResolveData = {
14
- context?: string;
15
- request: string;
16
- fileDependencies: string[];
17
- missingDependencies: string[];
18
- contextDependencies: string[];
19
- };
4
+ import { ResolveData, ResourceDataWithData } from "./Module";
20
5
  type CreateModuleData = binding.CreateModuleData & {
21
6
  settings: {};
22
7
  matchResource: string;
@@ -25,7 +10,7 @@ export declare class NormalModuleFactory {
25
10
  hooks: {
26
11
  resolveForScheme: HookMap<AsyncSeriesBailHook<[ResourceDataWithData], true | void>>;
27
12
  beforeResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>;
28
- afterResolve: AsyncSeriesBailHook<[ResolveData], boolean | void>;
13
+ afterResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>;
29
14
  createModule: AsyncSeriesBailHook<[CreateModuleData, {}], void>;
30
15
  };
31
16
  constructor();
@@ -42,7 +42,7 @@ class NormalModuleFactory {
42
42
  // /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
43
43
  beforeResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
44
44
  // /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
45
- afterResolve: new tapable_1.AsyncSeriesBailHook(["resolveData"]),
45
+ afterResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
46
46
  // /** @type {AsyncSeriesBailHook<[ResolveData["createData"], ResolveData], Module | void>} */
47
47
  createModule: new tapable_1.AsyncSeriesBailHook(["createData", "resolveData"])
48
48
  // /** @type {SyncWaterfallHook<[Module, ResolveData["createData"], ResolveData], Module>} */
@@ -336,8 +336,7 @@ const getRawModuleRule = (rule, path, options) => {
336
336
  if (rule.resourceQuery && !tryMatch(query, rule.resourceQuery)) {
337
337
  return false;
338
338
  }
339
- if (rule.resourceFragment &&
340
- !tryMatch(fragment, rule.resourceFragment)) {
339
+ if (rule.resourceFragment && !tryMatch(fragment, rule.resourceFragment)) {
341
340
  return false;
342
341
  }
343
342
  return true;
@@ -16,5 +16,5 @@ export declare const compareIds: (a: string | number, b: string | number) => -1
16
16
  export declare const compareChunksById: (a: Chunk, b: Chunk) => -1 | 0 | 1;
17
17
  export declare const compareChunkGroupsByIndex: (a: ChunkGroup, b: ChunkGroup) => -1 | 0 | 1;
18
18
  export declare const compareSelect: <T, R>(getter: Selector<T, R>, comparator: Comparator) => Comparator;
19
- export declare const compareNumbers: (a: number, b: number) => 1 | -1 | 0;
19
+ export declare const compareNumbers: (a: number, b: number) => 0 | 1 | -1;
20
20
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "0.5.9-canary-8fd75cb-20240326041944",
3
+ "version": "0.5.9-canary-845e837-20240327011520",
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/plugin-minify": "^0.5.9-canary-8fd75cb-20240326041944",
60
- "@rspack/core": "0.5.9-canary-8fd75cb-20240326041944"
59
+ "@rspack/core": "0.5.9-canary-845e837-20240327011520",
60
+ "@rspack/plugin-minify": "^0.5.9-canary-845e837-20240327011520"
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-8fd75cb-20240326041944"
75
+ "@rspack/binding": "0.5.9-canary-845e837-20240327011520"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@swc/helpers": ">=0.5.1"