@rspack/core 0.7.6-canary-1a0d77d-20240627143904 → 1.0.0-alpha.1

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.
Files changed (87) hide show
  1. package/README.md +2 -2
  2. package/compiled/enhanced-resolve/index.js +11 -11
  3. package/compiled/webpack-sources/index.d.ts +130 -0
  4. package/compiled/webpack-sources/index.js +3520 -0
  5. package/compiled/webpack-sources/license +21 -0
  6. package/compiled/webpack-sources/package.json +1 -0
  7. package/dist/Chunk.d.ts +19 -14
  8. package/dist/Chunk.js +22 -17
  9. package/dist/ChunkGraph.d.ts +1 -1
  10. package/dist/ChunkGraph.js +5 -5
  11. package/dist/ChunkGroup.d.ts +17 -7
  12. package/dist/ChunkGroup.js +12 -2
  13. package/dist/Compilation.d.ts +31 -33
  14. package/dist/Compilation.js +33 -53
  15. package/dist/Compiler.d.ts +26 -28
  16. package/dist/Compiler.js +74 -26
  17. package/dist/ContextModuleFactory.d.ts +1 -1
  18. package/dist/ContextModuleFactory.js +1 -1
  19. package/dist/Entrypoint.d.ts +1 -1
  20. package/dist/Entrypoint.js +2 -2
  21. package/dist/Module.d.ts +12 -7
  22. package/dist/Module.js +1 -0
  23. package/dist/MultiCompiler.d.ts +11 -11
  24. package/dist/MultiCompiler.js +30 -13
  25. package/dist/NormalModule.d.ts +7 -4
  26. package/dist/NormalModule.js +27 -11
  27. package/dist/NormalModuleFactory.d.ts +3 -1
  28. package/dist/NormalModuleFactory.js +3 -23
  29. package/dist/ResolverFactory.d.ts +3 -3
  30. package/dist/ResolverFactory.js +1 -1
  31. package/dist/RspackError.d.ts +8 -0
  32. package/dist/RspackError.js +21 -0
  33. package/dist/Stats.d.ts +4 -2
  34. package/dist/Stats.js +6 -0
  35. package/dist/Template.d.ts +1 -1
  36. package/dist/Template.js +2 -2
  37. package/dist/Watching.d.ts +1 -1
  38. package/dist/builtin-loader/swc/index.d.ts +0 -4
  39. package/dist/builtin-loader/swc/index.js +1 -5
  40. package/dist/builtin-loader/swc/preact.d.ts +3 -4
  41. package/dist/builtin-loader/swc/types.d.ts +2 -17
  42. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -0
  43. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +1 -0
  44. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
  46. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -1
  47. package/dist/builtin-plugin/SplitChunksPlugin.js +11 -2
  48. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +0 -28
  49. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +20 -69
  50. package/dist/builtin-plugin/css-extract/index.d.ts +2 -2
  51. package/dist/config/adapter.js +30 -16
  52. package/dist/config/adapterRuleUse.js +0 -11
  53. package/dist/config/defaults.js +22 -30
  54. package/dist/config/normalization.js +13 -5
  55. package/dist/config/zod.d.ts +753 -205
  56. package/dist/config/zod.js +27 -13
  57. package/dist/container/ModuleFederationPlugin.js +1 -1
  58. package/dist/container/default.runtime.js +1 -170
  59. package/dist/exports.d.ts +9 -2
  60. package/dist/exports.js +11 -6
  61. package/dist/lib/Cache.d.ts +3 -3
  62. package/dist/lib/Cache.js +1 -1
  63. package/dist/loader-runner/index.js +37 -12
  64. package/dist/rspack.d.ts +1 -1
  65. package/dist/rspackOptionsApply.js +3 -0
  66. package/dist/stats/DefaultStatsFactoryPlugin.js +35 -11
  67. package/dist/stats/DefaultStatsPrinterPlugin.js +2 -2
  68. package/dist/stats/StatsFactory.d.ts +2 -2
  69. package/dist/stats/StatsFactory.js +12 -12
  70. package/dist/stats/StatsPrinter.d.ts +1 -1
  71. package/dist/stats/StatsPrinter.js +8 -8
  72. package/dist/stats/statsFactoryUtils.d.ts +13 -4
  73. package/dist/util/SplitChunkSize.d.ts +5 -0
  74. package/dist/util/SplitChunkSize.js +18 -0
  75. package/dist/util/index.d.ts +2 -2
  76. package/dist/util/index.js +4 -3
  77. package/dist/util/memoize.js +5 -1
  78. package/dist/util/source.d.ts +1 -1
  79. package/dist/util/source.js +1 -1
  80. package/package.json +14 -9
  81. package/dist/builtin-loader/swc/emotion.d.ts +0 -17
  82. package/dist/builtin-loader/swc/emotion.js +0 -22
  83. package/dist/builtin-loader/swc/relay.d.ts +0 -5
  84. package/dist/builtin-loader/swc/relay.js +0 -48
  85. package/dist/container/default.runtime.d.ts +0 -2
  86. package/dist/lite-tapable/index.d.ts +0 -146
  87. package/dist/lite-tapable/index.js +0 -752
@@ -9,8 +9,7 @@
9
9
  * https://github.com/webpack/webpack/blob/main/LICENSE
10
10
  */
11
11
  import * as binding from "@rspack/binding";
12
- import * as tapable from "tapable";
13
- import { Callback } from "tapable";
12
+ import * as liteTapable from "@rspack/lite-tapable";
14
13
  import type Watchpack from "../compiled/watchpack";
15
14
  import { Compilation, CompilationParams } from "./Compilation";
16
15
  import { ContextModuleFactory } from "./ContextModuleFactory";
@@ -18,11 +17,10 @@ import { RuleSetCompiler } from "./RuleSetCompiler";
18
17
  import { Stats } from "./Stats";
19
18
  import { EntryNormalized, OutputNormalized, RspackOptionsNormalized, RspackPluginInstance } from "./config";
20
19
  import { rspack } from "./index";
21
- import * as liteTapable from "./lite-tapable";
22
20
  import ResolverFactory = require("./ResolverFactory");
23
21
  import Cache = require("./lib/Cache");
24
22
  import CacheFacade = require("./lib/CacheFacade");
25
- import { Source } from "webpack-sources";
23
+ import { Source } from "../compiled/webpack-sources";
26
24
  import { Chunk } from "./Chunk";
27
25
  import { FileSystemInfoEntry } from "./FileSystemInfo";
28
26
  import { NormalModuleFactory } from "./NormalModuleFactory";
@@ -39,35 +37,35 @@ export interface AssetEmittedInfo {
39
37
  declare class Compiler {
40
38
  #private;
41
39
  hooks: {
42
- done: tapable.AsyncSeriesHook<Stats>;
43
- afterDone: tapable.SyncHook<Stats>;
40
+ done: liteTapable.AsyncSeriesHook<Stats>;
41
+ afterDone: liteTapable.SyncHook<Stats>;
44
42
  thisCompilation: liteTapable.SyncHook<[Compilation, CompilationParams]>;
45
43
  compilation: liteTapable.SyncHook<[Compilation, CompilationParams]>;
46
- invalid: tapable.SyncHook<[string | null, number]>;
47
- compile: tapable.SyncHook<[CompilationParams]>;
48
- normalModuleFactory: tapable.SyncHook<NormalModuleFactory>;
49
- contextModuleFactory: tapable.SyncHook<ContextModuleFactory>;
50
- initialize: tapable.SyncHook<[]>;
44
+ invalid: liteTapable.SyncHook<[string | null, number]>;
45
+ compile: liteTapable.SyncHook<[CompilationParams]>;
46
+ normalModuleFactory: liteTapable.SyncHook<NormalModuleFactory>;
47
+ contextModuleFactory: liteTapable.SyncHook<ContextModuleFactory>;
48
+ initialize: liteTapable.SyncHook<[]>;
51
49
  shouldEmit: liteTapable.SyncBailHook<[Compilation], boolean>;
52
- infrastructureLog: tapable.SyncBailHook<[string, string, any[]], true>;
53
- beforeRun: tapable.AsyncSeriesHook<[Compiler]>;
54
- run: tapable.AsyncSeriesHook<[Compiler]>;
50
+ infrastructureLog: liteTapable.SyncBailHook<[string, string, any[]], true>;
51
+ beforeRun: liteTapable.AsyncSeriesHook<[Compiler]>;
52
+ run: liteTapable.AsyncSeriesHook<[Compiler]>;
55
53
  emit: liteTapable.AsyncSeriesHook<[Compilation]>;
56
54
  assetEmitted: liteTapable.AsyncSeriesHook<[string, AssetEmittedInfo]>;
57
55
  afterEmit: liteTapable.AsyncSeriesHook<[Compilation]>;
58
- failed: tapable.SyncHook<[Error]>;
59
- shutdown: tapable.AsyncSeriesHook<[]>;
60
- watchRun: tapable.AsyncSeriesHook<[Compiler]>;
61
- watchClose: tapable.SyncHook<[]>;
62
- environment: tapable.SyncHook<[]>;
63
- afterEnvironment: tapable.SyncHook<[]>;
64
- afterPlugins: tapable.SyncHook<[Compiler]>;
65
- afterResolvers: tapable.SyncHook<[Compiler]>;
56
+ failed: liteTapable.SyncHook<[Error]>;
57
+ shutdown: liteTapable.AsyncSeriesHook<[]>;
58
+ watchRun: liteTapable.AsyncSeriesHook<[Compiler]>;
59
+ watchClose: liteTapable.SyncHook<[]>;
60
+ environment: liteTapable.SyncHook<[]>;
61
+ afterEnvironment: liteTapable.SyncHook<[]>;
62
+ afterPlugins: liteTapable.SyncHook<[Compiler]>;
63
+ afterResolvers: liteTapable.SyncHook<[Compiler]>;
66
64
  make: liteTapable.AsyncParallelHook<[Compilation]>;
67
- beforeCompile: tapable.AsyncSeriesHook<[CompilationParams]>;
68
- afterCompile: tapable.AsyncSeriesHook<[Compilation]>;
65
+ beforeCompile: liteTapable.AsyncSeriesHook<[CompilationParams]>;
66
+ afterCompile: liteTapable.AsyncSeriesHook<[Compilation]>;
69
67
  finishMake: liteTapable.AsyncSeriesHook<[Compilation]>;
70
- entryOption: tapable.SyncBailHook<[string, EntryNormalized], any>;
68
+ entryOption: liteTapable.SyncBailHook<[string, EntryNormalized], any>;
71
69
  };
72
70
  webpack: typeof rspack;
73
71
  name?: string;
@@ -125,11 +123,11 @@ declare class Compiler {
125
123
  * @param handler - signals when the call finishes
126
124
  * @returns a compiler watcher
127
125
  */
128
- watch(watchOptions: Watchpack.WatchOptions, handler: Callback<Error, Stats>): Watching;
126
+ watch(watchOptions: Watchpack.WatchOptions, handler: liteTapable.Callback<Error, Stats>): Watching;
129
127
  /**
130
128
  * @param callback - signals when the call finishes
131
129
  */
132
- run(callback: Callback<Error, Stats>): void;
130
+ run(callback: liteTapable.Callback<Error, Stats>): void;
133
131
  runAsChild(callback: (err?: null | Error, entries?: Chunk[], compilation?: Compilation) => any): void;
134
132
  purgeInputFileSystem(): void;
135
133
  /**
@@ -142,7 +140,7 @@ declare class Compiler {
142
140
  */
143
141
  createChildCompiler(compilation: Compilation, compilerName: string, compilerIndex: number, outputOptions: OutputNormalized, plugins: RspackPluginInstance[]): Compiler;
144
142
  isChild(): boolean;
145
- compile(callback: Callback<Error, Compilation>): void;
143
+ compile(callback: liteTapable.Callback<Error, Compilation>): void;
146
144
  close(callback: (error?: Error | null) => void): void;
147
145
  /**
148
146
  * Note: This is not a webpack public API, maybe removed in future.
package/dist/Compiler.js CHANGED
@@ -49,15 +49,13 @@ exports.Compiler = void 0;
49
49
  * https://github.com/webpack/webpack/blob/main/LICENSE
50
50
  */
51
51
  const binding = __importStar(require("@rspack/binding"));
52
- const tapable = __importStar(require("tapable"));
53
- const tapable_1 = require("tapable");
52
+ const liteTapable = __importStar(require("@rspack/lite-tapable"));
54
53
  const Compilation_1 = require("./Compilation");
55
54
  const ContextModuleFactory_1 = require("./ContextModuleFactory");
56
55
  const RuleSetCompiler_1 = require("./RuleSetCompiler");
57
56
  const Stats_1 = require("./Stats");
58
57
  const config_1 = require("./config");
59
58
  const index_1 = require("./index");
60
- const liteTapable = __importStar(require("./lite-tapable"));
61
59
  const ResolverFactory = require("./ResolverFactory");
62
60
  const FileSystem_1 = require("./FileSystem");
63
61
  const ConcurrentCompilationError_1 = __importDefault(require("./error/ConcurrentCompilationError"));
@@ -97,12 +95,12 @@ class Compiler {
97
95
  __classPrivateFieldSet(this, _Compiler_moduleExecutionResultsMap, new Map(), "f");
98
96
  __classPrivateFieldSet(this, _Compiler_ruleSet, new RuleSetCompiler_1.RuleSetCompiler(), "f");
99
97
  this.hooks = {
100
- initialize: new tapable_1.SyncHook([]),
98
+ initialize: new liteTapable.SyncHook([]),
101
99
  shouldEmit: new liteTapable.SyncBailHook(["compilation"]),
102
- done: new tapable.AsyncSeriesHook(["stats"]),
103
- afterDone: new tapable.SyncHook(["stats"]),
104
- beforeRun: new tapable.AsyncSeriesHook(["compiler"]),
105
- run: new tapable.AsyncSeriesHook(["compiler"]),
100
+ done: new liteTapable.AsyncSeriesHook(["stats"]),
101
+ afterDone: new liteTapable.SyncHook(["stats"]),
102
+ beforeRun: new liteTapable.AsyncSeriesHook(["compiler"]),
103
+ run: new liteTapable.AsyncSeriesHook(["compiler"]),
106
104
  emit: new liteTapable.AsyncSeriesHook(["compilation"]),
107
105
  assetEmitted: new liteTapable.AsyncSeriesHook(["file", "info"]),
108
106
  afterEmit: new liteTapable.AsyncSeriesHook(["compilation"]),
@@ -111,28 +109,32 @@ class Compiler {
111
109
  "compilation",
112
110
  "params"
113
111
  ]),
114
- invalid: new tapable_1.SyncHook(["filename", "changeTime"]),
115
- compile: new tapable_1.SyncHook(["params"]),
116
- infrastructureLog: new tapable_1.SyncBailHook(["origin", "type", "args"]),
117
- failed: new tapable_1.SyncHook(["error"]),
118
- shutdown: new tapable.AsyncSeriesHook([]),
119
- normalModuleFactory: new tapable.SyncHook([
112
+ invalid: new liteTapable.SyncHook(["filename", "changeTime"]),
113
+ compile: new liteTapable.SyncHook(["params"]),
114
+ infrastructureLog: new liteTapable.SyncBailHook([
115
+ "origin",
116
+ "type",
117
+ "args"
118
+ ]),
119
+ failed: new liteTapable.SyncHook(["error"]),
120
+ shutdown: new liteTapable.AsyncSeriesHook([]),
121
+ normalModuleFactory: new liteTapable.SyncHook([
120
122
  "normalModuleFactory"
121
123
  ]),
122
- contextModuleFactory: new tapable.SyncHook([
124
+ contextModuleFactory: new liteTapable.SyncHook([
123
125
  "contextModuleFactory"
124
126
  ]),
125
- watchRun: new tapable.AsyncSeriesHook(["compiler"]),
126
- watchClose: new tapable.SyncHook([]),
127
- environment: new tapable.SyncHook([]),
128
- afterEnvironment: new tapable.SyncHook([]),
129
- afterPlugins: new tapable.SyncHook(["compiler"]),
130
- afterResolvers: new tapable.SyncHook(["compiler"]),
127
+ watchRun: new liteTapable.AsyncSeriesHook(["compiler"]),
128
+ watchClose: new liteTapable.SyncHook([]),
129
+ environment: new liteTapable.SyncHook([]),
130
+ afterEnvironment: new liteTapable.SyncHook([]),
131
+ afterPlugins: new liteTapable.SyncHook(["compiler"]),
132
+ afterResolvers: new liteTapable.SyncHook(["compiler"]),
131
133
  make: new liteTapable.AsyncParallelHook(["compilation"]),
132
- beforeCompile: new tapable.AsyncSeriesHook(["params"]),
133
- afterCompile: new tapable.AsyncSeriesHook(["compilation"]),
134
+ beforeCompile: new liteTapable.AsyncSeriesHook(["params"]),
135
+ afterCompile: new liteTapable.AsyncSeriesHook(["compilation"]),
134
136
  finishMake: new liteTapable.AsyncSeriesHook(["compilation"]),
135
- entryOption: new tapable.SyncBailHook(["context", "entry"])
137
+ entryOption: new liteTapable.SyncBailHook(["context", "entry"])
136
138
  };
137
139
  this.webpack = index_1.rspack;
138
140
  this.root = this;
@@ -652,16 +654,27 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
652
654
  __classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").set(id, executeResult);
653
655
  }),
654
656
  registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationFinishModules, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.finishModules, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f").modules)),
655
- registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeModules, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.optimizeModules, queried => () => queried.call(__classPrivateFieldGet(this, _Compiler_compilation, "f").modules)),
656
- registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterOptimizeModules, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.afterOptimizeModules, queried => () => queried.call(__classPrivateFieldGet(this, _Compiler_compilation, "f").modules)),
657
+ registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeModules, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.optimizeModules, queried => () => queried.call(__classPrivateFieldGet(this, _Compiler_compilation, "f").modules.values())),
658
+ registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterOptimizeModules, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.afterOptimizeModules, queried => () => {
659
+ queried.call(__classPrivateFieldGet(this, _Compiler_compilation, "f").modules.values());
660
+ }),
657
661
  registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeTree, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.optimizeTree, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f").chunks, __classPrivateFieldGet(this, _Compiler_compilation, "f").modules)),
658
662
  registerCompilationOptimizeChunkModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeChunkModules, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.optimizeChunkModules, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f").chunks, __classPrivateFieldGet(this, _Compiler_compilation, "f").modules)),
663
+ registerCompilationChunkHashTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkHash, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.chunkHash, queried => (chunk) => {
664
+ const hash = (0, createHash_1.createHash)(this.options.output.hashFunction);
665
+ queried.call(Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compiler_compilation, "f")), hash);
666
+ const digestResult = hash.digest(this.options.output.hashDigest);
667
+ return Buffer.from(digestResult);
668
+ }),
659
669
  registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkAsset, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.chunkAsset, queried => ({ chunk, filename }) => queried.call(Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compiler_compilation, "f")), filename)),
660
670
  registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationProcessAssets, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.processAssets, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f").assets)),
661
671
  registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.afterProcessAssets, queried => () => queried.call(__classPrivateFieldGet(this, _Compiler_compilation, "f").assets)),
662
672
  registerCompilationAfterSealTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterSeal, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.afterSeal, queried => async () => await queried.promise()),
663
673
  registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
664
674
  const normalizedResolveData = {
675
+ contextInfo: {
676
+ issuer: resolveData.issuer
677
+ },
665
678
  request: resolveData.request,
666
679
  context: resolveData.context,
667
680
  fileDependencies: [],
@@ -673,6 +686,38 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
673
686
  resolveData.context = normalizedResolveData.context;
674
687
  return [ret, resolveData];
675
688
  }),
689
+ registerNormalModuleFactoryFactorizeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryFactorize, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.factorize, queried => async (resolveData) => {
690
+ const normalizedResolveData = {
691
+ contextInfo: {
692
+ issuer: resolveData.issuer
693
+ },
694
+ request: resolveData.request,
695
+ context: resolveData.context,
696
+ fileDependencies: [],
697
+ missingDependencies: [],
698
+ contextDependencies: []
699
+ };
700
+ await queried.promise(normalizedResolveData);
701
+ resolveData.request = normalizedResolveData.request;
702
+ resolveData.context = normalizedResolveData.context;
703
+ return resolveData;
704
+ }),
705
+ registerNormalModuleFactoryResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.resolve, queried => async (resolveData) => {
706
+ const normalizedResolveData = {
707
+ contextInfo: {
708
+ issuer: resolveData.issuer
709
+ },
710
+ request: resolveData.request,
711
+ context: resolveData.context,
712
+ fileDependencies: [],
713
+ missingDependencies: [],
714
+ contextDependencies: []
715
+ };
716
+ await queried.promise(normalizedResolveData);
717
+ resolveData.request = normalizedResolveData.request;
718
+ resolveData.context = normalizedResolveData.context;
719
+ return resolveData;
720
+ }),
676
721
  registerNormalModuleFactoryResolveForSchemeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookMapRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryResolveForScheme, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.resolveForScheme, queried => async (args) => {
677
722
  const ret = await queried
678
723
  .for(args.scheme)
@@ -681,6 +726,9 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
681
726
  }),
682
727
  registerNormalModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryAfterResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.afterResolve, queried => async (arg) => {
683
728
  const data = {
729
+ contextInfo: {
730
+ issuer: arg.issuer
731
+ },
684
732
  request: arg.request,
685
733
  context: arg.context,
686
734
  fileDependencies: arg.fileDependencies,
@@ -1,5 +1,5 @@
1
+ import * as liteTapable from "@rspack/lite-tapable";
1
2
  import { ContextModuleFactoryAfterResolveResult, ContextModuleFactoryBeforeResolveResult } from "./Module";
2
- import * as liteTapable from "./lite-tapable";
3
3
  export declare class ContextModuleFactory {
4
4
  hooks: {
5
5
  beforeResolve: liteTapable.AsyncSeriesWaterfallHook<[
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.ContextModuleFactory = void 0;
27
- const liteTapable = __importStar(require("./lite-tapable"));
27
+ const liteTapable = __importStar(require("@rspack/lite-tapable"));
28
28
  class ContextModuleFactory {
29
29
  constructor() {
30
30
  this.hooks = {
@@ -4,5 +4,5 @@ import { ChunkGroup } from "./ChunkGroup";
4
4
  export declare class Entrypoint extends ChunkGroup {
5
5
  static __from_binding(chunk: JsChunkGroup, compilation: JsCompilation): Entrypoint;
6
6
  protected constructor(inner: JsChunkGroup, compilation: JsCompilation);
7
- getRuntimeChunk(): Chunk | null;
7
+ getRuntimeChunk(): Readonly<Chunk | null>;
8
8
  }
@@ -12,9 +12,9 @@ class Entrypoint extends ChunkGroup_1.ChunkGroup {
12
12
  super(inner, compilation);
13
13
  }
14
14
  getRuntimeChunk() {
15
- const c = (0, binding_1.__entrypoint_inner_get_runtime_chunk)(this.__internal_innerUkey(), this.__internal_innerCompilation());
15
+ const c = (0, binding_1.__entrypoint_inner_get_runtime_chunk)(this.__internal__innerUkey(), this.__internal__innerCompilation());
16
16
  if (c)
17
- return Chunk_1.Chunk.__from_binding(c, this.__internal_innerCompilation());
17
+ return Chunk_1.Chunk.__from_binding(c, this.__internal__innerCompilation());
18
18
  return null;
19
19
  }
20
20
  }
package/dist/Module.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { JsCodegenerationResult, JsCodegenerationResults, JsCreateData, JsModule } from "@rspack/binding";
2
- import { Source } from "webpack-sources";
1
+ import { JsCodegenerationResult, JsCodegenerationResults, JsCreateData, JsFactoryMeta, JsModule } from "@rspack/binding";
2
+ import { Source } from "../compiled/webpack-sources";
3
3
  import { Compilation } from "./Compilation";
4
4
  export type ResourceData = {
5
5
  resource: string;
@@ -11,7 +11,11 @@ export type ResourceDataWithData = ResourceData & {
11
11
  data?: Record<string, any>;
12
12
  };
13
13
  export type CreateData = Partial<JsCreateData>;
14
+ export type ContextInfo = {
15
+ issuer: string;
16
+ };
14
17
  export type ResolveData = {
18
+ contextInfo: ContextInfo;
15
19
  context: string;
16
20
  request: string;
17
21
  fileDependencies: string[];
@@ -32,11 +36,12 @@ export type ContextModuleFactoryAfterResolveResult = false | {
32
36
  };
33
37
  export declare class Module {
34
38
  #private;
35
- context?: string;
36
- resource?: string;
37
- request?: string;
38
- userRequest?: string;
39
- rawRequest?: string;
39
+ context?: Readonly<string>;
40
+ resource?: Readonly<string>;
41
+ request?: Readonly<string>;
42
+ userRequest?: Readonly<string>;
43
+ rawRequest?: Readonly<string>;
44
+ factoryMeta?: Readonly<JsFactoryMeta>;
40
45
  /**
41
46
  * Records the dynamically added fields for Module on the JavaScript side.
42
47
  * These fields are generally used within a plugin, so they do not need to be passed back to the Rust side.
package/dist/Module.js CHANGED
@@ -27,6 +27,7 @@ class Module {
27
27
  this.request = module.request;
28
28
  this.userRequest = module.userRequest;
29
29
  this.rawRequest = module.rawRequest;
30
+ this.factoryMeta = module.factoryMeta;
30
31
  const customModule = compilation?.__internal__getCustomModule(module.moduleIdentifier);
31
32
  this.buildInfo = customModule?.buildInfo || {};
32
33
  this.buildMeta = customModule?.buildMeta || {};
@@ -7,7 +7,7 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
- import { AsyncSeriesHook, Callback, MultiHook, SyncBailHook, SyncHook } from "tapable";
10
+ import * as liteTapable from "@rspack/lite-tapable";
11
11
  import { Compiler, RspackOptions } from ".";
12
12
  import MultiStats from "./MultiStats";
13
13
  import MultiWatching from "./MultiWatching";
@@ -25,12 +25,12 @@ export declare class MultiCompiler {
25
25
  compilers: Compiler[];
26
26
  dependencies: WeakMap<Compiler, string[]>;
27
27
  hooks: {
28
- done: SyncHook<MultiStats>;
29
- invalid: MultiHook<SyncHook<[string | null, number]>>;
30
- run: MultiHook<AsyncSeriesHook<[Compiler]>>;
31
- watchClose: SyncHook<[]>;
32
- watchRun: MultiHook<AsyncSeriesHook<[Compiler]>>;
33
- infrastructureLog: MultiHook<SyncBailHook<[string, string, any[]], true>>;
28
+ done: liteTapable.SyncHook<MultiStats>;
29
+ invalid: liteTapable.MultiHook<liteTapable.SyncHook<[string | null, number]>>;
30
+ run: liteTapable.MultiHook<liteTapable.AsyncSeriesHook<[Compiler]>>;
31
+ watchClose: liteTapable.SyncHook<[]>;
32
+ watchRun: liteTapable.MultiHook<liteTapable.AsyncSeriesHook<[Compiler]>>;
33
+ infrastructureLog: liteTapable.MultiHook<liteTapable.SyncBailHook<[string, string, any[]], true>>;
34
34
  };
35
35
  _options: MultiCompilerOptions;
36
36
  running: boolean;
@@ -55,14 +55,14 @@ export declare class MultiCompiler {
55
55
  * @param callback - signals when the validation is complete
56
56
  * @returns true if the dependencies are valid
57
57
  */
58
- validateDependencies(callback: Callback<Error, MultiStats>): boolean;
58
+ validateDependencies(callback: liteTapable.Callback<Error, MultiStats>): boolean;
59
59
  /**
60
60
  * @param watchOptions - the watcher's options
61
61
  * @param handler - signals when the call finishes
62
62
  * @returns a compiler watcher
63
63
  */
64
- watch(watchOptions: WatchOptions, handler: Callback<Error, MultiStats>): MultiWatching;
65
- run(callback: Callback<Error, MultiStats>): void;
64
+ watch(watchOptions: WatchOptions, handler: liteTapable.Callback<Error, MultiStats>): MultiWatching;
65
+ run(callback: liteTapable.Callback<Error, MultiStats>): void;
66
66
  purgeInputFileSystem(): void;
67
- close(callback: Callback<Error, void>): void;
67
+ close(callback: liteTapable.Callback<Error, void>): void;
68
68
  }
@@ -8,6 +8,29 @@
8
8
  * Copyright (c) JS Foundation and other contributors
9
9
  * https://github.com/webpack/webpack/blob/main/LICENSE
10
10
  */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
11
34
  var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
35
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
36
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
@@ -19,8 +42,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
42
  var _MultiCompiler_instances, _MultiCompiler_runGraph;
20
43
  Object.defineProperty(exports, "__esModule", { value: true });
21
44
  exports.MultiCompiler = void 0;
45
+ const liteTapable = __importStar(require("@rspack/lite-tapable"));
22
46
  const neo_async_1 = __importDefault(require("../compiled/neo-async"));
23
- const tapable_1 = require("tapable");
24
47
  const MultiStats_1 = __importDefault(require("./MultiStats"));
25
48
  const MultiWatching_1 = __importDefault(require("./MultiWatching"));
26
49
  const ConcurrentCompilationError_1 = __importDefault(require("./error/ConcurrentCompilationError"));
@@ -35,18 +58,12 @@ class MultiCompiler {
35
58
  });
36
59
  }
37
60
  this.hooks = {
38
- /** @type {SyncHook<[MultiStats]>} */
39
- done: new tapable_1.SyncHook(["stats"]),
40
- /** @type {MultiHook<SyncHook<[string | null, number]>>} */
41
- invalid: new tapable_1.MultiHook(compilers.map(c => c.hooks.invalid)),
42
- /** @type {MultiHook<AsyncSeriesHook<[Compiler]>>} */
43
- run: new tapable_1.MultiHook(compilers.map(c => c.hooks.run)),
44
- /** @type {SyncHook<[]>} */
45
- watchClose: new tapable_1.SyncHook([]),
46
- /** @type {MultiHook<AsyncSeriesHook<[Compiler]>>} */
47
- watchRun: new tapable_1.MultiHook(compilers.map(c => c.hooks.watchRun)),
48
- /** @type {MultiHook<SyncBailHook<[string, string, any[]], true>>} */
49
- infrastructureLog: new tapable_1.MultiHook(compilers.map(c => c.hooks.infrastructureLog))
61
+ done: new liteTapable.SyncHook(["stats"]),
62
+ invalid: new liteTapable.MultiHook(compilers.map(c => c.hooks.invalid)),
63
+ run: new liteTapable.MultiHook(compilers.map(c => c.hooks.run)),
64
+ watchClose: new liteTapable.SyncHook([]),
65
+ watchRun: new liteTapable.MultiHook(compilers.map(c => c.hooks.watchRun)),
66
+ infrastructureLog: new liteTapable.MultiHook(compilers.map(c => c.hooks.infrastructureLog))
50
67
  };
51
68
  this.compilers = compilers;
52
69
  this._options = {
@@ -1,12 +1,15 @@
1
1
  /// <reference types="node" />
2
- import { AsyncSeriesBailHook, HookMap, SyncHook } from "tapable";
2
+ import * as liteTapable from "@rspack/lite-tapable";
3
3
  import { Compilation } from "./Compilation";
4
4
  import { LoaderContext } from "./config";
5
5
  export declare class NormalModule {
6
- constructor();
7
6
  static getCompilationHooks(compilation: Compilation): {
8
- loader: SyncHook<[LoaderContext<{}>], void, import("tapable").UnsetAdditionalOptions>;
7
+ loader: liteTapable.SyncHook<[LoaderContext<{}>], void, {
8
+ _UnsetAdditionalOptions: true;
9
+ }>;
9
10
  readResourceForScheme: any;
10
- readResource: HookMap<AsyncSeriesBailHook<[LoaderContext<{}>], string | Buffer, import("tapable").UnsetAdditionalOptions>>;
11
+ readResource: liteTapable.HookMap<liteTapable.AsyncSeriesBailHook<[LoaderContext<{}>], string | Buffer, {
12
+ _UnsetAdditionalOptions: true;
13
+ }>>;
11
14
  };
12
15
  }
@@ -1,11 +1,34 @@
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
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.NormalModule = void 0;
7
30
  const util_1 = __importDefault(require("util"));
8
- const tapable_1 = require("tapable");
31
+ const liteTapable = __importStar(require("@rspack/lite-tapable"));
9
32
  const Compilation_1 = require("./Compilation");
10
33
  const compilationHooksMap = new WeakMap();
11
34
  const createFakeHook = (fakeHook, message, code) => {
@@ -46,10 +69,7 @@ const deprecateAllProperties = (obj, message, code) => {
46
69
  }
47
70
  return newObj;
48
71
  };
49
- // Actually it is just a NormalModule proxy, used for hooks api alignment
50
- // Maybe we can 1:1 align to webpack NormalModule once we found a better way to reduce communicate overhead between rust and js
51
72
  class NormalModule {
52
- constructor() { }
53
73
  static getCompilationHooks(compilation) {
54
74
  if (!(compilation instanceof Compilation_1.Compilation)) {
55
75
  throw new TypeError("The 'compilation' argument must be an instance of Compilation");
@@ -57,12 +77,9 @@ class NormalModule {
57
77
  let hooks = compilationHooksMap.get(compilation);
58
78
  if (hooks === undefined) {
59
79
  hooks = {
60
- loader: new tapable_1.SyncHook(["loaderContext"]),
61
- // beforeLoaders: new SyncHook(["loaders", "module", "loaderContext"]),
62
- // beforeParse: new SyncHook(["module"]),
63
- // beforeSnapshot: new SyncHook(["module"]),
80
+ loader: new liteTapable.SyncHook(["loaderContext"]),
64
81
  // TODO webpack 6 deprecate
65
- readResourceForScheme: new tapable_1.HookMap(scheme => {
82
+ readResourceForScheme: new liteTapable.HookMap(scheme => {
66
83
  const hook = hooks.readResource.for(scheme);
67
84
  return createFakeHook({
68
85
  tap: (options, fn) => hook.tap(options, (loaderContext) => fn(loaderContext.resource)),
@@ -70,8 +87,7 @@ class NormalModule {
70
87
  tapPromise: (options, fn) => hook.tapPromise(options, (loaderContext) => fn(loaderContext.resource))
71
88
  });
72
89
  }),
73
- readResource: new tapable_1.HookMap(() => new tapable_1.AsyncSeriesBailHook(["loaderContext"]))
74
- // needBuild: new AsyncSeriesBailHook(["module", "context"])
90
+ readResource: new liteTapable.HookMap(() => new liteTapable.AsyncSeriesBailHook(["loaderContext"]))
75
91
  };
76
92
  compilationHooksMap.set(compilation, hooks);
77
93
  }
@@ -1,6 +1,6 @@
1
1
  import type * as binding from "@rspack/binding";
2
+ import * as liteTapable from "@rspack/lite-tapable";
2
3
  import { ResolveData, ResourceDataWithData } from "./Module";
3
- import * as liteTapable from "./lite-tapable";
4
4
  export type NormalModuleCreateData = binding.JsNormalModuleFactoryCreateModuleArgs & {
5
5
  settings: {};
6
6
  };
@@ -8,6 +8,8 @@ export declare class NormalModuleFactory {
8
8
  hooks: {
9
9
  resolveForScheme: liteTapable.HookMap<liteTapable.AsyncSeriesBailHook<[ResourceDataWithData], true | void>>;
10
10
  beforeResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>;
11
+ factorize: liteTapable.AsyncSeriesBailHook<[ResolveData], void>;
12
+ resolve: liteTapable.AsyncSeriesBailHook<[ResolveData], void>;
11
13
  afterResolve: liteTapable.AsyncSeriesBailHook<[ResolveData], false | void>;
12
14
  createModule: liteTapable.AsyncSeriesBailHook<[
13
15
  NormalModuleCreateData,
@@ -24,39 +24,19 @@ 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 liteTapable = __importStar(require("./lite-tapable"));
27
+ const liteTapable = __importStar(require("@rspack/lite-tapable"));
28
28
  class NormalModuleFactory {
29
29
  constructor() {
30
30
  this.hooks = {
31
- // /** @type {AsyncSeriesBailHook<[ResolveData], Module | false | void>} */
32
- // resolve: new AsyncSeriesBailHook(["resolveData"]),
33
- // /** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>>} */
34
31
  resolveForScheme: new liteTapable.HookMap(() => new liteTapable.AsyncSeriesBailHook(["resourceData"])),
35
- // /** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>>} */
36
- // resolveInScheme: new HookMap(
37
- // () => new AsyncSeriesBailHook(["resourceData", "resolveData"])
38
- // ),
39
- // /** @type {AsyncSeriesBailHook<[ResolveData], Module>} */
40
- // factorize: new AsyncSeriesBailHook(["resolveData"]),
41
- // /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
42
32
  beforeResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
43
- // /** @type {AsyncSeriesBailHook<[ResolveData], false | void>} */
33
+ factorize: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
34
+ resolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
44
35
  afterResolve: new liteTapable.AsyncSeriesBailHook(["resolveData"]),
45
- // /** @type {AsyncSeriesBailHook<[ResolveData["createData"], ResolveData], Module | void>} */
46
36
  createModule: new liteTapable.AsyncSeriesBailHook([
47
37
  "createData",
48
38
  "resolveData"
49
39
  ])
50
- // /** @type {SyncWaterfallHook<[Module, ResolveData["createData"], ResolveData], Module>} */
51
- // module: new SyncWaterfallHook(["module", "createData", "resolveData"]),
52
- // createParser: new HookMap(() => new SyncBailHook(["parserOptions"])),
53
- // parser: new HookMap(() => new SyncHook(["parser", "parserOptions"])),
54
- // createGenerator: new HookMap(
55
- // () => new SyncBailHook(["generatorOptions"])
56
- // ),
57
- // generator: new HookMap(
58
- // () => new SyncHook(["generator", "generatorOptions"])
59
- // )
60
40
  };
61
41
  }
62
42
  }