@rspack/core 0.5.9-canary-8fd75cb-20240326041944 → 0.5.9-canary-6bcb6c4-20240326140146

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,7 +143,9 @@ 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");
148
+ new builtin_plugin_1.JsLoaderRspackPlugin(this).apply(this);
136
149
  new ExecuteModulePlugin_1.default().apply(this);
137
150
  }
138
151
  /**
@@ -484,7 +497,7 @@ class Compiler {
484
497
  }
485
498
  }
486
499
  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) {
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) {
488
501
  const error = (0, bindingVersionCheck_1.checkVersion)();
489
502
  if (error) {
490
503
  return callback(error);
@@ -501,26 +514,20 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
501
514
  options.builtins = (0, builtin_plugin_1.deprecated_resolveBuiltins)(options.builtins, options);
502
515
  const rawOptions = (0, config_1.getRawOptions)(options, this);
503
516
  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) => {
517
+ __classPrivateFieldSet(this, _Compiler_registers, {
518
+ registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerThisCompilation, () => this.hooks.thisCompilation, queried => (native) => {
512
519
  if (this.compilation === undefined) {
513
520
  __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createCompilation).call(this, native);
514
521
  }
515
522
  queried.call(this.compilation, this.compilationParams);
516
523
  }),
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, {
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, {
524
531
  compilation: this.compilation,
525
532
  targetPath,
526
533
  outputPath,
@@ -533,7 +540,7 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
533
540
  return (_a = this.source) === null || _a === void 0 ? void 0 : _a.buffer();
534
541
  }
535
542
  })),
536
- registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.runtimeModule, queried => ({ module, chunk }) => {
543
+ registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeModule, () => this.compilation.hooks.runtimeModule, queried => ({ module, chunk }) => {
537
544
  var _a, _b;
538
545
  const originSource = (_a = module.source) === null || _a === void 0 ? void 0 : _a.source;
539
546
  queried.call(module, Chunk_1.Chunk.__from_binding(chunk, this.compilation));
@@ -543,10 +550,10 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
543
550
  }
544
551
  return;
545
552
  }),
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 }) => {
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 }) => {
550
557
  const __webpack_require__ = (id) => {
551
558
  const cached = moduleCache[id];
552
559
  if (cached !== undefined) {
@@ -584,15 +591,15 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
584
591
  const executeResult = __webpack_require__(entry);
585
592
  __classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").set(id, executeResult);
586
593
  }),
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) => {
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) => {
596
603
  const normalizedResolveData = {
597
604
  request: resolveData.request,
598
605
  context: resolveData.context,
@@ -604,18 +611,59 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
604
611
  resolveData.request = normalizedResolveData.request;
605
612
  resolveData.context = normalizedResolveData.context;
606
613
  return [ret, resolveData];
614
+ }),
615
+ registerNormalModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryAfterResolve, () => this.compilationParams.normalModuleFactory.hooks.afterResolve, queried => async (arg) => {
616
+ const data = {
617
+ request: arg.request,
618
+ context: arg.context,
619
+ fileDependencies: arg.fileDependencies,
620
+ missingDependencies: arg.missingDependencies,
621
+ contextDependencies: arg.contextDependencies,
622
+ factoryMeta: arg.factoryMeta,
623
+ createData: arg.createData
624
+ };
625
+ const ret = await queried.promise(data);
626
+ return [ret, data.createData];
627
+ }),
628
+ registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => this.compilationParams.contextModuleFactory.hooks.beforeResolve, queried => async (arg) => {
629
+ const data = {
630
+ request: arg.request,
631
+ context: arg.context,
632
+ fileDependencies: [],
633
+ missingDependencies: [],
634
+ contextDependencies: []
635
+ };
636
+ const ret = await queried.promise(data);
637
+ return [ret, data];
607
638
  })
608
- }, (0, fileSystem_1.createThreadsafeNodeFSFromRaw)(this.outputFileSystem)), "f");
639
+ }, "f");
640
+ __classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins, {
641
+ normalModuleFactoryCreateModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryCreateModule).bind(this),
642
+ normalModuleFactoryResolveForScheme: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryResolveForScheme).bind(this),
643
+ contextModuleFactoryAfterResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_contextModuleFactoryAfterResolve).bind(this)
644
+ }, __classPrivateFieldGet(this, _Compiler_registers, "f"), (0, fileSystem_1.createThreadsafeNodeFSFromRaw)(this.outputFileSystem)), "f");
609
645
  callback(null, __classPrivateFieldGet(this, _Compiler_instance, "f"));
646
+ }, _Compiler_updateNonSkippableRegisters = function _Compiler_updateNonSkippableRegisters() {
647
+ const kinds = [];
648
+ for (const { getHook, registerKind } of Object.values(__classPrivateFieldGet(this, _Compiler_registers, "f"))) {
649
+ const hook = getHook();
650
+ if (hook.isUsed()) {
651
+ kinds.push(registerKind);
652
+ }
653
+ }
654
+ if (__classPrivateFieldGet(this, _Compiler_nonSkippableRegisters, "f").join() !== kinds.join()) {
655
+ __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
656
+ instance.setNonSkippableRegisters(kinds);
657
+ __classPrivateFieldSet(this, _Compiler_nonSkippableRegisters, kinds, "f");
658
+ });
659
+ }
610
660
  }, _Compiler_updateDisabledHooks = function _Compiler_updateDisabledHooks(callback) {
611
- var _a, _b, _c, _d, _e;
661
+ var _a, _b, _c;
612
662
  const disabledHooks = [];
613
663
  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
664
+ contextModuleFactoryAfterResolve: (_a = this.compilationParams) === null || _a === void 0 ? void 0 : _a.contextModuleFactory.hooks.afterResolve,
665
+ normalModuleFactoryCreateModule: (_b = this.compilationParams) === null || _b === void 0 ? void 0 : _b.normalModuleFactory.hooks.createModule,
666
+ normalModuleFactoryResolveForScheme: (_c = this.compilationParams) === null || _c === void 0 ? void 0 : _c.normalModuleFactory.hooks.resolveForScheme
619
667
  };
620
668
  for (const [name, hook] of Object.entries(hookMap)) {
621
669
  if (typeof hook !== "undefined" &&
@@ -637,24 +685,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
637
685
  __classPrivateFieldSet(this, _Compiler_disabledHooks, disabledHooks, "f");
638
686
  });
639
687
  }
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
688
  }, _Compiler_contextModuleFactoryAfterResolve = async function _Compiler_contextModuleFactoryAfterResolve(resourceData) {
659
689
  let res = await this.compilationParams.contextModuleFactory.hooks.afterResolve.promise(resourceData);
660
690
  __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
@@ -674,12 +704,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
674
704
  resourceData: input.resourceData,
675
705
  stop: stop === true
676
706
  };
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
707
  }, _Compiler_decorateUpdateDisabledHooks = function _Compiler_decorateUpdateDisabledHooks(jsTaps) {
684
708
  if (jsTaps.length > 0) {
685
709
  const last = jsTaps[jsTaps.length - 1];
@@ -689,15 +713,17 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
689
713
  if (result && typeof result.then === "function") {
690
714
  return result.then((r) => {
691
715
  __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
716
+ __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateNonSkippableRegisters).call(this);
692
717
  return r;
693
718
  });
694
719
  }
695
720
  __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
721
+ __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateNonSkippableRegisters).call(this);
696
722
  return result;
697
723
  };
698
724
  }
699
- }, _Compiler_createRegisterTaps = function _Compiler_createRegisterTaps(getHook, createTap) {
700
- return stages => {
725
+ }, _Compiler_createRegisterTaps = function _Compiler_createRegisterTaps(registerKind, getHook, createTap) {
726
+ const getTaps = (stages) => {
701
727
  const hook = getHook();
702
728
  if (!hook.isUsed())
703
729
  return [];
@@ -722,6 +748,9 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
722
748
  __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_decorateUpdateDisabledHooks).call(this, jsTaps);
723
749
  return jsTaps;
724
750
  };
751
+ getTaps.registerKind = registerKind;
752
+ getTaps.getHook = getHook;
753
+ return getTaps;
725
754
  }, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
726
755
  const compilation = new Compilation_1.Compilation(this, native);
727
756
  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>} */
@@ -4,4 +4,6 @@ exports.JsLoaderRspackPlugin = void 0;
4
4
  const binding_1 = require("@rspack/binding");
5
5
  const base_1 = require("./base");
6
6
  const loader_runner_1 = require("../loader-runner");
7
- exports.JsLoaderRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.JsLoaderRspackPlugin, (compiler) => loader_runner_1.runLoaders.bind(null, compiler), "compilation");
7
+ exports.JsLoaderRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.JsLoaderRspackPlugin, (compiler) => loader_runner_1.runLoaders.bind(null, compiler),
8
+ /* Not Inheretable */
9
+ "thisCompilation");
@@ -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;
@@ -137,7 +137,6 @@ class RspackOptionsApply {
137
137
  if (options.experiments.asyncWebAssembly) {
138
138
  new builtin_plugin_1.AsyncWebAssemblyModulesPlugin().apply(compiler);
139
139
  }
140
- new builtin_plugin_1.JsLoaderRspackPlugin(compiler).apply(compiler);
141
140
  if (options.experiments.rspackFuture.disableApplyEntryLazily) {
142
141
  applyEntryOptions(compiler, options);
143
142
  }
@@ -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-6bcb6c4-20240326140146",
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-6bcb6c4-20240326140146",
60
+ "@rspack/plugin-minify": "^0.5.9-canary-6bcb6c4-20240326140146"
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-6bcb6c4-20240326140146"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@swc/helpers": ">=0.5.1"