@rspack/core 0.6.5-canary-6d6fcd3-20240514084813 → 0.6.5-canary-231c64e-20240515075232
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chunk.d.ts +1 -1
- package/dist/Chunk.js +1 -1
- package/dist/ChunkGroup.d.ts +1 -1
- package/dist/ChunkGroup.js +3 -3
- package/dist/Compilation.d.ts +46 -65
- package/dist/Compilation.js +128 -222
- package/dist/Compiler.d.ts +75 -44
- package/dist/Compiler.js +325 -278
- package/dist/ContextModuleFactory.d.ts +7 -3
- package/dist/ContextModuleFactory.js +2 -2
- package/dist/Entrypoint.d.ts +1 -1
- package/dist/Entrypoint.js +1 -1
- package/dist/ExecuteModulePlugin.js +1 -1
- package/dist/Module.d.ts +11 -0
- package/dist/Module.js +2 -2
- package/dist/MultiCompiler.d.ts +10 -25
- package/dist/MultiCompiler.js +3 -3
- package/dist/MultiStats.d.ts +1 -1
- package/dist/NormalModuleFactory.d.ts +1 -1
- package/dist/Stats.d.ts +2 -2
- package/dist/Watching.d.ts +0 -9
- package/dist/Watching.js +12 -2
- package/dist/builtin-loader/swc/index.d.ts +6 -6
- package/dist/builtin-loader/swc/index.js +3 -3
- package/dist/builtin-loader/swc/types.d.ts +2 -2
- package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/BannerPlugin.d.ts +2 -2
- package/dist/builtin-plugin/BannerPlugin.js +1 -1
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DynamicEntryPlugin.js +1 -1
- package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EntryPlugin.js +1 -1
- package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +2 -2
- package/dist/builtin-plugin/HtmlRspackPlugin.js +2 -2
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
- package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +1 -1
- package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
- package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
- package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SplitChunksPlugin.d.ts +2 -2
- package/dist/builtin-plugin/SplitChunksPlugin.js +4 -4
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
- package/dist/builtin-plugin/WorkerPlugin.d.ts +2 -2
- package/dist/builtin-plugin/base.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/index.d.ts +5 -4
- package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/loader.js +2 -2
- package/dist/builtin-plugin/index.d.ts +43 -43
- package/dist/builtin-plugin/index.js +43 -43
- package/dist/config/adapter.d.ts +2 -2
- package/dist/config/adapterRuleUse.d.ts +2 -1
- package/dist/config/adapterRuleUse.js +2 -2
- package/dist/config/defaults.js +3 -3
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -2
- package/dist/config/normalization.d.ts +1 -1
- package/dist/config/zod.d.ts +169 -176
- package/dist/config/zod.js +2 -15
- package/dist/container/ContainerPlugin.d.ts +1 -1
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/container/ContainerReferencePlugin.js +1 -1
- package/dist/container/ModuleFederationPlugin.js +1 -1
- package/dist/container/ModuleFederationPluginV1.d.ts +1 -1
- package/dist/container/ModuleFederationPluginV1.js +1 -1
- package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
- package/dist/exports.d.ts +34 -30
- package/dist/exports.js +21 -18
- package/dist/fileSystem.d.ts +12 -8
- package/dist/fileSystem.js +25 -48
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lite-tapable/index.d.ts +6 -0
- package/dist/lite-tapable/index.js +107 -1
- package/dist/loader-runner/index.js +13 -13
- package/dist/logging/Logger.d.ts +1 -1
- package/dist/logging/createConsoleLogger.js +0 -14
- package/dist/node/NodeEnvironmentPlugin.d.ts +1 -1
- package/dist/node/NodeEnvironmentPlugin.js +1 -1
- package/dist/node/nodeConsole.js +0 -4
- package/dist/rspack.d.ts +4 -13
- package/dist/rspack.js +8 -8
- package/dist/rspackOptionsApply.d.ts +1 -10
- package/dist/rspackOptionsApply.js +14 -5
- package/dist/sharing/ConsumeSharedPlugin.d.ts +1 -1
- package/dist/sharing/ConsumeSharedPlugin.js +1 -1
- package/dist/stats/DefaultStatsFactoryPlugin.js +2 -2
- package/dist/stats/StatsFactory.d.ts +2 -2
- package/dist/stats/StatsFactory.js +0 -9
- package/dist/stats/StatsPrinter.d.ts +1 -1
- package/dist/stats/statsFactoryUtils.d.ts +1 -1
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/fs.d.ts +64 -0
- package/dist/util/fs.js +122 -0
- package/dist/util/index.d.ts +2 -1
- package/dist/util/index.js +16 -11
- package/dist/util/source.d.ts +18 -0
- package/dist/util/source.js +66 -0
- package/package.json +4 -4
- package/dist/util/createSource.d.ts +0 -5
- package/dist/util/createSource.js +0 -65
package/dist/Compiler.js
CHANGED
|
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
|
-
var _Compiler_instances, _Compiler_instance, _Compiler_initial,
|
|
39
|
+
var _Compiler_instances, _Compiler_instance, _Compiler_initial, _Compiler_compilation, _Compiler_compilationParams, _Compiler_builtinPlugins, _Compiler_moduleExecutionResultsMap, _Compiler_nonSkippableRegisters, _Compiler_registers, _Compiler_ruleSet, _Compiler_build, _Compiler_createCompilation, _Compiler_resetThisCompilation, _Compiler_newCompilationParams, _Compiler_getInstance, _Compiler_updateNonSkippableRegisters, _Compiler_decorateJsTaps, _Compiler_createHookRegisterTaps, _Compiler_createHookMapRegisterTaps;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.Compiler = void 0;
|
|
42
42
|
/**
|
|
@@ -49,58 +49,52 @@ 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 index_1 = require("./index");
|
|
53
|
-
const fs_1 = __importDefault(require("fs"));
|
|
54
52
|
const tapable = __importStar(require("tapable"));
|
|
55
|
-
const liteTapable = __importStar(require("./lite-tapable"));
|
|
56
53
|
const tapable_1 = require("tapable");
|
|
54
|
+
const Compilation_1 = require("./Compilation");
|
|
57
55
|
const config_1 = require("./config");
|
|
56
|
+
const ContextModuleFactory_1 = require("./ContextModuleFactory");
|
|
57
|
+
const index_1 = require("./index");
|
|
58
|
+
const liteTapable = __importStar(require("./lite-tapable"));
|
|
58
59
|
const RuleSetCompiler_1 = require("./RuleSetCompiler");
|
|
59
60
|
const Stats_1 = require("./Stats");
|
|
60
|
-
const Compilation_1 = require("./Compilation");
|
|
61
|
-
const ContextModuleFactory_1 = require("./ContextModuleFactory");
|
|
62
61
|
const ResolverFactory = require("./ResolverFactory");
|
|
63
62
|
const ConcurrentCompilationError_1 = __importDefault(require("./error/ConcurrentCompilationError"));
|
|
64
63
|
const fileSystem_1 = require("./fileSystem");
|
|
65
64
|
const Cache = require("./lib/Cache");
|
|
66
65
|
const CacheFacade = require("./lib/CacheFacade");
|
|
67
|
-
const Logger_1 = require("./logging/Logger");
|
|
68
|
-
const NormalModuleFactory_1 = require("./NormalModuleFactory");
|
|
69
|
-
const bindingVersionCheck_1 = require("./util/bindingVersionCheck");
|
|
70
|
-
const Watching_1 = require("./Watching");
|
|
71
66
|
const builtin_plugin_1 = require("./builtin-plugin");
|
|
67
|
+
const base_1 = require("./builtin-plugin/base");
|
|
68
|
+
const Chunk_1 = require("./Chunk");
|
|
72
69
|
const defaults_1 = require("./config/defaults");
|
|
73
|
-
const
|
|
74
|
-
const RuntimeGlobals_1 = require("./RuntimeGlobals");
|
|
70
|
+
const ExecuteModulePlugin_1 = __importDefault(require("./ExecuteModulePlugin"));
|
|
75
71
|
const HookWebpackError_1 = require("./lib/HookWebpackError");
|
|
72
|
+
const Logger_1 = require("./logging/Logger");
|
|
76
73
|
const Module_1 = require("./Module");
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
74
|
+
const NormalModuleFactory_1 = require("./NormalModuleFactory");
|
|
75
|
+
const RuntimeGlobals_1 = require("./RuntimeGlobals");
|
|
76
|
+
const util_1 = require("./util");
|
|
77
|
+
const assertNotNil_1 = require("./util/assertNotNil");
|
|
78
|
+
const bindingVersionCheck_1 = require("./util/bindingVersionCheck");
|
|
79
|
+
const identifier_1 = require("./util/identifier");
|
|
80
|
+
const Watching_1 = require("./Watching");
|
|
80
81
|
class Compiler {
|
|
81
82
|
constructor(context, options) {
|
|
82
83
|
_Compiler_instances.add(this);
|
|
83
84
|
_Compiler_instance.set(this, void 0);
|
|
84
|
-
this
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
_Compiler_initial.set(this, void 0);
|
|
86
|
+
_Compiler_compilation.set(this, void 0);
|
|
87
|
+
_Compiler_compilationParams.set(this, void 0);
|
|
88
|
+
_Compiler_builtinPlugins.set(this, void 0);
|
|
89
|
+
_Compiler_moduleExecutionResultsMap.set(this, void 0);
|
|
88
90
|
_Compiler_nonSkippableRegisters.set(this, void 0);
|
|
89
91
|
_Compiler_registers.set(this, void 0);
|
|
90
|
-
|
|
91
|
-
this
|
|
92
|
-
this
|
|
93
|
-
this
|
|
94
|
-
this
|
|
95
|
-
this.
|
|
96
|
-
this.root = this;
|
|
97
|
-
this.ruleSet = new RuleSetCompiler_1.RuleSetCompiler();
|
|
98
|
-
this.running = false;
|
|
99
|
-
this.idle = false;
|
|
100
|
-
this.context = context;
|
|
101
|
-
this.resolverFactory = new ResolverFactory();
|
|
102
|
-
this.modifiedFiles = undefined;
|
|
103
|
-
this.removedFiles = undefined;
|
|
92
|
+
_Compiler_ruleSet.set(this, void 0);
|
|
93
|
+
__classPrivateFieldSet(this, _Compiler_initial, true, "f");
|
|
94
|
+
__classPrivateFieldSet(this, _Compiler_builtinPlugins, [], "f");
|
|
95
|
+
__classPrivateFieldSet(this, _Compiler_nonSkippableRegisters, [], "f");
|
|
96
|
+
__classPrivateFieldSet(this, _Compiler_moduleExecutionResultsMap, new Map(), "f");
|
|
97
|
+
__classPrivateFieldSet(this, _Compiler_ruleSet, new RuleSetCompiler_1.RuleSetCompiler(), "f");
|
|
104
98
|
this.hooks = {
|
|
105
99
|
initialize: new tapable_1.SyncHook([]),
|
|
106
100
|
shouldEmit: new liteTapable.SyncBailHook(["compilation"]),
|
|
@@ -139,14 +133,54 @@ class Compiler {
|
|
|
139
133
|
finishMake: new liteTapable.AsyncSeriesHook(["compilation"]),
|
|
140
134
|
entryOption: new tapable.SyncBailHook(["context", "entry"])
|
|
141
135
|
};
|
|
142
|
-
this.
|
|
143
|
-
this.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
136
|
+
this.webpack = index_1.rspack;
|
|
137
|
+
this.root = this;
|
|
138
|
+
this.outputPath = "";
|
|
139
|
+
this.inputFileSystem = null;
|
|
140
|
+
this.intermediateFileSystem = null;
|
|
141
|
+
this.outputFileSystem = null;
|
|
142
|
+
this.watchFileSystem = null;
|
|
143
|
+
this.records = {};
|
|
144
|
+
this.resolverFactory = new ResolverFactory();
|
|
145
|
+
this.options = options;
|
|
146
|
+
this.context = context;
|
|
147
|
+
this.cache = new Cache();
|
|
148
|
+
this.compilerPath = "";
|
|
149
|
+
this.running = false;
|
|
150
|
+
this.idle = false;
|
|
151
|
+
this.watchMode = false;
|
|
147
152
|
new builtin_plugin_1.JsLoaderRspackPlugin(this).apply(this);
|
|
148
153
|
new ExecuteModulePlugin_1.default().apply(this);
|
|
149
154
|
}
|
|
155
|
+
get recordsInputPath() {
|
|
156
|
+
return (0, util_1.unsupported)("Compiler.recordsInputPath");
|
|
157
|
+
}
|
|
158
|
+
get recordsOutputPath() {
|
|
159
|
+
return (0, util_1.unsupported)("Compiler.recordsOutputPath");
|
|
160
|
+
}
|
|
161
|
+
get managedPaths() {
|
|
162
|
+
return (0, util_1.unsupported)("Compiler.managedPaths");
|
|
163
|
+
}
|
|
164
|
+
get immutablePaths() {
|
|
165
|
+
return (0, util_1.unsupported)("Compiler.immutablePaths");
|
|
166
|
+
}
|
|
167
|
+
get _lastCompilation() {
|
|
168
|
+
return __classPrivateFieldGet(this, _Compiler_compilation, "f");
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Note: This is not a webpack public API, maybe removed in future.
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
get __internal__builtinPlugins() {
|
|
175
|
+
return __classPrivateFieldGet(this, _Compiler_builtinPlugins, "f");
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Note: This is not a webpack public API, maybe removed in future.
|
|
179
|
+
* @internal
|
|
180
|
+
*/
|
|
181
|
+
get __internal__ruleSet() {
|
|
182
|
+
return __classPrivateFieldGet(this, _Compiler_ruleSet, "f");
|
|
183
|
+
}
|
|
150
184
|
/**
|
|
151
185
|
* @param name - cache name
|
|
152
186
|
* @returns the cache facade instance
|
|
@@ -154,106 +188,10 @@ class Compiler {
|
|
|
154
188
|
getCache(name) {
|
|
155
189
|
return new CacheFacade(this.cache, `${this.compilerPath}${name}`, this.options.output.hashFunction);
|
|
156
190
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
...this.options.output,
|
|
162
|
-
...outputOptions
|
|
163
|
-
},
|
|
164
|
-
// TODO: check why we need to have builtins otherwise this.#instance will fail to initialize Rspack
|
|
165
|
-
builtins: this.options.builtins
|
|
166
|
-
};
|
|
167
|
-
(0, defaults_1.applyRspackOptionsDefaults)(options);
|
|
168
|
-
const childCompiler = new Compiler(this.context, options);
|
|
169
|
-
childCompiler.name = compilerName;
|
|
170
|
-
childCompiler.outputPath = this.outputPath;
|
|
171
|
-
childCompiler.inputFileSystem = this.inputFileSystem;
|
|
172
|
-
// childCompiler.outputFileSystem = null;
|
|
173
|
-
childCompiler.resolverFactory = this.resolverFactory;
|
|
174
|
-
childCompiler.modifiedFiles = this.modifiedFiles;
|
|
175
|
-
childCompiler.removedFiles = this.removedFiles;
|
|
176
|
-
// childCompiler.fileTimestamps = this.fileTimestamps;
|
|
177
|
-
// childCompiler.contextTimestamps = this.contextTimestamps;
|
|
178
|
-
// childCompiler.fsStartTime = this.fsStartTime;
|
|
179
|
-
childCompiler.cache = this.cache;
|
|
180
|
-
childCompiler.compilerPath = `${this.compilerPath}${compilerName}|${compilerIndex}|`;
|
|
181
|
-
// childCompiler._backCompat = this._backCompat;
|
|
182
|
-
// const relativeCompilerName = makePathsRelative(
|
|
183
|
-
// this.context,
|
|
184
|
-
// compilerName,
|
|
185
|
-
// this.root
|
|
186
|
-
// );
|
|
187
|
-
// if (!this.records[relativeCompilerName]) {
|
|
188
|
-
// this.records[relativeCompilerName] = [];
|
|
189
|
-
// }
|
|
190
|
-
// if (this.records[relativeCompilerName][compilerIndex]) {
|
|
191
|
-
// childCompiler.records = this.records[relativeCompilerName][compilerIndex];
|
|
192
|
-
// } else {
|
|
193
|
-
// this.records[relativeCompilerName].push((childCompiler.records = {}));
|
|
194
|
-
// }
|
|
195
|
-
childCompiler.parentCompilation = compilation;
|
|
196
|
-
childCompiler.root = this.root;
|
|
197
|
-
if (Array.isArray(plugins)) {
|
|
198
|
-
for (const plugin of plugins) {
|
|
199
|
-
if (plugin) {
|
|
200
|
-
plugin.apply(childCompiler);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
childCompiler.builtinPlugins = [
|
|
205
|
-
...childCompiler.builtinPlugins,
|
|
206
|
-
...this.builtinPlugins.filter(plugin => plugin.canInherentFromParent === true)
|
|
207
|
-
];
|
|
208
|
-
for (const name in this.hooks) {
|
|
209
|
-
if ((0, base_1.canInherentFromParent)(name)) {
|
|
210
|
-
//@ts-ignore
|
|
211
|
-
if (childCompiler.hooks[name]) {
|
|
212
|
-
//@ts-ignore
|
|
213
|
-
childCompiler.hooks[name].taps = this.hooks[name].taps.slice();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
compilation.hooks.childCompiler.call(childCompiler, compilerName, compilerIndex);
|
|
218
|
-
return childCompiler;
|
|
219
|
-
}
|
|
220
|
-
runAsChild(callback) {
|
|
221
|
-
const finalCallback = (err, entries, compilation) => {
|
|
222
|
-
try {
|
|
223
|
-
callback(err, entries, compilation);
|
|
224
|
-
}
|
|
225
|
-
catch (e) {
|
|
226
|
-
const err = new Error(`compiler.runAsChild callback error: ${e}`);
|
|
227
|
-
// err.details = e.stack;
|
|
228
|
-
this.parentCompilation.errors.push(err);
|
|
229
|
-
// TODO: remove once this works
|
|
230
|
-
console.log(e);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
this.compile((err, compilation) => {
|
|
234
|
-
if (err) {
|
|
235
|
-
return finalCallback(err);
|
|
236
|
-
}
|
|
237
|
-
(0, assertNotNil_1.assertNotNill)(compilation);
|
|
238
|
-
this.parentCompilation.children.push(compilation);
|
|
239
|
-
for (const { name, source, info } of compilation.getAssets()) {
|
|
240
|
-
// Do not emit asset if source is not available.
|
|
241
|
-
// Webpack will emit it anyway.
|
|
242
|
-
if (source) {
|
|
243
|
-
this.parentCompilation.emitAsset(name, source, info);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
const entries = [];
|
|
247
|
-
for (const ep of compilation.entrypoints.values()) {
|
|
248
|
-
entries.push(...ep.getFiles());
|
|
249
|
-
}
|
|
250
|
-
return finalCallback(null, entries, compilation);
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
isChild() {
|
|
254
|
-
const isRoot = this.root === this;
|
|
255
|
-
return !isRoot;
|
|
256
|
-
}
|
|
191
|
+
/**
|
|
192
|
+
* @param name - name of the logger, or function called once to get the logger name
|
|
193
|
+
* @returns a logger with that name
|
|
194
|
+
*/
|
|
257
195
|
getInfrastructureLogger(name) {
|
|
258
196
|
if (!name) {
|
|
259
197
|
throw new TypeError("Compiler.getInfrastructureLogger(name) called without a name");
|
|
@@ -266,9 +204,7 @@ class Compiler {
|
|
|
266
204
|
}
|
|
267
205
|
}
|
|
268
206
|
else {
|
|
269
|
-
if (
|
|
270
|
-
// @ts-expect-error
|
|
271
|
-
this.hooks.infrastructureLog.call(name, type, args) === undefined) {
|
|
207
|
+
if (this.hooks.infrastructureLog.call(name, type, args) === undefined) {
|
|
272
208
|
if (this.infrastructureLogger !== undefined) {
|
|
273
209
|
this.infrastructureLogger(name, type, args);
|
|
274
210
|
}
|
|
@@ -324,6 +260,25 @@ class Compiler {
|
|
|
324
260
|
}
|
|
325
261
|
});
|
|
326
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* @param watchOptions - the watcher's options
|
|
265
|
+
* @param handler - signals when the call finishes
|
|
266
|
+
* @returns a compiler watcher
|
|
267
|
+
*/
|
|
268
|
+
watch(watchOptions, handler) {
|
|
269
|
+
if (this.running) {
|
|
270
|
+
// @ts-expect-error
|
|
271
|
+
return handler(new ConcurrentCompilationError_1.default());
|
|
272
|
+
}
|
|
273
|
+
this.running = true;
|
|
274
|
+
this.watchMode = true;
|
|
275
|
+
// @ts-expect-error
|
|
276
|
+
this.watching = new Watching_1.Watching(this, watchOptions, handler);
|
|
277
|
+
return this.watching;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* @param callback - signals when the call finishes
|
|
281
|
+
*/
|
|
327
282
|
run(callback) {
|
|
328
283
|
if (this.running) {
|
|
329
284
|
return callback(new ConcurrentCompilationError_1.default());
|
|
@@ -357,9 +312,9 @@ class Compiler {
|
|
|
357
312
|
if (err) {
|
|
358
313
|
return finalCallback(err);
|
|
359
314
|
}
|
|
360
|
-
this.
|
|
361
|
-
this.
|
|
362
|
-
const stats = new Stats_1.Stats(this
|
|
315
|
+
__classPrivateFieldGet(this, _Compiler_compilation, "f").startTime = startTime;
|
|
316
|
+
__classPrivateFieldGet(this, _Compiler_compilation, "f").endTime = Date.now();
|
|
317
|
+
const stats = new Stats_1.Stats(__classPrivateFieldGet(this, _Compiler_compilation, "f"));
|
|
363
318
|
this.hooks.done.callAsync(stats, err => {
|
|
364
319
|
if (err) {
|
|
365
320
|
return finalCallback(err);
|
|
@@ -384,22 +339,114 @@ class Compiler {
|
|
|
384
339
|
doRun();
|
|
385
340
|
}
|
|
386
341
|
}
|
|
342
|
+
runAsChild(callback) {
|
|
343
|
+
const finalCallback = (err, entries, compilation) => {
|
|
344
|
+
try {
|
|
345
|
+
callback(err, entries, compilation);
|
|
346
|
+
}
|
|
347
|
+
catch (e) {
|
|
348
|
+
const err = new Error(`compiler.runAsChild callback error: ${e}`);
|
|
349
|
+
// err.details = e.stack;
|
|
350
|
+
this.parentCompilation.errors.push(err);
|
|
351
|
+
// TODO: remove once this works
|
|
352
|
+
console.log(e);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
this.compile((err, compilation) => {
|
|
356
|
+
if (err) {
|
|
357
|
+
return finalCallback(err);
|
|
358
|
+
}
|
|
359
|
+
(0, assertNotNil_1.assertNotNill)(compilation);
|
|
360
|
+
this.parentCompilation.children.push(compilation);
|
|
361
|
+
for (const { name, source, info } of compilation.getAssets()) {
|
|
362
|
+
// Do not emit asset if source is not available.
|
|
363
|
+
// Webpack will emit it anyway.
|
|
364
|
+
if (source) {
|
|
365
|
+
this.parentCompilation.emitAsset(name, source, info);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
const entries = [];
|
|
369
|
+
for (const ep of compilation.entrypoints.values()) {
|
|
370
|
+
entries.push(...ep.chunks);
|
|
371
|
+
}
|
|
372
|
+
return finalCallback(null, entries, compilation);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
purgeInputFileSystem() {
|
|
376
|
+
if (this.inputFileSystem && this.inputFileSystem.purge) {
|
|
377
|
+
this.inputFileSystem.purge();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
387
380
|
/**
|
|
388
|
-
*
|
|
389
|
-
* @
|
|
381
|
+
* @param compilation - the compilation
|
|
382
|
+
* @param compilerName - the compiler's name
|
|
383
|
+
* @param compilerIndex - the compiler's index
|
|
384
|
+
* @param outputOptions - the output options
|
|
385
|
+
* @param plugins - the plugins to apply
|
|
386
|
+
* @returns a child compiler
|
|
390
387
|
*/
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
388
|
+
createChildCompiler(compilation, compilerName, compilerIndex, outputOptions, plugins) {
|
|
389
|
+
const options = {
|
|
390
|
+
...this.options,
|
|
391
|
+
output: {
|
|
392
|
+
...this.options.output,
|
|
393
|
+
...outputOptions
|
|
394
|
+
},
|
|
395
|
+
// TODO: check why we need to have builtins otherwise this.#instance will fail to initialize Rspack
|
|
396
|
+
builtins: this.options.builtins
|
|
397
|
+
};
|
|
398
|
+
(0, defaults_1.applyRspackOptionsDefaults)(options);
|
|
399
|
+
const childCompiler = new Compiler(this.context, options);
|
|
400
|
+
childCompiler.name = compilerName;
|
|
401
|
+
childCompiler.outputPath = this.outputPath;
|
|
402
|
+
childCompiler.inputFileSystem = this.inputFileSystem;
|
|
403
|
+
childCompiler.outputFileSystem = null;
|
|
404
|
+
childCompiler.resolverFactory = this.resolverFactory;
|
|
405
|
+
childCompiler.modifiedFiles = this.modifiedFiles;
|
|
406
|
+
childCompiler.removedFiles = this.removedFiles;
|
|
407
|
+
childCompiler.fileTimestamps = this.fileTimestamps;
|
|
408
|
+
childCompiler.contextTimestamps = this.contextTimestamps;
|
|
409
|
+
childCompiler.fsStartTime = this.fsStartTime;
|
|
410
|
+
childCompiler.cache = this.cache;
|
|
411
|
+
childCompiler.compilerPath = `${this.compilerPath}${compilerName}|${compilerIndex}|`;
|
|
412
|
+
const relativeCompilerName = (0, identifier_1.makePathsRelative)(this.context, compilerName, this.root);
|
|
413
|
+
if (!this.records[relativeCompilerName]) {
|
|
414
|
+
this.records[relativeCompilerName] = [];
|
|
415
|
+
}
|
|
416
|
+
if (this.records[relativeCompilerName][compilerIndex]) {
|
|
417
|
+
childCompiler.records = this.records[relativeCompilerName][compilerIndex];
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
this.records[relativeCompilerName].push((childCompiler.records = {}));
|
|
421
|
+
}
|
|
422
|
+
childCompiler.parentCompilation = compilation;
|
|
423
|
+
childCompiler.root = this.root;
|
|
424
|
+
if (Array.isArray(plugins)) {
|
|
425
|
+
for (const plugin of plugins) {
|
|
426
|
+
if (plugin) {
|
|
427
|
+
plugin.apply(childCompiler);
|
|
428
|
+
}
|
|
395
429
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
430
|
+
}
|
|
431
|
+
__classPrivateFieldSet(childCompiler, _Compiler_builtinPlugins, [
|
|
432
|
+
...__classPrivateFieldGet(childCompiler, _Compiler_builtinPlugins, "f"),
|
|
433
|
+
...__classPrivateFieldGet(this, _Compiler_builtinPlugins, "f").filter(plugin => plugin.canInherentFromParent === true)
|
|
434
|
+
], "f");
|
|
435
|
+
for (const name in this.hooks) {
|
|
436
|
+
if ((0, base_1.canInherentFromParent)(name)) {
|
|
437
|
+
//@ts-ignore
|
|
438
|
+
if (childCompiler.hooks[name]) {
|
|
439
|
+
//@ts-ignore
|
|
440
|
+
childCompiler.hooks[name].taps = this.hooks[name].taps.slice();
|
|
399
441
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
compilation.hooks.childCompiler.call(childCompiler, compilerName, compilerIndex);
|
|
445
|
+
return childCompiler;
|
|
446
|
+
}
|
|
447
|
+
isChild() {
|
|
448
|
+
const isRoot = this.root === this;
|
|
449
|
+
return !isRoot;
|
|
403
450
|
}
|
|
404
451
|
compile(callback) {
|
|
405
452
|
const startTime = Date.now();
|
|
@@ -414,33 +461,17 @@ class Compiler {
|
|
|
414
461
|
if (err) {
|
|
415
462
|
return callback(err);
|
|
416
463
|
}
|
|
417
|
-
this.
|
|
418
|
-
this.
|
|
419
|
-
this.hooks.afterCompile.callAsync(this
|
|
464
|
+
__classPrivateFieldGet(this, _Compiler_compilation, "f").startTime = startTime;
|
|
465
|
+
__classPrivateFieldGet(this, _Compiler_compilation, "f").endTime = Date.now();
|
|
466
|
+
this.hooks.afterCompile.callAsync(__classPrivateFieldGet(this, _Compiler_compilation, "f"), err => {
|
|
420
467
|
if (err) {
|
|
421
468
|
return callback(err);
|
|
422
469
|
}
|
|
423
|
-
return callback(null, this
|
|
470
|
+
return callback(null, __classPrivateFieldGet(this, _Compiler_compilation, "f"));
|
|
424
471
|
});
|
|
425
472
|
});
|
|
426
473
|
});
|
|
427
474
|
}
|
|
428
|
-
watch(watchOptions, handler) {
|
|
429
|
-
if (this.running) {
|
|
430
|
-
// @ts-expect-error
|
|
431
|
-
return handler(new ConcurrentCompilationError_1.default());
|
|
432
|
-
}
|
|
433
|
-
this.running = true;
|
|
434
|
-
this.watchMode = true;
|
|
435
|
-
// @ts-expect-error
|
|
436
|
-
this.watching = new Watching_1.Watching(this, watchOptions, handler);
|
|
437
|
-
return this.watching;
|
|
438
|
-
}
|
|
439
|
-
purgeInputFileSystem() {
|
|
440
|
-
if (this.inputFileSystem && this.inputFileSystem.purge) {
|
|
441
|
-
this.inputFileSystem.purge();
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
475
|
close(callback) {
|
|
445
476
|
if (this.watching) {
|
|
446
477
|
// When there is still an active watching, close this #initial
|
|
@@ -455,22 +486,77 @@ class Compiler {
|
|
|
455
486
|
this.cache.shutdown(callback);
|
|
456
487
|
});
|
|
457
488
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
489
|
+
/**
|
|
490
|
+
* Note: This is not a webpack public API, maybe removed in future.
|
|
491
|
+
* @internal
|
|
492
|
+
*/
|
|
493
|
+
__internal__rebuild(modifiedFiles, removedFiles, callback) {
|
|
494
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
495
|
+
if (error) {
|
|
496
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
497
|
+
}
|
|
498
|
+
instance.rebuild(Array.from(modifiedFiles || []), Array.from(removedFiles || []), error => {
|
|
499
|
+
if (error) {
|
|
500
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
501
|
+
}
|
|
502
|
+
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
503
|
+
});
|
|
504
|
+
});
|
|
464
505
|
}
|
|
465
506
|
__internal__registerBuiltinPlugin(plugin) {
|
|
466
|
-
this.
|
|
507
|
+
__classPrivateFieldGet(this, _Compiler_builtinPlugins, "f").push(plugin);
|
|
467
508
|
}
|
|
468
509
|
__internal__getModuleExecutionResult(id) {
|
|
469
510
|
return __classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").get(id);
|
|
470
511
|
}
|
|
471
512
|
}
|
|
472
513
|
exports.Compiler = Compiler;
|
|
473
|
-
_Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(),
|
|
514
|
+
_Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler_compilation = new WeakMap(), _Compiler_compilationParams = new WeakMap(), _Compiler_builtinPlugins = new WeakMap(), _Compiler_moduleExecutionResultsMap = new WeakMap(), _Compiler_nonSkippableRegisters = new WeakMap(), _Compiler_registers = new WeakMap(), _Compiler_ruleSet = new WeakMap(), _Compiler_instances = new WeakSet(), _Compiler_build = function _Compiler_build(callback) {
|
|
515
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
516
|
+
if (error) {
|
|
517
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
518
|
+
}
|
|
519
|
+
if (!__classPrivateFieldGet(this, _Compiler_initial, "f")) {
|
|
520
|
+
instance.rebuild(Array.from(this.modifiedFiles || []), Array.from(this.removedFiles || []), error => {
|
|
521
|
+
if (error) {
|
|
522
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
523
|
+
}
|
|
524
|
+
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
525
|
+
});
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
__classPrivateFieldSet(this, _Compiler_initial, false, "f");
|
|
529
|
+
instance.build(error => {
|
|
530
|
+
if (error) {
|
|
531
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
532
|
+
}
|
|
533
|
+
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
}, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
|
|
537
|
+
const compilation = new Compilation_1.Compilation(this, native);
|
|
538
|
+
compilation.name = this.name;
|
|
539
|
+
__classPrivateFieldSet(this, _Compiler_compilation, compilation, "f");
|
|
540
|
+
return compilation;
|
|
541
|
+
}, _Compiler_resetThisCompilation = function _Compiler_resetThisCompilation() {
|
|
542
|
+
// reassign new compilation in thisCompilation
|
|
543
|
+
__classPrivateFieldSet(this, _Compiler_compilation, undefined, "f");
|
|
544
|
+
// ensure thisCompilation must call
|
|
545
|
+
this.hooks.thisCompilation.intercept({
|
|
546
|
+
call: () => { }
|
|
547
|
+
});
|
|
548
|
+
}, _Compiler_newCompilationParams = function _Compiler_newCompilationParams() {
|
|
549
|
+
const normalModuleFactory = new NormalModuleFactory_1.NormalModuleFactory();
|
|
550
|
+
this.hooks.normalModuleFactory.call(normalModuleFactory);
|
|
551
|
+
const contextModuleFactory = new ContextModuleFactory_1.ContextModuleFactory();
|
|
552
|
+
this.hooks.contextModuleFactory.call(contextModuleFactory);
|
|
553
|
+
const params = {
|
|
554
|
+
normalModuleFactory,
|
|
555
|
+
contextModuleFactory
|
|
556
|
+
};
|
|
557
|
+
__classPrivateFieldSet(this, _Compiler_compilationParams, params, "f");
|
|
558
|
+
return params;
|
|
559
|
+
}, _Compiler_getInstance = function _Compiler_getInstance(callback) {
|
|
474
560
|
const error = (0, bindingVersionCheck_1.checkVersion)();
|
|
475
561
|
if (error) {
|
|
476
562
|
return callback(error);
|
|
@@ -485,20 +571,20 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
485
571
|
const instanceBinding = require("@rspack/binding");
|
|
486
572
|
__classPrivateFieldSet(this, _Compiler_registers, {
|
|
487
573
|
registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerThisCompilation, () => this.hooks.thisCompilation, queried => (native) => {
|
|
488
|
-
if (this
|
|
574
|
+
if (__classPrivateFieldGet(this, _Compiler_compilation, "f") === undefined) {
|
|
489
575
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createCompilation).call(this, native);
|
|
490
576
|
}
|
|
491
|
-
queried.call(this
|
|
577
|
+
queried.call(__classPrivateFieldGet(this, _Compiler_compilation, "f"), __classPrivateFieldGet(this, _Compiler_compilationParams, "f"));
|
|
492
578
|
}),
|
|
493
|
-
registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerCompilation, () => this.hooks.compilation, queried => () => queried.call(this
|
|
494
|
-
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerMake, () => this.hooks.make, queried => async () => await queried.promise(this
|
|
495
|
-
registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerFinishMake, () => this.hooks.finishMake, queried => async () => await queried.promise(this
|
|
496
|
-
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerShouldEmit, () => this.hooks.shouldEmit, queried => () => queried.call(this
|
|
497
|
-
registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerEmit, () => this.hooks.emit, queried => async () => await queried.promise(this
|
|
498
|
-
registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAfterEmit, () => this.hooks.afterEmit, queried => async () => await queried.promise(this
|
|
579
|
+
registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerCompilation, () => this.hooks.compilation, queried => () => queried.call(__classPrivateFieldGet(this, _Compiler_compilation, "f"), __classPrivateFieldGet(this, _Compiler_compilationParams, "f"))),
|
|
580
|
+
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerMake, () => this.hooks.make, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f"))),
|
|
581
|
+
registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerFinishMake, () => this.hooks.finishMake, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f"))),
|
|
582
|
+
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerShouldEmit, () => this.hooks.shouldEmit, queried => () => queried.call(__classPrivateFieldGet(this, _Compiler_compilation, "f"))),
|
|
583
|
+
registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerEmit, () => this.hooks.emit, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f"))),
|
|
584
|
+
registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAfterEmit, () => this.hooks.afterEmit, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f"))),
|
|
499
585
|
registerCompilerAssetEmittedTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAssetEmitted, () => this.hooks.assetEmitted, queried => async ({ filename, targetPath, outputPath }) => {
|
|
500
586
|
return queried.promise(filename, {
|
|
501
|
-
compilation: this
|
|
587
|
+
compilation: __classPrivateFieldGet(this, _Compiler_compilation, "f"),
|
|
502
588
|
targetPath,
|
|
503
589
|
outputPath,
|
|
504
590
|
get source() {
|
|
@@ -511,20 +597,20 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
511
597
|
}
|
|
512
598
|
});
|
|
513
599
|
}),
|
|
514
|
-
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeModule, () => this.
|
|
600
|
+
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeModule, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.runtimeModule, queried => ({ module, chunk }) => {
|
|
515
601
|
var _a, _b;
|
|
516
602
|
const originSource = (_a = module.source) === null || _a === void 0 ? void 0 : _a.source;
|
|
517
|
-
queried.call(module, Chunk_1.Chunk.__from_binding(chunk, this
|
|
603
|
+
queried.call(module, Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compiler_compilation, "f")));
|
|
518
604
|
const newSource = (_b = module.source) === null || _b === void 0 ? void 0 : _b.source;
|
|
519
605
|
if (newSource && newSource !== originSource) {
|
|
520
606
|
return module;
|
|
521
607
|
}
|
|
522
608
|
return;
|
|
523
609
|
}),
|
|
524
|
-
registerCompilationBuildModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationBuildModule, () => this.
|
|
525
|
-
registerCompilationStillValidModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationStillValidModule, () => this.
|
|
526
|
-
registerCompilationSucceedModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationSucceedModule, () => this.
|
|
527
|
-
registerCompilationExecuteModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationExecuteModule, () => this.
|
|
610
|
+
registerCompilationBuildModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationBuildModule, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.buildModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
611
|
+
registerCompilationStillValidModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationStillValidModule, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.stillValidModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
612
|
+
registerCompilationSucceedModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationSucceedModule, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.succeedModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
613
|
+
registerCompilationExecuteModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationExecuteModule, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.executeModule, queried => ({ entry, id, codegenResults, runtimeModules }) => {
|
|
528
614
|
const __webpack_require__ = (id) => {
|
|
529
615
|
const cached = moduleCache[id];
|
|
530
616
|
if (cached !== undefined) {
|
|
@@ -562,16 +648,16 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
562
648
|
const executeResult = __webpack_require__(entry);
|
|
563
649
|
__classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").set(id, executeResult);
|
|
564
650
|
}),
|
|
565
|
-
registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationFinishModules, () => this.
|
|
566
|
-
registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeModules, () => this.
|
|
567
|
-
registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterOptimizeModules, () => this.
|
|
568
|
-
registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeTree, () => this.
|
|
569
|
-
registerCompilationOptimizeChunkModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeChunkModules, () => this.
|
|
570
|
-
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkAsset, () => this.
|
|
571
|
-
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationProcessAssets, () => this.
|
|
572
|
-
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () => this.
|
|
573
|
-
registerCompilationAfterSealTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterSeal, () => this.
|
|
574
|
-
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => this.
|
|
651
|
+
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)),
|
|
652
|
+
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)),
|
|
653
|
+
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)),
|
|
654
|
+
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)),
|
|
655
|
+
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)),
|
|
656
|
+
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)),
|
|
657
|
+
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)),
|
|
658
|
+
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)),
|
|
659
|
+
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()),
|
|
660
|
+
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
575
661
|
const normalizedResolveData = {
|
|
576
662
|
request: resolveData.request,
|
|
577
663
|
context: resolveData.context,
|
|
@@ -584,13 +670,13 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
584
670
|
resolveData.context = normalizedResolveData.context;
|
|
585
671
|
return [ret, resolveData];
|
|
586
672
|
}),
|
|
587
|
-
registerNormalModuleFactoryResolveForSchemeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookMapRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryResolveForScheme, () => this.
|
|
673
|
+
registerNormalModuleFactoryResolveForSchemeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookMapRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryResolveForScheme, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.resolveForScheme, queried => async (args) => {
|
|
588
674
|
const ret = await queried
|
|
589
675
|
.for(args.scheme)
|
|
590
676
|
.promise(args.resourceData);
|
|
591
677
|
return [ret, args.resourceData];
|
|
592
678
|
}),
|
|
593
|
-
registerNormalModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryAfterResolve, () => this.
|
|
679
|
+
registerNormalModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryAfterResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.afterResolve, queried => async (arg) => {
|
|
594
680
|
const data = {
|
|
595
681
|
request: arg.request,
|
|
596
682
|
context: arg.context,
|
|
@@ -602,37 +688,43 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
602
688
|
const ret = await queried.promise(data);
|
|
603
689
|
return [ret, data.createData];
|
|
604
690
|
}),
|
|
605
|
-
registerNormalModuleFactoryCreateModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryCreateModule, () => this.
|
|
691
|
+
registerNormalModuleFactoryCreateModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryCreateModule, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.createModule, queried => async (args) => {
|
|
606
692
|
const data = {
|
|
607
693
|
...args,
|
|
608
694
|
settings: {}
|
|
609
695
|
};
|
|
610
696
|
await queried.promise(data, {});
|
|
611
697
|
}),
|
|
612
|
-
registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => this.
|
|
613
|
-
|
|
614
|
-
request: arg.request,
|
|
615
|
-
context: arg.context,
|
|
616
|
-
fileDependencies: [],
|
|
617
|
-
missingDependencies: [],
|
|
618
|
-
contextDependencies: []
|
|
619
|
-
};
|
|
620
|
-
const ret = await queried.promise(data);
|
|
621
|
-
return [ret, data];
|
|
698
|
+
registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").contextModuleFactory.hooks.beforeResolve, queried => async (bindingData) => {
|
|
699
|
+
return queried.promise(bindingData);
|
|
622
700
|
}),
|
|
623
|
-
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryAfterResolve, () => this.
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
701
|
+
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryAfterResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").contextModuleFactory.hooks.afterResolve, queried => async (bindingData) => {
|
|
702
|
+
var _a;
|
|
703
|
+
const data = bindingData
|
|
704
|
+
? ({
|
|
705
|
+
resource: bindingData.resource,
|
|
706
|
+
regExp: bindingData.regExp
|
|
707
|
+
? new RegExp(bindingData.regExp)
|
|
708
|
+
: undefined,
|
|
709
|
+
request: bindingData.request,
|
|
710
|
+
context: bindingData.context,
|
|
711
|
+
// TODO: Dependencies are not fully supported yet; this is a placeholder to prevent errors in moment-locales-webpack-plugin.
|
|
712
|
+
dependencies: []
|
|
713
|
+
})
|
|
714
|
+
: false;
|
|
715
|
+
const ret = await queried.promise(data);
|
|
716
|
+
const result = ret
|
|
717
|
+
? ({
|
|
718
|
+
resource: ret.resource,
|
|
719
|
+
context: ret.context,
|
|
720
|
+
request: ret.request,
|
|
721
|
+
regExp: (_a = ret.regExp) === null || _a === void 0 ? void 0 : _a.toString()
|
|
722
|
+
})
|
|
723
|
+
: false;
|
|
724
|
+
return result;
|
|
633
725
|
})
|
|
634
726
|
}, "f");
|
|
635
|
-
__classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this
|
|
727
|
+
__classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, __classPrivateFieldGet(this, _Compiler_builtinPlugins, "f"), __classPrivateFieldGet(this, _Compiler_registers, "f"), fileSystem_1.ThreadsafeWritableNodeFS.__into_binding(this.outputFileSystem)), "f");
|
|
636
728
|
callback(null, __classPrivateFieldGet(this, _Compiler_instance, "f"));
|
|
637
729
|
}, _Compiler_updateNonSkippableRegisters = function _Compiler_updateNonSkippableRegisters() {
|
|
638
730
|
const kinds = [];
|
|
@@ -723,49 +815,4 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
723
815
|
getTaps.registerKind = registerKind;
|
|
724
816
|
getTaps.getHookMap = getHookMap;
|
|
725
817
|
return getTaps;
|
|
726
|
-
}, _Compiler_build = function _Compiler_build(callback) {
|
|
727
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
728
|
-
if (error) {
|
|
729
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
730
|
-
}
|
|
731
|
-
if (!__classPrivateFieldGet(this, _Compiler_initial, "f")) {
|
|
732
|
-
instance.rebuild(Array.from(this.modifiedFiles || []), Array.from(this.removedFiles || []), error => {
|
|
733
|
-
if (error) {
|
|
734
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
735
|
-
}
|
|
736
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
737
|
-
});
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
__classPrivateFieldSet(this, _Compiler_initial, false, "f");
|
|
741
|
-
instance.build(error => {
|
|
742
|
-
if (error) {
|
|
743
|
-
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
744
|
-
}
|
|
745
|
-
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
746
|
-
});
|
|
747
|
-
});
|
|
748
|
-
}, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
|
|
749
|
-
const compilation = new Compilation_1.Compilation(this, native);
|
|
750
|
-
compilation.name = this.name;
|
|
751
|
-
this.compilation = compilation;
|
|
752
|
-
return compilation;
|
|
753
|
-
}, _Compiler_resetThisCompilation = function _Compiler_resetThisCompilation() {
|
|
754
|
-
// reassign new compilation in thisCompilation
|
|
755
|
-
this.compilation = undefined;
|
|
756
|
-
// ensure thisCompilation must call
|
|
757
|
-
this.hooks.thisCompilation.intercept({
|
|
758
|
-
call: () => { }
|
|
759
|
-
});
|
|
760
|
-
}, _Compiler_newCompilationParams = function _Compiler_newCompilationParams() {
|
|
761
|
-
const normalModuleFactory = new NormalModuleFactory_1.NormalModuleFactory();
|
|
762
|
-
this.hooks.normalModuleFactory.call(normalModuleFactory);
|
|
763
|
-
const contextModuleFactory = new ContextModuleFactory_1.ContextModuleFactory();
|
|
764
|
-
this.hooks.contextModuleFactory.call(contextModuleFactory);
|
|
765
|
-
const params = {
|
|
766
|
-
normalModuleFactory,
|
|
767
|
-
contextModuleFactory
|
|
768
|
-
};
|
|
769
|
-
this.compilationParams = params;
|
|
770
|
-
return params;
|
|
771
818
|
};
|