@rspack/core 0.5.8 → 0.5.9
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 +2 -0
- package/dist/Chunk.js +4 -0
- package/dist/Compilation.d.ts +25 -26
- package/dist/Compilation.js +16 -16
- package/dist/Compiler.d.ts +12 -5
- package/dist/Compiler.js +83 -138
- package/dist/Module.d.ts +3 -0
- package/dist/Module.js +12 -0
- 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 +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/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/ElectronTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +11 -10
- package/dist/builtin-plugin/EnableLibraryPlugin.js +39 -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 +3 -3
- 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 +1 -1
- 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 +1 -1
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.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/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/RuntimePlugin.d.ts +1 -1
- package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
- 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/base.d.ts +2 -2
- package/dist/config/normalization.js +1 -1
- package/dist/config/zod.d.ts +359 -51
- package/dist/config/zod.js +8 -5
- package/dist/container/ContainerPlugin.d.ts +2 -2
- package/dist/exports.d.ts +74 -29
- package/dist/sharing/ShareRuntimePlugin.d.ts +1 -1
- package/dist/sharing/ShareRuntimePlugin.js +1 -1
- package/package.json +5 -5
- package/dist/util/normalization.d.ts +0 -5
- package/dist/util/normalization.js +0 -9
package/dist/Chunk.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type JsChunk, type JsCompilation } from "@rspack/binding";
|
|
2
2
|
import { ChunkGroup } from "./ChunkGroup";
|
|
3
|
+
import { Compilation } from ".";
|
|
3
4
|
export declare class Chunk {
|
|
4
5
|
#private;
|
|
5
6
|
name?: string;
|
|
@@ -15,6 +16,7 @@ export declare class Chunk {
|
|
|
15
16
|
renderedHash?: string;
|
|
16
17
|
chunkReasons: Array<string>;
|
|
17
18
|
auxiliaryFiles: Array<string>;
|
|
19
|
+
static __from_binding(chunk: JsChunk, compilation: Compilation): Chunk;
|
|
18
20
|
static __from_binding(chunk: JsChunk, compilation: JsCompilation): Chunk;
|
|
19
21
|
constructor(chunk: JsChunk, compilation: JsCompilation);
|
|
20
22
|
isOnlyInitial(): boolean;
|
package/dist/Chunk.js
CHANGED
|
@@ -16,8 +16,12 @@ exports.Chunk = void 0;
|
|
|
16
16
|
const binding_1 = require("@rspack/binding");
|
|
17
17
|
const ChunkGroup_1 = require("./ChunkGroup");
|
|
18
18
|
const comparators_1 = require("./util/comparators");
|
|
19
|
+
const _1 = require(".");
|
|
19
20
|
class Chunk {
|
|
20
21
|
static __from_binding(chunk, compilation) {
|
|
22
|
+
if (compilation instanceof _1.Compilation) {
|
|
23
|
+
return new Chunk(chunk, compilation.__internal_getInner());
|
|
24
|
+
}
|
|
21
25
|
return new Chunk(chunk, compilation);
|
|
22
26
|
}
|
|
23
27
|
constructor(chunk, compilation) {
|
package/dist/Compilation.d.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import * as tapable from "tapable";
|
|
12
12
|
import { Source } from "webpack-sources";
|
|
13
|
-
import type { ExternalObject, JsAssetInfo,
|
|
14
|
-
import { RspackOptionsNormalized, StatsOptions, OutputNormalized, StatsValue, RspackPluginInstance } from "./config";
|
|
13
|
+
import type { ExternalObject, JsAssetInfo, JsCompatSource, JsCompilation, JsModule, JsRuntimeModule, JsStatsChunk, JsStatsError, PathData } from "@rspack/binding";
|
|
14
|
+
import { RspackOptionsNormalized, StatsOptions, OutputNormalized, StatsValue, RspackPluginInstance, Filename } from "./config";
|
|
15
15
|
import * as liteTapable from "./lite-tapable";
|
|
16
16
|
import { ContextModuleFactory } from "./ContextModuleFactory";
|
|
17
17
|
import ResolverFactory from "./ResolverFactory";
|
|
@@ -21,10 +21,9 @@ import { NormalModuleFactory } from "./NormalModuleFactory";
|
|
|
21
21
|
import { Stats } from "./Stats";
|
|
22
22
|
import { StatsFactory } from "./stats/StatsFactory";
|
|
23
23
|
import { StatsPrinter } from "./stats/StatsPrinter";
|
|
24
|
-
import { NormalizedJsModule } from "./util/normalization";
|
|
25
24
|
import MergeCaller from "./util/MergeCaller";
|
|
26
25
|
import { Chunk } from "./Chunk";
|
|
27
|
-
import { CodeGenerationResult } from "./Module";
|
|
26
|
+
import { CodeGenerationResult, Module } from "./Module";
|
|
28
27
|
import { ChunkGraph } from "./ChunkGraph";
|
|
29
28
|
import { Entrypoint } from "./Entrypoint";
|
|
30
29
|
export type AssetInfo = Partial<JsAssetInfo> & Record<string, any>;
|
|
@@ -64,33 +63,33 @@ export declare class Compilation {
|
|
|
64
63
|
#private;
|
|
65
64
|
hooks: {
|
|
66
65
|
processAssets: liteTapable.AsyncSeriesHook<Assets>;
|
|
67
|
-
afterProcessAssets:
|
|
66
|
+
afterProcessAssets: liteTapable.SyncHook<Assets>;
|
|
68
67
|
childCompiler: tapable.SyncHook<[Compiler, string, number]>;
|
|
69
68
|
log: tapable.SyncBailHook<[string, LogEntry], true>;
|
|
70
69
|
additionalAssets: any;
|
|
71
|
-
optimizeModules:
|
|
72
|
-
afterOptimizeModules:
|
|
73
|
-
optimizeTree:
|
|
70
|
+
optimizeModules: liteTapable.SyncBailHook<Iterable<Module>, void>;
|
|
71
|
+
afterOptimizeModules: liteTapable.SyncHook<Iterable<Module>, void>;
|
|
72
|
+
optimizeTree: liteTapable.AsyncSeriesHook<[
|
|
74
73
|
Iterable<Chunk>,
|
|
75
|
-
Iterable<
|
|
76
|
-
]
|
|
77
|
-
optimizeChunkModules:
|
|
74
|
+
Iterable<Module>
|
|
75
|
+
]>;
|
|
76
|
+
optimizeChunkModules: liteTapable.AsyncSeriesBailHook<[
|
|
78
77
|
Iterable<Chunk>,
|
|
79
|
-
Iterable<
|
|
78
|
+
Iterable<Module>
|
|
80
79
|
], void>;
|
|
81
|
-
finishModules:
|
|
82
|
-
chunkAsset:
|
|
80
|
+
finishModules: liteTapable.AsyncSeriesHook<[Iterable<Module>], void>;
|
|
81
|
+
chunkAsset: liteTapable.SyncHook<[Chunk, string], void>;
|
|
83
82
|
processWarnings: tapable.SyncWaterfallHook<[Error[]]>;
|
|
84
|
-
succeedModule:
|
|
85
|
-
stillValidModule:
|
|
83
|
+
succeedModule: liteTapable.SyncHook<[Module], void>;
|
|
84
|
+
stillValidModule: liteTapable.SyncHook<[Module], void>;
|
|
86
85
|
statsFactory: tapable.SyncHook<[StatsFactory, StatsOptions], void>;
|
|
87
86
|
statsPrinter: tapable.SyncHook<[StatsPrinter, StatsOptions], void>;
|
|
88
|
-
buildModule:
|
|
89
|
-
executeModule:
|
|
87
|
+
buildModule: liteTapable.SyncHook<[Module]>;
|
|
88
|
+
executeModule: liteTapable.SyncHook<[
|
|
90
89
|
ExecuteModuleArgument,
|
|
91
90
|
ExecuteModuleContext
|
|
92
91
|
]>;
|
|
93
|
-
runtimeModule:
|
|
92
|
+
runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>;
|
|
94
93
|
};
|
|
95
94
|
options: RspackOptionsNormalized;
|
|
96
95
|
outputOptions: OutputNormalized;
|
|
@@ -197,10 +196,10 @@ export declare class Compilation {
|
|
|
197
196
|
};
|
|
198
197
|
};
|
|
199
198
|
};
|
|
200
|
-
getPath(filename:
|
|
201
|
-
getPathWithInfo(filename:
|
|
202
|
-
getAssetPath(filename:
|
|
203
|
-
getAssetPathWithInfo(filename:
|
|
199
|
+
getPath(filename: Filename, data?: PathData): string;
|
|
200
|
+
getPathWithInfo(filename: Filename, data?: PathData): import("@rspack/binding").PathWithInfo;
|
|
201
|
+
getAssetPath(filename: Filename, data?: PathData): string;
|
|
202
|
+
getAssetPathWithInfo(filename: Filename, data?: PathData): import("@rspack/binding").PathWithInfo;
|
|
204
203
|
getLogger(name: string | (() => string)): Logger;
|
|
205
204
|
fileDependencies: {
|
|
206
205
|
[Symbol.iterator](): Generator<string, void, unknown>;
|
|
@@ -226,7 +225,7 @@ export declare class Compilation {
|
|
|
226
225
|
add: (dep: string) => void;
|
|
227
226
|
addAll: (deps: Iterable<string>) => void;
|
|
228
227
|
};
|
|
229
|
-
get modules():
|
|
228
|
+
get modules(): Module[];
|
|
230
229
|
get chunks(): Chunk[];
|
|
231
230
|
/**
|
|
232
231
|
* Get the named chunks.
|
|
@@ -266,8 +265,8 @@ export declare class Compilation {
|
|
|
266
265
|
__internal__getChunks(): Chunk[];
|
|
267
266
|
getStats(): Stats;
|
|
268
267
|
createChildCompiler(name: string, outputOptions: OutputNormalized, plugins: RspackPluginInstance[]): Compiler;
|
|
269
|
-
_rebuildModuleCaller: MergeCaller<[string, (err:
|
|
270
|
-
rebuildModule(m:
|
|
268
|
+
_rebuildModuleCaller: MergeCaller<[string, (err: Error, m: Module) => void]>;
|
|
269
|
+
rebuildModule(m: Module, f: (err: Error, m: Module) => void): void;
|
|
271
270
|
/**
|
|
272
271
|
* Get the `Source` of a given asset filename.
|
|
273
272
|
*
|
package/dist/Compilation.js
CHANGED
|
@@ -59,10 +59,10 @@ const StatsPrinter_1 = require("./stats/StatsPrinter");
|
|
|
59
59
|
const util_1 = require("./util");
|
|
60
60
|
const createSource_1 = require("./util/createSource");
|
|
61
61
|
const fake_1 = require("./util/fake");
|
|
62
|
-
const normalization_1 = require("./util/normalization");
|
|
63
62
|
const MergeCaller_1 = __importDefault(require("./util/MergeCaller"));
|
|
64
63
|
const memoize_1 = require("./util/memoize");
|
|
65
64
|
const Chunk_1 = require("./Chunk");
|
|
65
|
+
const Module_1 = require("./Module");
|
|
66
66
|
const ChunkGraph_1 = require("./ChunkGraph");
|
|
67
67
|
const Entrypoint_1 = require("./Entrypoint");
|
|
68
68
|
class Compilation {
|
|
@@ -85,7 +85,7 @@ class Compilation {
|
|
|
85
85
|
for (const [id, callback] of args) {
|
|
86
86
|
const m = modules.find(item => item.moduleIdentifier === id);
|
|
87
87
|
if (m) {
|
|
88
|
-
callback(err, m);
|
|
88
|
+
callback(err, Module_1.Module.__from_binding(m));
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
91
|
callback(err || new Error("module no found"), null);
|
|
@@ -129,7 +129,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
129
129
|
};
|
|
130
130
|
this.hooks = {
|
|
131
131
|
processAssets: processAssetsHook,
|
|
132
|
-
afterProcessAssets: new
|
|
132
|
+
afterProcessAssets: new liteTapable.SyncHook(["assets"]),
|
|
133
133
|
/** @deprecated */
|
|
134
134
|
additionalAssets: createProcessAssetsHook("additionalAssets", Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL, () => []),
|
|
135
135
|
childCompiler: new tapable.SyncHook([
|
|
@@ -138,23 +138,23 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
138
138
|
"compilerIndex"
|
|
139
139
|
]),
|
|
140
140
|
log: new tapable.SyncBailHook(["origin", "logEntry"]),
|
|
141
|
-
optimizeModules: new
|
|
142
|
-
afterOptimizeModules: new
|
|
143
|
-
optimizeTree: new
|
|
144
|
-
optimizeChunkModules: new
|
|
141
|
+
optimizeModules: new liteTapable.SyncBailHook(["modules"]),
|
|
142
|
+
afterOptimizeModules: new liteTapable.SyncBailHook(["modules"]),
|
|
143
|
+
optimizeTree: new liteTapable.AsyncSeriesHook(["chunks", "modules"]),
|
|
144
|
+
optimizeChunkModules: new liteTapable.AsyncSeriesBailHook([
|
|
145
145
|
"chunks",
|
|
146
146
|
"modules"
|
|
147
147
|
]),
|
|
148
|
-
finishModules: new
|
|
149
|
-
chunkAsset: new
|
|
148
|
+
finishModules: new liteTapable.AsyncSeriesHook(["modules"]),
|
|
149
|
+
chunkAsset: new liteTapable.SyncHook(["chunk", "filename"]),
|
|
150
150
|
processWarnings: new tapable.SyncWaterfallHook(["warnings"]),
|
|
151
|
-
succeedModule: new
|
|
152
|
-
stillValidModule: new
|
|
151
|
+
succeedModule: new liteTapable.SyncHook(["module"]),
|
|
152
|
+
stillValidModule: new liteTapable.SyncHook(["module"]),
|
|
153
153
|
statsFactory: new tapable.SyncHook(["statsFactory", "options"]),
|
|
154
154
|
statsPrinter: new tapable.SyncHook(["statsPrinter", "options"]),
|
|
155
|
-
buildModule: new
|
|
156
|
-
executeModule: new
|
|
157
|
-
runtimeModule: new
|
|
155
|
+
buildModule: new liteTapable.SyncHook(["module"]),
|
|
156
|
+
executeModule: new liteTapable.SyncHook(["options", "context"]),
|
|
157
|
+
runtimeModule: new liteTapable.SyncHook(["module", "chunk"])
|
|
158
158
|
};
|
|
159
159
|
this.compiler = compiler;
|
|
160
160
|
this.resolverFactory = compiler.resolverFactory;
|
|
@@ -549,7 +549,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
549
549
|
}
|
|
550
550
|
get modules() {
|
|
551
551
|
return (0, memoize_1.memoizeValue)(() => {
|
|
552
|
-
return this.__internal__getModules().map(item =>
|
|
552
|
+
return this.__internal__getModules().map(item => Module_1.Module.__from_binding(item));
|
|
553
553
|
});
|
|
554
554
|
}
|
|
555
555
|
// FIXME: This is not aligned with Webpack.
|
|
@@ -644,7 +644,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
644
644
|
return this.compiler.createChildCompiler(this, name, idx, outputOptions, plugins);
|
|
645
645
|
}
|
|
646
646
|
rebuildModule(m, f) {
|
|
647
|
-
this._rebuildModuleCaller.push([m.
|
|
647
|
+
this._rebuildModuleCaller.push([m.identifier(), f]);
|
|
648
648
|
}
|
|
649
649
|
/**
|
|
650
650
|
* Get the `Source` of a given asset filename.
|
package/dist/Compiler.d.ts
CHANGED
|
@@ -26,6 +26,14 @@ import { NormalModuleFactory } from "./NormalModuleFactory";
|
|
|
26
26
|
import { WatchFileSystem } from "./util/fs";
|
|
27
27
|
import { Watching } from "./Watching";
|
|
28
28
|
import { FileSystemInfoEntry } from "./FileSystemInfo";
|
|
29
|
+
import { Source } from "webpack-sources";
|
|
30
|
+
export interface AssetEmittedInfo {
|
|
31
|
+
content: Buffer;
|
|
32
|
+
source: Source;
|
|
33
|
+
outputPath: string;
|
|
34
|
+
targetPath: string;
|
|
35
|
+
compilation: Compilation;
|
|
36
|
+
}
|
|
29
37
|
declare class Compiler {
|
|
30
38
|
#private;
|
|
31
39
|
webpack: typeof import("./rspack").rspack & typeof import("./exports") & {
|
|
@@ -71,9 +79,9 @@ declare class Compiler {
|
|
|
71
79
|
infrastructureLog: tapable.SyncBailHook<[string, string, any[]], true>;
|
|
72
80
|
beforeRun: tapable.AsyncSeriesHook<[Compiler]>;
|
|
73
81
|
run: tapable.AsyncSeriesHook<[Compiler]>;
|
|
74
|
-
emit:
|
|
75
|
-
assetEmitted:
|
|
76
|
-
afterEmit:
|
|
82
|
+
emit: liteTapable.AsyncSeriesHook<[Compilation]>;
|
|
83
|
+
assetEmitted: liteTapable.AsyncSeriesHook<[string, AssetEmittedInfo]>;
|
|
84
|
+
afterEmit: liteTapable.AsyncSeriesHook<[Compilation]>;
|
|
77
85
|
failed: tapable.SyncHook<[Error]>;
|
|
78
86
|
shutdown: tapable.AsyncSeriesHook<[]>;
|
|
79
87
|
watchRun: tapable.AsyncSeriesHook<[Compiler]>;
|
|
@@ -85,8 +93,7 @@ declare class Compiler {
|
|
|
85
93
|
make: liteTapable.AsyncParallelHook<[Compilation]>;
|
|
86
94
|
beforeCompile: tapable.AsyncSeriesHook<[CompilationParams]>;
|
|
87
95
|
afterCompile: tapable.AsyncSeriesHook<[Compilation]>;
|
|
88
|
-
|
|
89
|
-
finishMake: tapable.AsyncSeriesHook<[Compilation]>;
|
|
96
|
+
finishMake: liteTapable.AsyncSeriesHook<[Compilation]>;
|
|
90
97
|
entryOption: tapable.SyncBailHook<[string, EntryNormalized], any>;
|
|
91
98
|
};
|
|
92
99
|
options: RspackOptionsNormalized;
|
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_disabledHooks, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateDisabledHooks,
|
|
39
|
+
var _Compiler_instances, _Compiler_instance, _Compiler_disabledHooks, _Compiler_moduleExecutionResultsMap, _Compiler_getInstance, _Compiler_updateDisabledHooks, _Compiler_afterProcessAssets, _Compiler_afterResolve, _Compiler_contextModuleFactoryBeforeResolve, _Compiler_contextModuleFactoryAfterResolve, _Compiler_normalModuleFactoryCreateModule, _Compiler_normalModuleFactoryResolveForScheme, _Compiler_optimizeChunkModules, _Compiler_optimizeTree, _Compiler_decorateUpdateDisabledHooks, _Compiler_createRegisterTaps, _Compiler_createCompilation, _Compiler_resetThisCompilation, _Compiler_newCompilationParams;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.Compiler = void 0;
|
|
42
42
|
const index_1 = require("./index");
|
|
@@ -44,12 +44,12 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
44
44
|
const tapable = __importStar(require("tapable"));
|
|
45
45
|
const liteTapable = __importStar(require("./lite-tapable"));
|
|
46
46
|
const tapable_1 = require("tapable");
|
|
47
|
+
const config_1 = require("./config");
|
|
47
48
|
const RuleSetCompiler_1 = require("./RuleSetCompiler");
|
|
48
49
|
const Stats_1 = require("./Stats");
|
|
49
50
|
const Compilation_1 = require("./Compilation");
|
|
50
51
|
const ContextModuleFactory_1 = require("./ContextModuleFactory");
|
|
51
52
|
const ResolverFactory_1 = __importDefault(require("./ResolverFactory"));
|
|
52
|
-
const config_1 = require("./config");
|
|
53
53
|
const ConcurrentCompilationError_1 = __importDefault(require("./error/ConcurrentCompilationError"));
|
|
54
54
|
const fileSystem_1 = require("./fileSystem");
|
|
55
55
|
const Cache_1 = __importDefault(require("./lib/Cache"));
|
|
@@ -59,7 +59,6 @@ const NormalModuleFactory_1 = require("./NormalModuleFactory");
|
|
|
59
59
|
const bindingVersionCheck_1 = require("./util/bindingVersionCheck");
|
|
60
60
|
const Watching_1 = require("./Watching");
|
|
61
61
|
const NormalModule_1 = require("./NormalModule");
|
|
62
|
-
const normalization_1 = require("./util/normalization");
|
|
63
62
|
const builtin_plugin_1 = require("./builtin-plugin");
|
|
64
63
|
const rspackOptionsApply_1 = require("./rspackOptionsApply");
|
|
65
64
|
const defaults_1 = require("./config/defaults");
|
|
@@ -69,6 +68,7 @@ const HookWebpackError_1 = require("./lib/HookWebpackError");
|
|
|
69
68
|
const Module_1 = require("./Module");
|
|
70
69
|
const base_1 = require("./builtin-plugin/base");
|
|
71
70
|
const ExecuteModulePlugin_1 = __importDefault(require("./ExecuteModulePlugin"));
|
|
71
|
+
const Chunk_1 = require("./Chunk");
|
|
72
72
|
class Compiler {
|
|
73
73
|
constructor(context, options) {
|
|
74
74
|
_Compiler_instances.add(this);
|
|
@@ -98,9 +98,9 @@ class Compiler {
|
|
|
98
98
|
afterDone: new tapable.SyncHook(["stats"]),
|
|
99
99
|
beforeRun: new tapable.AsyncSeriesHook(["compiler"]),
|
|
100
100
|
run: new tapable.AsyncSeriesHook(["compiler"]),
|
|
101
|
-
emit: new
|
|
102
|
-
assetEmitted: new
|
|
103
|
-
afterEmit: new
|
|
101
|
+
emit: new liteTapable.AsyncSeriesHook(["compilation"]),
|
|
102
|
+
assetEmitted: new liteTapable.AsyncSeriesHook(["file", "info"]),
|
|
103
|
+
afterEmit: new liteTapable.AsyncSeriesHook(["compilation"]),
|
|
104
104
|
thisCompilation: new liteTapable.SyncHook(["compilation", "params"]),
|
|
105
105
|
compilation: new liteTapable.SyncHook([
|
|
106
106
|
"compilation",
|
|
@@ -126,8 +126,7 @@ class Compiler {
|
|
|
126
126
|
make: new liteTapable.AsyncParallelHook(["compilation"]),
|
|
127
127
|
beforeCompile: new tapable.AsyncSeriesHook(["params"]),
|
|
128
128
|
afterCompile: new tapable.AsyncSeriesHook(["compilation"]),
|
|
129
|
-
finishMake: new
|
|
130
|
-
finishModules: new tapable.AsyncSeriesHook(["modules"]),
|
|
129
|
+
finishMake: new liteTapable.AsyncSeriesHook(["compilation"]),
|
|
131
130
|
entryOption: new tapable.SyncBailHook(["context", "entry"])
|
|
132
131
|
};
|
|
133
132
|
this.modifiedFiles = undefined;
|
|
@@ -503,27 +502,11 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
503
502
|
const rawOptions = (0, config_1.getRawOptions)(options, this);
|
|
504
503
|
const instanceBinding = require("@rspack/binding");
|
|
505
504
|
__classPrivateFieldSet(this, _Compiler_instance, new instanceBinding.Rspack(rawOptions, this.builtinPlugins, {
|
|
506
|
-
finishMake: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_finishMake).bind(this),
|
|
507
|
-
emit: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_emit).bind(this),
|
|
508
|
-
assetEmitted: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_assetEmitted).bind(this),
|
|
509
|
-
afterEmit: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterEmit).bind(this),
|
|
510
|
-
afterProcessAssets: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterProcessAssets).bind(this),
|
|
511
|
-
optimizeModules: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_optimizeModules).bind(this),
|
|
512
|
-
afterOptimizeModules: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterOptimizeModules).bind(this),
|
|
513
|
-
optimizeTree: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_optimizeTree).bind(this),
|
|
514
|
-
optimizeChunkModules: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_optimizeChunkModules).bind(this),
|
|
515
|
-
finishModules: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_finishModules).bind(this),
|
|
516
505
|
normalModuleFactoryCreateModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryCreateModule).bind(this),
|
|
517
506
|
normalModuleFactoryResolveForScheme: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_normalModuleFactoryResolveForScheme).bind(this),
|
|
518
|
-
chunkAsset: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_chunkAsset).bind(this),
|
|
519
507
|
afterResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_afterResolve).bind(this),
|
|
520
508
|
contextModuleFactoryBeforeResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_contextModuleFactoryBeforeResolve).bind(this),
|
|
521
|
-
contextModuleFactoryAfterResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_contextModuleFactoryAfterResolve).bind(this)
|
|
522
|
-
succeedModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_succeedModule).bind(this),
|
|
523
|
-
stillValidModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_stillValidModule).bind(this),
|
|
524
|
-
buildModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_buildModule).bind(this),
|
|
525
|
-
executeModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_executeModule).bind(this),
|
|
526
|
-
runtimeModule: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_runtimeModule).bind(this)
|
|
509
|
+
contextModuleFactoryAfterResolve: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_contextModuleFactoryAfterResolve).bind(this)
|
|
527
510
|
}, {
|
|
528
511
|
registerCompilerThisCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.thisCompilation, queried => (native) => {
|
|
529
512
|
if (this.compilation === undefined) {
|
|
@@ -533,8 +516,82 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
533
516
|
}),
|
|
534
517
|
registerCompilerCompilationTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.compilation, queried => () => queried.call(this.compilation, this.compilationParams)),
|
|
535
518
|
registerCompilerMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.make, queried => async () => await queried.promise(this.compilation)),
|
|
519
|
+
registerCompilerFinishMakeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.finishMake, queried => async () => await queried.promise(this.compilation)),
|
|
536
520
|
registerCompilerShouldEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.shouldEmit, queried => () => queried.call(this.compilation)),
|
|
521
|
+
registerCompilerEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.emit, queried => async () => await queried.promise(this.compilation)),
|
|
522
|
+
registerCompilerAfterEmitTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.afterEmit, queried => async () => await queried.promise(this.compilation)),
|
|
523
|
+
registerCompilerAssetEmittedTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.hooks.assetEmitted, queried => async ({ filename, targetPath, outputPath }) => await queried.promise(filename, {
|
|
524
|
+
compilation: this.compilation,
|
|
525
|
+
targetPath,
|
|
526
|
+
outputPath,
|
|
527
|
+
get source() {
|
|
528
|
+
var _a;
|
|
529
|
+
return (_a = this.compilation.getAsset(filename)) === null || _a === void 0 ? void 0 : _a.source;
|
|
530
|
+
},
|
|
531
|
+
get content() {
|
|
532
|
+
var _a;
|
|
533
|
+
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.buffer();
|
|
534
|
+
}
|
|
535
|
+
})),
|
|
536
|
+
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.runtimeModule, queried => ({ module, chunk }) => {
|
|
537
|
+
var _a, _b;
|
|
538
|
+
const originSource = (_a = module.source) === null || _a === void 0 ? void 0 : _a.source;
|
|
539
|
+
queried.call(module, Chunk_1.Chunk.__from_binding(chunk, this.compilation));
|
|
540
|
+
const newSource = (_b = module.source) === null || _b === void 0 ? void 0 : _b.source;
|
|
541
|
+
if (newSource && newSource !== originSource) {
|
|
542
|
+
return module;
|
|
543
|
+
}
|
|
544
|
+
return;
|
|
545
|
+
}),
|
|
546
|
+
registerCompilationBuildModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.buildModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
547
|
+
registerCompilationStillValidModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.stillValidModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
548
|
+
registerCompilationSucceedModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.succeedModule, queired => (m) => queired.call(Module_1.Module.__from_binding(m))),
|
|
549
|
+
registerCompilationExecuteModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.executeModule, queried => ({ entry, id, codegenResults, runtimeModules }) => {
|
|
550
|
+
const __webpack_require__ = (id) => {
|
|
551
|
+
const cached = moduleCache[id];
|
|
552
|
+
if (cached !== undefined) {
|
|
553
|
+
if (cached.error)
|
|
554
|
+
throw cached.error;
|
|
555
|
+
return cached.exports;
|
|
556
|
+
}
|
|
557
|
+
var execOptions = {
|
|
558
|
+
id,
|
|
559
|
+
module: {
|
|
560
|
+
id,
|
|
561
|
+
exports: {},
|
|
562
|
+
loaded: false,
|
|
563
|
+
error: undefined
|
|
564
|
+
},
|
|
565
|
+
require: __webpack_require__
|
|
566
|
+
};
|
|
567
|
+
interceptModuleExecution.forEach((handler) => handler(execOptions));
|
|
568
|
+
const result = codegenResults.map[id]["build time"];
|
|
569
|
+
const moduleObject = execOptions.module;
|
|
570
|
+
if (id)
|
|
571
|
+
moduleCache[id] = moduleObject;
|
|
572
|
+
(0, HookWebpackError_1.tryRunOrWebpackError)(() => queried.call({
|
|
573
|
+
codeGenerationResult: new Module_1.CodeGenerationResult(result),
|
|
574
|
+
moduleObject
|
|
575
|
+
}, { __webpack_require__ }), "Compilation.hooks.executeModule");
|
|
576
|
+
moduleObject.loaded = true;
|
|
577
|
+
return moduleObject.exports;
|
|
578
|
+
};
|
|
579
|
+
const moduleCache = (__webpack_require__[RuntimeGlobals_1.RuntimeGlobals.moduleCache.replace(`${RuntimeGlobals_1.RuntimeGlobals.require}.`, "")] = {});
|
|
580
|
+
const interceptModuleExecution = (__webpack_require__[RuntimeGlobals_1.RuntimeGlobals.interceptModuleExecution.replace(`${RuntimeGlobals_1.RuntimeGlobals.require}.`, "")] = []);
|
|
581
|
+
for (const runtimeModule of runtimeModules) {
|
|
582
|
+
__webpack_require__(runtimeModule);
|
|
583
|
+
}
|
|
584
|
+
const executeResult = __webpack_require__(entry);
|
|
585
|
+
__classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").set(id, executeResult);
|
|
586
|
+
}),
|
|
587
|
+
registerCompilationFinishModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.finishModules, queried => async () => await queried.promise(this.compilation.modules)),
|
|
588
|
+
registerCompilationOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.optimizeModules, queried => () => queried.call(this.compilation.modules)),
|
|
589
|
+
registerCompilationAfterOptimizeModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.afterOptimizeModules, queried => () => queried.call(this.compilation.modules)),
|
|
590
|
+
registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.optimizeTree, queried => async () => await queried.promise(this.compilation.chunks, this.compilation.modules)),
|
|
591
|
+
registerCompilationOptimizeChunkModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.optimizeChunkModules, queried => async () => await queried.promise(this.compilation.chunks, this.compilation.modules)),
|
|
592
|
+
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.chunkAsset, queried => ({ chunk, filename }) => queried.call(Chunk_1.Chunk.__from_binding(chunk, this.compilation), filename)),
|
|
537
593
|
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.processAssets, queried => async () => await queried.promise(this.compilation.assets)),
|
|
594
|
+
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilation.hooks.afterProcessAssets, queried => () => queried.call(this.compilation.assets)),
|
|
538
595
|
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createRegisterTaps).call(this, () => this.compilationParams.normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
539
596
|
const normalizedResolveData = {
|
|
540
597
|
request: resolveData.request,
|
|
@@ -554,27 +611,11 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
554
611
|
var _a, _b, _c, _d, _e;
|
|
555
612
|
const disabledHooks = [];
|
|
556
613
|
const hookMap = {
|
|
557
|
-
finishMake: this.hooks.finishMake,
|
|
558
|
-
emit: this.hooks.emit,
|
|
559
|
-
assetEmitted: this.hooks.assetEmitted,
|
|
560
|
-
afterEmit: this.hooks.afterEmit,
|
|
561
|
-
afterProcessAssets: this.compilation.hooks.afterProcessAssets,
|
|
562
|
-
optimizeTree: this.compilation.hooks.optimizeTree,
|
|
563
|
-
finishModules: this.compilation.hooks.finishModules,
|
|
564
|
-
optimizeModules: this.compilation.hooks.optimizeModules,
|
|
565
|
-
afterOptimizeModules: this.compilation.hooks.afterOptimizeModules,
|
|
566
|
-
chunkAsset: this.compilation.hooks.chunkAsset,
|
|
567
614
|
afterResolve: (_a = this.compilationParams) === null || _a === void 0 ? void 0 : _a.normalModuleFactory.hooks.afterResolve,
|
|
568
|
-
succeedModule: this.compilation.hooks.succeedModule,
|
|
569
|
-
stillValidModule: this.compilation.hooks.stillValidModule,
|
|
570
|
-
buildModule: this.compilation.hooks.buildModule,
|
|
571
|
-
optimizeChunkModules: this.compilation.hooks.optimizeChunkModules,
|
|
572
615
|
contextModuleFactoryBeforeResolve: (_b = this.compilationParams) === null || _b === void 0 ? void 0 : _b.contextModuleFactory.hooks.beforeResolve,
|
|
573
616
|
contextModuleFactoryAfterResolve: (_c = this.compilationParams) === null || _c === void 0 ? void 0 : _c.contextModuleFactory.hooks.afterResolve,
|
|
574
617
|
normalModuleFactoryCreateModule: (_d = this.compilationParams) === null || _d === void 0 ? void 0 : _d.normalModuleFactory.hooks.createModule,
|
|
575
|
-
normalModuleFactoryResolveForScheme: (_e = this.compilationParams) === null || _e === void 0 ? void 0 : _e.normalModuleFactory.hooks.resolveForScheme
|
|
576
|
-
executeModule: undefined,
|
|
577
|
-
runtimeModule: this.compilation.hooks.runtimeModule
|
|
618
|
+
normalModuleFactoryResolveForScheme: (_e = this.compilationParams) === null || _e === void 0 ? void 0 : _e.normalModuleFactory.hooks.resolveForScheme
|
|
578
619
|
};
|
|
579
620
|
for (const [name, hook] of Object.entries(hookMap)) {
|
|
580
621
|
if (typeof hook !== "undefined" &&
|
|
@@ -596,13 +637,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
596
637
|
__classPrivateFieldSet(this, _Compiler_disabledHooks, disabledHooks, "f");
|
|
597
638
|
});
|
|
598
639
|
}
|
|
599
|
-
}, _Compiler_finishMake = async function _Compiler_finishMake() {
|
|
600
|
-
await this.hooks.finishMake.promise(this.compilation);
|
|
601
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
602
|
-
}, _Compiler_buildModule = async function _Compiler_buildModule(module) {
|
|
603
|
-
const normalized = (0, normalization_1.normalizeJsModule)(module);
|
|
604
|
-
this.compilation.hooks.buildModule.call(normalized);
|
|
605
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
606
640
|
}, _Compiler_afterProcessAssets = async function _Compiler_afterProcessAssets() {
|
|
607
641
|
await this.compilation.hooks.afterProcessAssets.promise(this.compilation.assets);
|
|
608
642
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
@@ -646,95 +680,6 @@ _Compiler_instance = new WeakMap(), _Compiler_disabledHooks = new WeakMap(), _Co
|
|
|
646
680
|
}, _Compiler_optimizeTree = async function _Compiler_optimizeTree() {
|
|
647
681
|
await this.compilation.hooks.optimizeTree.promise(this.compilation.chunks, this.compilation.modules);
|
|
648
682
|
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
649
|
-
}, _Compiler_optimizeModules = async function _Compiler_optimizeModules() {
|
|
650
|
-
await this.compilation.hooks.optimizeModules.promise(this.compilation.modules);
|
|
651
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
652
|
-
}, _Compiler_afterOptimizeModules = async function _Compiler_afterOptimizeModules() {
|
|
653
|
-
await this.compilation.hooks.afterOptimizeModules.promise(this.compilation.modules);
|
|
654
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
655
|
-
}, _Compiler_chunkAsset = function _Compiler_chunkAsset(assetArg) {
|
|
656
|
-
this.compilation.hooks.chunkAsset.call(assetArg.chunk, assetArg.filename);
|
|
657
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
658
|
-
}, _Compiler_finishModules = async function _Compiler_finishModules() {
|
|
659
|
-
await this.compilation.hooks.finishModules.promise(this.compilation.modules);
|
|
660
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
661
|
-
}, _Compiler_emit = async function _Compiler_emit() {
|
|
662
|
-
await this.hooks.emit.promise(this.compilation);
|
|
663
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
664
|
-
}, _Compiler_assetEmitted = async function _Compiler_assetEmitted(args) {
|
|
665
|
-
const filename = args.filename;
|
|
666
|
-
const info = {
|
|
667
|
-
compilation: this.compilation,
|
|
668
|
-
outputPath: args.outputPath,
|
|
669
|
-
targetPath: args.targetPath,
|
|
670
|
-
get source() {
|
|
671
|
-
var _a;
|
|
672
|
-
return (_a = this.compilation.getAsset(args.filename)) === null || _a === void 0 ? void 0 : _a.source;
|
|
673
|
-
},
|
|
674
|
-
get content() {
|
|
675
|
-
var _a;
|
|
676
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.buffer();
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
await this.hooks.assetEmitted.promise(filename, info);
|
|
680
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
681
|
-
}, _Compiler_afterEmit = async function _Compiler_afterEmit() {
|
|
682
|
-
await this.hooks.afterEmit.promise(this.compilation);
|
|
683
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
684
|
-
}, _Compiler_succeedModule = function _Compiler_succeedModule(module) {
|
|
685
|
-
this.compilation.hooks.succeedModule.call(module);
|
|
686
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
687
|
-
}, _Compiler_stillValidModule = function _Compiler_stillValidModule(module) {
|
|
688
|
-
this.compilation.hooks.stillValidModule.call(module);
|
|
689
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
690
|
-
}, _Compiler_runtimeModule = function _Compiler_runtimeModule(arg) {
|
|
691
|
-
var _a, _b;
|
|
692
|
-
let { module, chunk } = arg;
|
|
693
|
-
const originSource = (_a = module.source) === null || _a === void 0 ? void 0 : _a.source;
|
|
694
|
-
this.compilation.hooks.runtimeModule.call(module, chunk);
|
|
695
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_updateDisabledHooks).call(this);
|
|
696
|
-
const newSource = (_b = module.source) === null || _b === void 0 ? void 0 : _b.source;
|
|
697
|
-
if (newSource && newSource !== originSource) {
|
|
698
|
-
return module;
|
|
699
|
-
}
|
|
700
|
-
return;
|
|
701
|
-
}, _Compiler_executeModule = async function _Compiler_executeModule({ entry, request, options, runtimeModules, codegenResults, id }) {
|
|
702
|
-
const __webpack_require__ = (id) => {
|
|
703
|
-
const cached = moduleCache[id];
|
|
704
|
-
if (cached !== undefined) {
|
|
705
|
-
if (cached.error)
|
|
706
|
-
throw cached.error;
|
|
707
|
-
return cached.exports;
|
|
708
|
-
}
|
|
709
|
-
var execOptions = {
|
|
710
|
-
id,
|
|
711
|
-
module: {
|
|
712
|
-
id,
|
|
713
|
-
exports: {},
|
|
714
|
-
loaded: false,
|
|
715
|
-
error: undefined
|
|
716
|
-
},
|
|
717
|
-
require: __webpack_require__
|
|
718
|
-
};
|
|
719
|
-
interceptModuleExecution.forEach((handler) => handler(execOptions));
|
|
720
|
-
const result = codegenResults.map[id]["build time"];
|
|
721
|
-
const moduleObject = execOptions.module;
|
|
722
|
-
if (id)
|
|
723
|
-
moduleCache[id] = moduleObject;
|
|
724
|
-
(0, HookWebpackError_1.tryRunOrWebpackError)(() => this.compilation.hooks.executeModule.call({
|
|
725
|
-
codeGenerationResult: new Module_1.CodeGenerationResult(result),
|
|
726
|
-
moduleObject
|
|
727
|
-
}, { __webpack_require__ }), "Compilation.hooks.executeModule");
|
|
728
|
-
moduleObject.loaded = true;
|
|
729
|
-
return moduleObject.exports;
|
|
730
|
-
};
|
|
731
|
-
const moduleCache = (__webpack_require__[RuntimeGlobals_1.RuntimeGlobals.moduleCache.replace(`${RuntimeGlobals_1.RuntimeGlobals.require}.`, "")] = {});
|
|
732
|
-
const interceptModuleExecution = (__webpack_require__[RuntimeGlobals_1.RuntimeGlobals.interceptModuleExecution.replace(`${RuntimeGlobals_1.RuntimeGlobals.require}.`, "")] = []);
|
|
733
|
-
for (const runtimeModule of runtimeModules) {
|
|
734
|
-
__webpack_require__(runtimeModule);
|
|
735
|
-
}
|
|
736
|
-
const executeResult = __webpack_require__(entry);
|
|
737
|
-
__classPrivateFieldGet(this, _Compiler_moduleExecutionResultsMap, "f").set(id, executeResult);
|
|
738
683
|
}, _Compiler_decorateUpdateDisabledHooks = function _Compiler_decorateUpdateDisabledHooks(jsTaps) {
|
|
739
684
|
if (jsTaps.length > 0) {
|
|
740
685
|
const last = jsTaps[jsTaps.length - 1];
|
package/dist/Module.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { JsCodegenerationResult, JsCodegenerationResults, JsModule } from "@rspack/binding";
|
|
2
|
+
import { Source } from "webpack-sources";
|
|
2
3
|
export declare class Module {
|
|
3
4
|
#private;
|
|
5
|
+
_originalSource?: Source;
|
|
4
6
|
static __from_binding(module: JsModule): Module;
|
|
5
7
|
constructor(module: JsModule);
|
|
6
8
|
get context(): string | undefined;
|
|
7
9
|
get resource(): string | undefined;
|
|
10
|
+
get originalSource(): Source | null;
|
|
8
11
|
identifier(): string;
|
|
9
12
|
nameForCondition(): string | null;
|
|
10
13
|
}
|
package/dist/Module.js
CHANGED
|
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _Module_inner, _CodeGenerationResult_inner, _CodeGenerationResults_inner;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.CodeGenerationResults = exports.CodeGenerationResult = exports.Module = void 0;
|
|
16
|
+
const createSource_1 = require("./util/createSource");
|
|
16
17
|
class Module {
|
|
17
18
|
static __from_binding(module) {
|
|
18
19
|
return new Module(module);
|
|
@@ -27,6 +28,17 @@ class Module {
|
|
|
27
28
|
get resource() {
|
|
28
29
|
return __classPrivateFieldGet(this, _Module_inner, "f").resource;
|
|
29
30
|
}
|
|
31
|
+
get originalSource() {
|
|
32
|
+
if (this._originalSource)
|
|
33
|
+
return this._originalSource;
|
|
34
|
+
if (__classPrivateFieldGet(this, _Module_inner, "f").originalSource) {
|
|
35
|
+
this._originalSource = (0, createSource_1.createSourceFromRaw)(__classPrivateFieldGet(this, _Module_inner, "f").originalSource);
|
|
36
|
+
return this._originalSource;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
30
42
|
identifier() {
|
|
31
43
|
return __classPrivateFieldGet(this, _Module_inner, "f").moduleIdentifier;
|
|
32
44
|
}
|
|
@@ -3,7 +3,7 @@ export declare const ArrayPushCallbackChunkFormatPlugin: {
|
|
|
3
3
|
new (): {
|
|
4
4
|
name: BuiltinPluginName;
|
|
5
5
|
_options: void;
|
|
6
|
-
affectedHooks: "
|
|
6
|
+
affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
7
7
|
raw(): import("@rspack/binding").BuiltinPlugin;
|
|
8
8
|
apply(compiler: import("../Compiler").Compiler): void;
|
|
9
9
|
};
|
|
@@ -3,7 +3,7 @@ export declare const AssetModulesPlugin: {
|
|
|
3
3
|
new (): {
|
|
4
4
|
name: BuiltinPluginName;
|
|
5
5
|
_options: void;
|
|
6
|
-
affectedHooks: "
|
|
6
|
+
affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
7
7
|
raw(): import("@rspack/binding").BuiltinPlugin;
|
|
8
8
|
apply(compiler: import("../Compiler").Compiler): void;
|
|
9
9
|
};
|