@rspack/core 0.6.5-canary-dc02c55-20240516004313 → 0.6.5-canary-b7b5c75-20240821125908
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 +65 -46
- package/dist/Compilation.js +222 -128
- package/dist/Compiler.d.ts +44 -75
- package/dist/Compiler.js +260 -301
- package/dist/Entrypoint.d.ts +1 -1
- package/dist/Entrypoint.js +1 -1
- package/dist/ExecuteModulePlugin.js +1 -1
- package/dist/Module.js +2 -2
- package/dist/MultiCompiler.d.ts +25 -10
- 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 +9 -0
- package/dist/Watching.js +2 -12
- 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 +4 -5
- 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/adapter.js +5 -6
- package/dist/config/adapterRuleUse.d.ts +1 -2
- package/dist/config/adapterRuleUse.js +2 -2
- package/dist/config/defaults.js +4 -6
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -2
- package/dist/config/normalization.d.ts +2 -1
- package/dist/config/zod.d.ts +184 -258
- package/dist/config/zod.js +28 -8
- 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 +30 -32
- package/dist/exports.js +17 -15
- package/dist/fileSystem.d.ts +8 -12
- package/dist/fileSystem.js +48 -25
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/loader-runner/index.js +13 -13
- package/dist/logging/Logger.d.ts +1 -1
- package/dist/logging/createConsoleLogger.js +14 -0
- package/dist/node/NodeEnvironmentPlugin.d.ts +1 -1
- package/dist/node/NodeEnvironmentPlugin.js +1 -1
- package/dist/node/nodeConsole.js +4 -0
- package/dist/rspack.d.ts +13 -4
- package/dist/rspack.js +8 -8
- package/dist/rspackOptionsApply.d.ts +10 -1
- package/dist/rspackOptionsApply.js +5 -14
- 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 +9 -0
- 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/createSource.d.ts +5 -0
- package/dist/util/createSource.js +65 -0
- package/dist/util/fs.d.ts +0 -64
- package/dist/util/fs.js +0 -122
- package/dist/util/index.d.ts +1 -2
- package/dist/util/index.js +11 -16
- package/package.json +5 -5
- package/dist/util/source.d.ts +0 -18
- package/dist/util/source.js +0 -66
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_disabledHooks, _Compiler_nonSkippableRegisters, _Compiler_registers, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateNonSkippableRegisters, _Compiler_decorateJsTaps, _Compiler_createHookRegisterTaps, _Compiler_createHookMapRegisterTaps, _Compiler_build, _Compiler_createCompilation, _Compiler_resetThisCompilation, _Compiler_newCompilationParams;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.Compiler = void 0;
|
|
42
42
|
/**
|
|
@@ -49,52 +49,58 @@ 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"));
|
|
52
54
|
const tapable = __importStar(require("tapable"));
|
|
55
|
+
const liteTapable = __importStar(require("./lite-tapable"));
|
|
53
56
|
const tapable_1 = require("tapable");
|
|
54
|
-
const Compilation_1 = require("./Compilation");
|
|
55
57
|
const config_1 = require("./config");
|
|
56
|
-
const ContextModuleFactory_1 = require("./ContextModuleFactory");
|
|
57
|
-
const index_1 = require("./index");
|
|
58
|
-
const liteTapable = __importStar(require("./lite-tapable"));
|
|
59
58
|
const RuleSetCompiler_1 = require("./RuleSetCompiler");
|
|
60
59
|
const Stats_1 = require("./Stats");
|
|
60
|
+
const Compilation_1 = require("./Compilation");
|
|
61
|
+
const ContextModuleFactory_1 = require("./ContextModuleFactory");
|
|
61
62
|
const ResolverFactory = require("./ResolverFactory");
|
|
62
63
|
const ConcurrentCompilationError_1 = __importDefault(require("./error/ConcurrentCompilationError"));
|
|
63
64
|
const fileSystem_1 = require("./fileSystem");
|
|
64
65
|
const Cache = require("./lib/Cache");
|
|
65
66
|
const CacheFacade = require("./lib/CacheFacade");
|
|
66
|
-
const builtin_plugin_1 = require("./builtin-plugin");
|
|
67
|
-
const base_1 = require("./builtin-plugin/base");
|
|
68
|
-
const Chunk_1 = require("./Chunk");
|
|
69
|
-
const defaults_1 = require("./config/defaults");
|
|
70
|
-
const ExecuteModulePlugin_1 = __importDefault(require("./ExecuteModulePlugin"));
|
|
71
|
-
const HookWebpackError_1 = require("./lib/HookWebpackError");
|
|
72
67
|
const Logger_1 = require("./logging/Logger");
|
|
73
|
-
const Module_1 = require("./Module");
|
|
74
68
|
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
69
|
const bindingVersionCheck_1 = require("./util/bindingVersionCheck");
|
|
79
|
-
const identifier_1 = require("./util/identifier");
|
|
80
70
|
const Watching_1 = require("./Watching");
|
|
71
|
+
const builtin_plugin_1 = require("./builtin-plugin");
|
|
72
|
+
const defaults_1 = require("./config/defaults");
|
|
73
|
+
const assertNotNil_1 = require("./util/assertNotNil");
|
|
74
|
+
const RuntimeGlobals_1 = require("./RuntimeGlobals");
|
|
75
|
+
const HookWebpackError_1 = require("./lib/HookWebpackError");
|
|
76
|
+
const Module_1 = require("./Module");
|
|
77
|
+
const base_1 = require("./builtin-plugin/base");
|
|
78
|
+
const ExecuteModulePlugin_1 = __importDefault(require("./ExecuteModulePlugin"));
|
|
79
|
+
const Chunk_1 = require("./Chunk");
|
|
81
80
|
class Compiler {
|
|
82
81
|
constructor(context, options) {
|
|
83
82
|
_Compiler_instances.add(this);
|
|
84
83
|
_Compiler_instance.set(this, void 0);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
_Compiler_moduleExecutionResultsMap.set(this, void 0);
|
|
84
|
+
this.webpack = index_1.rspack;
|
|
85
|
+
// TODO: remove this after remove rebuild on the rust side.
|
|
86
|
+
_Compiler_initial.set(this, true);
|
|
87
|
+
_Compiler_disabledHooks.set(this, void 0);
|
|
90
88
|
_Compiler_nonSkippableRegisters.set(this, void 0);
|
|
91
89
|
_Compiler_registers.set(this, void 0);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
_Compiler_moduleExecutionResultsMap.set(this, void 0);
|
|
91
|
+
this.outputFileSystem = fs_1.default;
|
|
92
|
+
this.options = options;
|
|
93
|
+
this.cache = new Cache();
|
|
94
|
+
this.compilerPath = "";
|
|
95
|
+
this.builtinPlugins = [];
|
|
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;
|
|
98
104
|
this.hooks = {
|
|
99
105
|
initialize: new tapable_1.SyncHook([]),
|
|
100
106
|
shouldEmit: new liteTapable.SyncBailHook(["compilation"]),
|
|
@@ -133,54 +139,14 @@ class Compiler {
|
|
|
133
139
|
finishMake: new liteTapable.AsyncSeriesHook(["compilation"]),
|
|
134
140
|
entryOption: new tapable.SyncBailHook(["context", "entry"])
|
|
135
141
|
};
|
|
136
|
-
this.
|
|
137
|
-
this.
|
|
138
|
-
this
|
|
139
|
-
this
|
|
140
|
-
this
|
|
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;
|
|
142
|
+
this.modifiedFiles = undefined;
|
|
143
|
+
this.removedFiles = undefined;
|
|
144
|
+
__classPrivateFieldSet(this, _Compiler_disabledHooks, [], "f");
|
|
145
|
+
__classPrivateFieldSet(this, _Compiler_nonSkippableRegisters, [], "f");
|
|
146
|
+
__classPrivateFieldSet(this, _Compiler_moduleExecutionResultsMap, new Map(), "f");
|
|
152
147
|
new builtin_plugin_1.JsLoaderRspackPlugin(this).apply(this);
|
|
153
148
|
new ExecuteModulePlugin_1.default().apply(this);
|
|
154
149
|
}
|
|
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
|
-
}
|
|
184
150
|
/**
|
|
185
151
|
* @param name - cache name
|
|
186
152
|
* @returns the cache facade instance
|
|
@@ -188,10 +154,106 @@ class Compiler {
|
|
|
188
154
|
getCache(name) {
|
|
189
155
|
return new CacheFacade(this.cache, `${this.compilerPath}${name}`, this.options.output.hashFunction);
|
|
190
156
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
157
|
+
createChildCompiler(compilation, compilerName, compilerIndex, outputOptions, plugins) {
|
|
158
|
+
const options = {
|
|
159
|
+
...this.options,
|
|
160
|
+
output: {
|
|
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
|
+
}
|
|
195
257
|
getInfrastructureLogger(name) {
|
|
196
258
|
if (!name) {
|
|
197
259
|
throw new TypeError("Compiler.getInfrastructureLogger(name) called without a name");
|
|
@@ -204,7 +266,9 @@ class Compiler {
|
|
|
204
266
|
}
|
|
205
267
|
}
|
|
206
268
|
else {
|
|
207
|
-
if (
|
|
269
|
+
if (
|
|
270
|
+
// @ts-expect-error
|
|
271
|
+
this.hooks.infrastructureLog.call(name, type, args) === undefined) {
|
|
208
272
|
if (this.infrastructureLogger !== undefined) {
|
|
209
273
|
this.infrastructureLogger(name, type, args);
|
|
210
274
|
}
|
|
@@ -260,25 +324,6 @@ class Compiler {
|
|
|
260
324
|
}
|
|
261
325
|
});
|
|
262
326
|
}
|
|
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
|
-
*/
|
|
282
327
|
run(callback) {
|
|
283
328
|
if (this.running) {
|
|
284
329
|
return callback(new ConcurrentCompilationError_1.default());
|
|
@@ -312,9 +357,9 @@ class Compiler {
|
|
|
312
357
|
if (err) {
|
|
313
358
|
return finalCallback(err);
|
|
314
359
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const stats = new Stats_1.Stats(
|
|
360
|
+
this.compilation.startTime = startTime;
|
|
361
|
+
this.compilation.endTime = Date.now();
|
|
362
|
+
const stats = new Stats_1.Stats(this.compilation);
|
|
318
363
|
this.hooks.done.callAsync(stats, err => {
|
|
319
364
|
if (err) {
|
|
320
365
|
return finalCallback(err);
|
|
@@ -339,114 +384,22 @@ class Compiler {
|
|
|
339
384
|
doRun();
|
|
340
385
|
}
|
|
341
386
|
}
|
|
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
|
-
}
|
|
380
387
|
/**
|
|
381
|
-
*
|
|
382
|
-
* @
|
|
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
|
|
388
|
+
* * Note: This is not a webpack public API, maybe removed in future.
|
|
389
|
+
* @internal
|
|
387
390
|
*/
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
}
|
|
391
|
+
__internal__rebuild(modifiedFiles, removedFiles, callback) {
|
|
392
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
393
|
+
if (error) {
|
|
394
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
429
395
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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();
|
|
396
|
+
instance.rebuild(Array.from(modifiedFiles || []), Array.from(removedFiles || []), error => {
|
|
397
|
+
if (error) {
|
|
398
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
441
399
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
return childCompiler;
|
|
446
|
-
}
|
|
447
|
-
isChild() {
|
|
448
|
-
const isRoot = this.root === this;
|
|
449
|
-
return !isRoot;
|
|
400
|
+
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
401
|
+
});
|
|
402
|
+
});
|
|
450
403
|
}
|
|
451
404
|
compile(callback) {
|
|
452
405
|
const startTime = Date.now();
|
|
@@ -461,17 +414,33 @@ class Compiler {
|
|
|
461
414
|
if (err) {
|
|
462
415
|
return callback(err);
|
|
463
416
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
this.hooks.afterCompile.callAsync(
|
|
417
|
+
this.compilation.startTime = startTime;
|
|
418
|
+
this.compilation.endTime = Date.now();
|
|
419
|
+
this.hooks.afterCompile.callAsync(this.compilation, err => {
|
|
467
420
|
if (err) {
|
|
468
421
|
return callback(err);
|
|
469
422
|
}
|
|
470
|
-
return callback(null,
|
|
423
|
+
return callback(null, this.compilation);
|
|
471
424
|
});
|
|
472
425
|
});
|
|
473
426
|
});
|
|
474
427
|
}
|
|
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
|
+
}
|
|
475
444
|
close(callback) {
|
|
476
445
|
if (this.watching) {
|
|
477
446
|
// When there is still an active watching, close this #initial
|
|
@@ -486,77 +455,22 @@ class Compiler {
|
|
|
486
455
|
this.cache.shutdown(callback);
|
|
487
456
|
});
|
|
488
457
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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
|
-
});
|
|
458
|
+
getAsset(name) {
|
|
459
|
+
let source = this.compilation.__internal__getAssetSource(name);
|
|
460
|
+
if (!source) {
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
return source.buffer();
|
|
505
464
|
}
|
|
506
465
|
__internal__registerBuiltinPlugin(plugin) {
|
|
507
|
-
|
|
466
|
+
this.builtinPlugins.push(plugin);
|
|
508
467
|
}
|
|
509
468
|
__internal__getModuleExecutionResult(id) {
|
|
510
469
|
return __classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").get(id);
|
|
511
470
|
}
|
|
512
471
|
}
|
|
513
472
|
exports.Compiler = Compiler;
|
|
514
|
-
_Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(),
|
|
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) {
|
|
473
|
+
_Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Compiler_nonSkippableRegisters = new WeakMap(), _Compiler_registers = new WeakMap(), _Compiler_moduleExecutionResultsMap = new WeakMap(), _Compiler_instances = new WeakSet(), _Compiler_getInstance = function _Compiler_getInstance(callback) {
|
|
560
474
|
const error = (0, bindingVersionCheck_1.checkVersion)();
|
|
561
475
|
if (error) {
|
|
562
476
|
return callback(error);
|
|
@@ -571,20 +485,20 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
571
485
|
const instanceBinding = require("@rspack/binding");
|
|
572
486
|
__classPrivateFieldSet(this, _Compiler_registers, {
|
|
573
487
|
registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerThisCompilation, () => this.hooks.thisCompilation, queried => (native) => {
|
|
574
|
-
if (
|
|
488
|
+
if (this.compilation === undefined) {
|
|
575
489
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createCompilation).call(this, native);
|
|
576
490
|
}
|
|
577
|
-
queried.call(
|
|
491
|
+
queried.call(this.compilation, this.compilationParams);
|
|
578
492
|
}),
|
|
579
|
-
registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerCompilation, () => this.hooks.compilation, queried => () => queried.call(
|
|
580
|
-
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerMake, () => this.hooks.make, queried => async () => await queried.promise(
|
|
581
|
-
registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerFinishMake, () => this.hooks.finishMake, queried => async () => await queried.promise(
|
|
582
|
-
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerShouldEmit, () => this.hooks.shouldEmit, queried => () => queried.call(
|
|
583
|
-
registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerEmit, () => this.hooks.emit, queried => async () => await queried.promise(
|
|
584
|
-
registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAfterEmit, () => this.hooks.afterEmit, queried => async () => await queried.promise(
|
|
493
|
+
registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerCompilation, () => this.hooks.compilation, queried => () => queried.call(this.compilation, this.compilationParams)),
|
|
494
|
+
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerMake, () => this.hooks.make, queried => async () => await queried.promise(this.compilation)),
|
|
495
|
+
registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerFinishMake, () => this.hooks.finishMake, queried => async () => await queried.promise(this.compilation)),
|
|
496
|
+
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerShouldEmit, () => this.hooks.shouldEmit, queried => () => queried.call(this.compilation)),
|
|
497
|
+
registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerEmit, () => this.hooks.emit, queried => async () => await queried.promise(this.compilation)),
|
|
498
|
+
registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAfterEmit, () => this.hooks.afterEmit, queried => async () => await queried.promise(this.compilation)),
|
|
585
499
|
registerCompilerAssetEmittedTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilerAssetEmitted, () => this.hooks.assetEmitted, queried => async ({ filename, targetPath, outputPath }) => {
|
|
586
500
|
return queried.promise(filename, {
|
|
587
|
-
compilation:
|
|
501
|
+
compilation: this.compilation,
|
|
588
502
|
targetPath,
|
|
589
503
|
outputPath,
|
|
590
504
|
get source() {
|
|
@@ -597,20 +511,20 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
597
511
|
}
|
|
598
512
|
});
|
|
599
513
|
}),
|
|
600
|
-
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeModule, () =>
|
|
514
|
+
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeModule, () => this.compilation.hooks.runtimeModule, queried => ({ module, chunk }) => {
|
|
601
515
|
var _a, _b;
|
|
602
516
|
const originSource = (_a = module.source) === null || _a === void 0 ? void 0 : _a.source;
|
|
603
|
-
queried.call(module, Chunk_1.Chunk.__from_binding(chunk,
|
|
517
|
+
queried.call(module, Chunk_1.Chunk.__from_binding(chunk, this.compilation));
|
|
604
518
|
const newSource = (_b = module.source) === null || _b === void 0 ? void 0 : _b.source;
|
|
605
519
|
if (newSource && newSource !== originSource) {
|
|
606
520
|
return module;
|
|
607
521
|
}
|
|
608
522
|
return;
|
|
609
523
|
}),
|
|
610
|
-
registerCompilationBuildModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationBuildModule, () =>
|
|
611
|
-
registerCompilationStillValidModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationStillValidModule, () =>
|
|
612
|
-
registerCompilationSucceedModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationSucceedModule, () =>
|
|
613
|
-
registerCompilationExecuteModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationExecuteModule, () =>
|
|
524
|
+
registerCompilationBuildModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationBuildModule, () => this.compilation.hooks.buildModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
525
|
+
registerCompilationStillValidModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationStillValidModule, () => this.compilation.hooks.stillValidModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
526
|
+
registerCompilationSucceedModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationSucceedModule, () => this.compilation.hooks.succeedModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
527
|
+
registerCompilationExecuteModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationExecuteModule, () => this.compilation.hooks.executeModule, queried => ({ entry, id, codegenResults, runtimeModules }) => {
|
|
614
528
|
const __webpack_require__ = (id) => {
|
|
615
529
|
const cached = moduleCache[id];
|
|
616
530
|
if (cached !== undefined) {
|
|
@@ -648,16 +562,16 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
648
562
|
const executeResult = __webpack_require__(entry);
|
|
649
563
|
__classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").set(id, executeResult);
|
|
650
564
|
}),
|
|
651
|
-
registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationFinishModules, () =>
|
|
652
|
-
registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeModules, () =>
|
|
653
|
-
registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterOptimizeModules, () =>
|
|
654
|
-
registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeTree, () =>
|
|
655
|
-
registerCompilationOptimizeChunkModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeChunkModules, () =>
|
|
656
|
-
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkAsset, () =>
|
|
657
|
-
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationProcessAssets, () =>
|
|
658
|
-
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () =>
|
|
659
|
-
registerCompilationAfterSealTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterSeal, () =>
|
|
660
|
-
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () =>
|
|
565
|
+
registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationFinishModules, () => this.compilation.hooks.finishModules, queried => async () => await queried.promise(this.compilation.modules)),
|
|
566
|
+
registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeModules, () => this.compilation.hooks.optimizeModules, queried => () => queried.call(this.compilation.modules)),
|
|
567
|
+
registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterOptimizeModules, () => this.compilation.hooks.afterOptimizeModules, queried => () => queried.call(this.compilation.modules)),
|
|
568
|
+
registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeTree, () => this.compilation.hooks.optimizeTree, queried => async () => await queried.promise(this.compilation.chunks, this.compilation.modules)),
|
|
569
|
+
registerCompilationOptimizeChunkModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeChunkModules, () => this.compilation.hooks.optimizeChunkModules, queried => async () => await queried.promise(this.compilation.chunks, this.compilation.modules)),
|
|
570
|
+
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkAsset, () => this.compilation.hooks.chunkAsset, queried => ({ chunk, filename }) => queried.call(Chunk_1.Chunk.__from_binding(chunk, this.compilation), filename)),
|
|
571
|
+
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationProcessAssets, () => this.compilation.hooks.processAssets, queried => async () => await queried.promise(this.compilation.assets)),
|
|
572
|
+
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () => this.compilation.hooks.afterProcessAssets, queried => () => queried.call(this.compilation.assets)),
|
|
573
|
+
registerCompilationAfterSealTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterSeal, () => this.compilation.hooks.afterSeal, queried => async () => await queried.promise()),
|
|
574
|
+
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
661
575
|
const normalizedResolveData = {
|
|
662
576
|
request: resolveData.request,
|
|
663
577
|
context: resolveData.context,
|
|
@@ -670,13 +584,13 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
670
584
|
resolveData.context = normalizedResolveData.context;
|
|
671
585
|
return [ret, resolveData];
|
|
672
586
|
}),
|
|
673
|
-
registerNormalModuleFactoryResolveForSchemeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookMapRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryResolveForScheme, () =>
|
|
587
|
+
registerNormalModuleFactoryResolveForSchemeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookMapRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryResolveForScheme, () => this.compilationParams.normalModuleFactory.hooks.resolveForScheme, queried => async (args) => {
|
|
674
588
|
const ret = await queried
|
|
675
589
|
.for(args.scheme)
|
|
676
590
|
.promise(args.resourceData);
|
|
677
591
|
return [ret, args.resourceData];
|
|
678
592
|
}),
|
|
679
|
-
registerNormalModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryAfterResolve, () =>
|
|
593
|
+
registerNormalModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryAfterResolve, () => this.compilationParams.normalModuleFactory.hooks.afterResolve, queried => async (arg) => {
|
|
680
594
|
const data = {
|
|
681
595
|
request: arg.request,
|
|
682
596
|
context: arg.context,
|
|
@@ -688,17 +602,17 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
688
602
|
const ret = await queried.promise(data);
|
|
689
603
|
return [ret, data.createData];
|
|
690
604
|
}),
|
|
691
|
-
registerNormalModuleFactoryCreateModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryCreateModule, () =>
|
|
605
|
+
registerNormalModuleFactoryCreateModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryCreateModule, () => this.compilationParams.normalModuleFactory.hooks.createModule, queried => async (args) => {
|
|
692
606
|
const data = {
|
|
693
607
|
...args,
|
|
694
608
|
settings: {}
|
|
695
609
|
};
|
|
696
610
|
await queried.promise(data, {});
|
|
697
611
|
}),
|
|
698
|
-
registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () =>
|
|
612
|
+
registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => this.compilationParams.contextModuleFactory.hooks.beforeResolve, queried => async (bindingData) => {
|
|
699
613
|
return queried.promise(bindingData);
|
|
700
614
|
}),
|
|
701
|
-
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryAfterResolve, () =>
|
|
615
|
+
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryAfterResolve, () => this.compilationParams.contextModuleFactory.hooks.afterResolve, queried => async (bindingData) => {
|
|
702
616
|
var _a;
|
|
703
617
|
const data = bindingData
|
|
704
618
|
? ({
|
|
@@ -724,7 +638,7 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
724
638
|
return result;
|
|
725
639
|
})
|
|
726
640
|
}, "f");
|
|
727
|
-
__classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions,
|
|
641
|
+
__classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins, __classPrivateFieldGet(this, _Compiler_registers, "f"), (0, fileSystem_1.createThreadsafeNodeFSFromRaw)(this.outputFileSystem)), "f");
|
|
728
642
|
callback(null, __classPrivateFieldGet(this, _Compiler_instance, "f"));
|
|
729
643
|
}, _Compiler_updateNonSkippableRegisters = function _Compiler_updateNonSkippableRegisters() {
|
|
730
644
|
const kinds = [];
|
|
@@ -815,4 +729,49 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
815
729
|
getTaps.registerKind = registerKind;
|
|
816
730
|
getTaps.getHookMap = getHookMap;
|
|
817
731
|
return getTaps;
|
|
732
|
+
}, _Compiler_build = function _Compiler_build(callback) {
|
|
733
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (error, instance) => {
|
|
734
|
+
if (error) {
|
|
735
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
736
|
+
}
|
|
737
|
+
if (!__classPrivateFieldGet(this, _Compiler_initial, "f")) {
|
|
738
|
+
instance.rebuild(Array.from(this.modifiedFiles || []), Array.from(this.removedFiles || []), error => {
|
|
739
|
+
if (error) {
|
|
740
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
741
|
+
}
|
|
742
|
+
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
743
|
+
});
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
__classPrivateFieldSet(this, _Compiler_initial, false, "f");
|
|
747
|
+
instance.build(error => {
|
|
748
|
+
if (error) {
|
|
749
|
+
return callback === null || callback === void 0 ? void 0 : callback(error);
|
|
750
|
+
}
|
|
751
|
+
callback === null || callback === void 0 ? void 0 : callback(null);
|
|
752
|
+
});
|
|
753
|
+
});
|
|
754
|
+
}, _Compiler_createCompilation = function _Compiler_createCompilation(native) {
|
|
755
|
+
const compilation = new Compilation_1.Compilation(this, native);
|
|
756
|
+
compilation.name = this.name;
|
|
757
|
+
this.compilation = compilation;
|
|
758
|
+
return compilation;
|
|
759
|
+
}, _Compiler_resetThisCompilation = function _Compiler_resetThisCompilation() {
|
|
760
|
+
// reassign new compilation in thisCompilation
|
|
761
|
+
this.compilation = undefined;
|
|
762
|
+
// ensure thisCompilation must call
|
|
763
|
+
this.hooks.thisCompilation.intercept({
|
|
764
|
+
call: () => { }
|
|
765
|
+
});
|
|
766
|
+
}, _Compiler_newCompilationParams = function _Compiler_newCompilationParams() {
|
|
767
|
+
const normalModuleFactory = new NormalModuleFactory_1.NormalModuleFactory();
|
|
768
|
+
this.hooks.normalModuleFactory.call(normalModuleFactory);
|
|
769
|
+
const contextModuleFactory = new ContextModuleFactory_1.ContextModuleFactory();
|
|
770
|
+
this.hooks.contextModuleFactory.call(contextModuleFactory);
|
|
771
|
+
const params = {
|
|
772
|
+
normalModuleFactory,
|
|
773
|
+
contextModuleFactory
|
|
774
|
+
};
|
|
775
|
+
this.compilationParams = params;
|
|
776
|
+
return params;
|
|
818
777
|
};
|