@rspack/core 1.0.4 → 1.0.6
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 +5 -0
- package/dist/Chunk.js +28 -0
- package/dist/Compilation.d.ts +15 -7
- package/dist/Compilation.js +25 -8
- package/dist/Compiler.js +16 -30
- package/dist/Module.d.ts +20 -8
- package/dist/Module.js +66 -7
- package/dist/MultiCompiler.js +6 -26
- package/dist/MultiWatching.d.ts +3 -6
- package/dist/MultiWatching.js +6 -7
- package/dist/Resolver.d.ts +2 -4
- package/dist/RspackError.d.ts +2 -2
- package/dist/RspackError.js +3 -3
- package/dist/RuntimeModule.d.ts +32 -0
- package/dist/RuntimeModule.js +58 -0
- package/dist/Watching.d.ts +5 -5
- package/dist/Watching.js +3 -11
- package/dist/builtin-plugin/ContextReplacementPlugin.d.ts +10 -0
- package/dist/builtin-plugin/ContextReplacementPlugin.js +43 -0
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -5
- package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProgressPlugin.js +10 -8
- package/dist/builtin-plugin/css-extract/index.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/index.js +2 -3
- package/dist/builtin-plugin/css-extract/loader.js +4 -8
- package/dist/builtin-plugin/index.d.ts +1 -0
- package/dist/builtin-plugin/index.js +1 -0
- package/dist/config/adapter.js +10 -14
- package/dist/config/adapterRuleUse.d.ts +47 -3
- package/dist/config/defaults.js +2 -7
- package/dist/config/zod.d.ts +16 -16
- package/dist/exports.d.ts +2 -0
- package/dist/exports.js +6 -2
- package/dist/loader-runner/index.js +34 -32
- package/dist/node/NodeEnvironmentPlugin.js +1 -1
- package/dist/node/NodeWatchFileSystem.d.ts +1 -1
- package/dist/node/NodeWatchFileSystem.js +1 -4
- package/dist/node/nodeConsole.js +2 -1
- package/dist/stats/DefaultStatsFactoryPlugin.js +18 -29
- package/dist/stats/DefaultStatsPrinterPlugin.js +3 -5
- package/dist/stats/StatsFactory.d.ts +1 -1
- package/dist/stats/StatsFactory.js +1 -4
- package/dist/stats/statsFactoryUtils.d.ts +7 -3
- package/dist/stats/statsFactoryUtils.js +5 -6
- package/dist/util/comparators.d.ts +2 -2
- package/dist/util/comparators.js +0 -1
- package/dist/util/index.js +12 -1
- package/dist/util/smartGrouping.d.ts +4 -4
- package/dist/util/source.d.ts +1 -12
- package/dist/util/source.js +19 -43
- package/package.json +2 -2
package/dist/RspackError.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NonErrorEmittedError = exports.
|
|
3
|
+
exports.NonErrorEmittedError = exports.JsRspackDiagnostic = void 0;
|
|
4
4
|
const util_1 = require("./util");
|
|
5
|
-
class
|
|
5
|
+
class JsRspackDiagnostic {
|
|
6
6
|
static __to_binding(error, severity) {
|
|
7
7
|
return {
|
|
8
8
|
error: (0, util_1.concatErrorMsgAndStack)(error),
|
|
@@ -10,7 +10,7 @@ class JsDiagnostic {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
exports.
|
|
13
|
+
exports.JsRspackDiagnostic = JsRspackDiagnostic;
|
|
14
14
|
class NonErrorEmittedError extends Error {
|
|
15
15
|
constructor(error) {
|
|
16
16
|
super();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { JsAddingRuntimeModule } from "@rspack/binding";
|
|
2
|
+
import type { Chunk } from "./Chunk";
|
|
3
|
+
import type { ChunkGraph } from "./ChunkGraph";
|
|
4
|
+
import type { Compilation } from "./Compilation";
|
|
5
|
+
export declare enum RuntimeModuleStage {
|
|
6
|
+
NORMAL = 0,
|
|
7
|
+
BASIC = 5,
|
|
8
|
+
ATTACH = 10,
|
|
9
|
+
TRIGGER = 20
|
|
10
|
+
}
|
|
11
|
+
export declare class RuntimeModule {
|
|
12
|
+
static STAGE_NORMAL: RuntimeModuleStage;
|
|
13
|
+
static STAGE_BASIC: RuntimeModuleStage;
|
|
14
|
+
static STAGE_ATTACH: RuntimeModuleStage;
|
|
15
|
+
static STAGE_TRIGGER: RuntimeModuleStage;
|
|
16
|
+
static __to_binding(compilation: Compilation, module: RuntimeModule): JsAddingRuntimeModule;
|
|
17
|
+
private _name;
|
|
18
|
+
private _stage;
|
|
19
|
+
fullHash: boolean;
|
|
20
|
+
dependentHash: boolean;
|
|
21
|
+
protected chunk: Chunk | null;
|
|
22
|
+
protected compilation: Compilation | null;
|
|
23
|
+
protected chunkGraph: ChunkGraph | null;
|
|
24
|
+
constructor(name: string, stage?: RuntimeModuleStage);
|
|
25
|
+
attach(compilation: Compilation, chunk: Chunk, chunkGraph: ChunkGraph): void;
|
|
26
|
+
get name(): string;
|
|
27
|
+
get stage(): RuntimeModuleStage;
|
|
28
|
+
identifier(): string;
|
|
29
|
+
readableIdentifier(): string;
|
|
30
|
+
shouldIsolate(): boolean;
|
|
31
|
+
generate(compilation: Compilation): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuntimeModule = exports.RuntimeModuleStage = void 0;
|
|
4
|
+
var RuntimeModuleStage;
|
|
5
|
+
(function (RuntimeModuleStage) {
|
|
6
|
+
RuntimeModuleStage[RuntimeModuleStage["NORMAL"] = 0] = "NORMAL";
|
|
7
|
+
RuntimeModuleStage[RuntimeModuleStage["BASIC"] = 5] = "BASIC";
|
|
8
|
+
RuntimeModuleStage[RuntimeModuleStage["ATTACH"] = 10] = "ATTACH";
|
|
9
|
+
RuntimeModuleStage[RuntimeModuleStage["TRIGGER"] = 20] = "TRIGGER";
|
|
10
|
+
})(RuntimeModuleStage = exports.RuntimeModuleStage || (exports.RuntimeModuleStage = {}));
|
|
11
|
+
class RuntimeModule {
|
|
12
|
+
static __to_binding(compilation, module) {
|
|
13
|
+
return {
|
|
14
|
+
name: module.name,
|
|
15
|
+
stage: module.stage,
|
|
16
|
+
generator: () => module.generate(compilation),
|
|
17
|
+
cacheable: !(module.fullHash || module.dependentHash),
|
|
18
|
+
isolate: module.shouldIsolate()
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
constructor(name, stage = RuntimeModuleStage.NORMAL) {
|
|
22
|
+
this.fullHash = false;
|
|
23
|
+
this.dependentHash = false;
|
|
24
|
+
this.chunk = null;
|
|
25
|
+
this.compilation = null;
|
|
26
|
+
this.chunkGraph = null;
|
|
27
|
+
this._name = name;
|
|
28
|
+
this._stage = stage;
|
|
29
|
+
}
|
|
30
|
+
attach(compilation, chunk, chunkGraph) {
|
|
31
|
+
this.compilation = compilation;
|
|
32
|
+
this.chunk = chunk;
|
|
33
|
+
this.chunkGraph = chunkGraph;
|
|
34
|
+
}
|
|
35
|
+
get name() {
|
|
36
|
+
return this._name;
|
|
37
|
+
}
|
|
38
|
+
get stage() {
|
|
39
|
+
return this._stage;
|
|
40
|
+
}
|
|
41
|
+
identifier() {
|
|
42
|
+
return `webpack/runtime/${this._name}`;
|
|
43
|
+
}
|
|
44
|
+
readableIdentifier() {
|
|
45
|
+
return `webpack/runtime/${this._name}`;
|
|
46
|
+
}
|
|
47
|
+
shouldIsolate() {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
generate(compilation) {
|
|
51
|
+
throw new Error(`Should implement "generate" method of runtime module "${this.name}"`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
RuntimeModule.STAGE_NORMAL = RuntimeModuleStage.NORMAL;
|
|
55
|
+
RuntimeModule.STAGE_BASIC = RuntimeModuleStage.BASIC;
|
|
56
|
+
RuntimeModule.STAGE_ATTACH = RuntimeModuleStage.ATTACH;
|
|
57
|
+
RuntimeModule.STAGE_TRIGGER = RuntimeModuleStage.TRIGGER;
|
|
58
|
+
exports.RuntimeModule = RuntimeModule;
|
package/dist/Watching.d.ts
CHANGED
|
@@ -8,19 +8,19 @@ export declare class Watching {
|
|
|
8
8
|
watcher?: Watcher;
|
|
9
9
|
pausedWatcher?: Watcher;
|
|
10
10
|
compiler: Compiler;
|
|
11
|
-
handler:
|
|
11
|
+
handler: Callback<Error, Stats>;
|
|
12
12
|
callbacks: Callback<Error, void>[];
|
|
13
13
|
watchOptions: WatchOptions;
|
|
14
14
|
lastWatcherStartTime: number;
|
|
15
15
|
running: boolean;
|
|
16
16
|
blocked: boolean;
|
|
17
|
-
isBlocked
|
|
18
|
-
onChange
|
|
19
|
-
onInvalid
|
|
17
|
+
isBlocked: () => boolean;
|
|
18
|
+
onChange: () => void;
|
|
19
|
+
onInvalid: () => void;
|
|
20
20
|
invalid: boolean;
|
|
21
21
|
startTime?: number;
|
|
22
22
|
suspended: boolean;
|
|
23
|
-
constructor(compiler: Compiler, watchOptions: WatchOptions, handler:
|
|
23
|
+
constructor(compiler: Compiler, watchOptions: WatchOptions, handler: Callback<Error, Stats>);
|
|
24
24
|
watch(files: Iterable<string>, dirs: Iterable<string>, missing: Iterable<string>): void;
|
|
25
25
|
close(callback?: () => void): void;
|
|
26
26
|
invalidate(callback?: Callback<Error, void>): void;
|
package/dist/Watching.js
CHANGED
|
@@ -72,14 +72,12 @@ class Watching {
|
|
|
72
72
|
return this.handler(err);
|
|
73
73
|
}
|
|
74
74
|
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this, fileTimeInfoEntries, contextTimeInfoEntries, changedFiles, removedFiles);
|
|
75
|
-
// @ts-expect-error
|
|
76
75
|
this.onChange();
|
|
77
76
|
}, (fileName, changeTime) => {
|
|
78
77
|
if (!__classPrivateFieldGet(this, _Watching_invalidReported, "f")) {
|
|
79
78
|
__classPrivateFieldSet(this, _Watching_invalidReported, true, "f");
|
|
80
79
|
this.compiler.hooks.invalid.call(fileName, changeTime);
|
|
81
80
|
}
|
|
82
|
-
// @ts-expect-error
|
|
83
81
|
this.onInvalid();
|
|
84
82
|
});
|
|
85
83
|
}
|
|
@@ -104,7 +102,6 @@ class Watching {
|
|
|
104
102
|
this.compiler.hooks.watchClose.call();
|
|
105
103
|
const closeCallbacks = __classPrivateFieldGet(this, _Watching_closeCallbacks, "f");
|
|
106
104
|
__classPrivateFieldSet(this, _Watching_closeCallbacks, undefined, "f");
|
|
107
|
-
// @ts-expect-error
|
|
108
105
|
for (const cb of closeCallbacks)
|
|
109
106
|
cb(err);
|
|
110
107
|
};
|
|
@@ -122,7 +119,6 @@ class Watching {
|
|
|
122
119
|
// } else {
|
|
123
120
|
// shutdown(err);
|
|
124
121
|
// }
|
|
125
|
-
// @ts-expect-error
|
|
126
122
|
shutdown(err);
|
|
127
123
|
};
|
|
128
124
|
__classPrivateFieldSet(this, _Watching_closed, true, "f");
|
|
@@ -156,7 +152,6 @@ class Watching {
|
|
|
156
152
|
__classPrivateFieldSet(this, _Watching_invalidReported, true, "f");
|
|
157
153
|
this.compiler.hooks.invalid.call(null, Date.now());
|
|
158
154
|
}
|
|
159
|
-
// @ts-expect-error
|
|
160
155
|
this.onChange();
|
|
161
156
|
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_invalidate).call(this);
|
|
162
157
|
}
|
|
@@ -191,7 +186,6 @@ class Watching {
|
|
|
191
186
|
this.compiler.hooks.done.callAsync(stats, err => {
|
|
192
187
|
if (err)
|
|
193
188
|
return handleError(err, cbs);
|
|
194
|
-
// @ts-expect-error
|
|
195
189
|
this.handler(null, stats);
|
|
196
190
|
process.nextTick(() => {
|
|
197
191
|
if (!__classPrivateFieldGet(this, _Watching_closed, "f")) {
|
|
@@ -215,9 +209,7 @@ class Watching {
|
|
|
215
209
|
}
|
|
216
210
|
exports.Watching = Watching;
|
|
217
211
|
_Watching_invalidReported = new WeakMap(), _Watching_closeCallbacks = new WeakMap(), _Watching_initial = new WeakMap(), _Watching_closed = new WeakMap(), _Watching_collectedChangedFiles = new WeakMap(), _Watching_collectedRemovedFiles = new WeakMap(), _Watching_instances = new WeakSet(), _Watching_invalidate = function _Watching_invalidate(fileTimeInfoEntries, contextTimeInfoEntries, changedFiles, removedFiles) {
|
|
218
|
-
// @ts-expect-error
|
|
219
212
|
__classPrivateFieldGet(this, _Watching_instances, "m", _Watching_mergeWithCollected).call(this, changedFiles, removedFiles);
|
|
220
|
-
// @ts-expect-error
|
|
221
213
|
if (this.suspended || (this.isBlocked() && (this.blocked = true))) {
|
|
222
214
|
return;
|
|
223
215
|
}
|
|
@@ -279,19 +271,19 @@ _Watching_invalidReported = new WeakMap(), _Watching_closeCallbacks = new WeakMa
|
|
|
279
271
|
}, _Watching_mergeWithCollected = function _Watching_mergeWithCollected(changedFiles, removedFiles) {
|
|
280
272
|
if (!changedFiles)
|
|
281
273
|
return;
|
|
282
|
-
if (!
|
|
274
|
+
if (!removedFiles)
|
|
275
|
+
return;
|
|
276
|
+
if (!__classPrivateFieldGet(this, _Watching_collectedChangedFiles, "f") || !__classPrivateFieldGet(this, _Watching_collectedRemovedFiles, "f")) {
|
|
283
277
|
__classPrivateFieldSet(this, _Watching_collectedChangedFiles, new Set(changedFiles), "f");
|
|
284
278
|
__classPrivateFieldSet(this, _Watching_collectedRemovedFiles, new Set(removedFiles), "f");
|
|
285
279
|
}
|
|
286
280
|
else {
|
|
287
281
|
for (const file of changedFiles) {
|
|
288
282
|
__classPrivateFieldGet(this, _Watching_collectedChangedFiles, "f").add(file);
|
|
289
|
-
// @ts-expect-error
|
|
290
283
|
__classPrivateFieldGet(this, _Watching_collectedRemovedFiles, "f").delete(file);
|
|
291
284
|
}
|
|
292
285
|
for (const file of removedFiles) {
|
|
293
286
|
__classPrivateFieldGet(this, _Watching_collectedChangedFiles, "f").delete(file);
|
|
294
|
-
// @ts-expect-error
|
|
295
287
|
__classPrivateFieldGet(this, _Watching_collectedRemovedFiles, "f").add(file);
|
|
296
288
|
}
|
|
297
289
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BuiltinPluginName } from "@rspack/binding";
|
|
2
|
+
export declare const ContextReplacementPlugin: {
|
|
3
|
+
new (resourceRegExp: RegExp, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any): {
|
|
4
|
+
name: BuiltinPluginName;
|
|
5
|
+
_args: [resourceRegExp: RegExp, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any];
|
|
6
|
+
affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "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
|
+
raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
|
|
8
|
+
apply(compiler: import("../Compiler").Compiler): void;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextReplacementPlugin = void 0;
|
|
4
|
+
const binding_1 = require("@rspack/binding");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
exports.ContextReplacementPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ContextReplacementPlugin, (resourceRegExp, newContentResource, newContentRecursive, newContentRegExp) => {
|
|
7
|
+
const rawOptions = {
|
|
8
|
+
resourceRegExp
|
|
9
|
+
};
|
|
10
|
+
if (typeof newContentResource === "function") {
|
|
11
|
+
// rawOptions.newContentCallback = newContentResource;
|
|
12
|
+
}
|
|
13
|
+
else if (typeof newContentResource === "string" &&
|
|
14
|
+
typeof newContentRecursive === "object") {
|
|
15
|
+
rawOptions.newContentResource = newContentResource;
|
|
16
|
+
rawOptions.newContentCreateContextMap = newContentRecursive;
|
|
17
|
+
}
|
|
18
|
+
else if (typeof newContentResource === "string" &&
|
|
19
|
+
typeof newContentRecursive === "function") {
|
|
20
|
+
rawOptions.newContentResource = newContentResource;
|
|
21
|
+
// rawOptions.newContentCreateContextMap = newContentRecursive;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
if (typeof newContentResource !== "string") {
|
|
25
|
+
// biome-ignore lint/style/noParameterAssign: based on webpack's logic
|
|
26
|
+
newContentRegExp = newContentRecursive;
|
|
27
|
+
// biome-ignore lint/style/noParameterAssign: based on webpack's logic
|
|
28
|
+
newContentRecursive = newContentResource;
|
|
29
|
+
// biome-ignore lint/style/noParameterAssign: based on webpack's logic
|
|
30
|
+
newContentResource = undefined;
|
|
31
|
+
}
|
|
32
|
+
if (typeof newContentRecursive !== "boolean") {
|
|
33
|
+
// biome-ignore lint/style/noParameterAssign: based on webpack's logic
|
|
34
|
+
newContentRegExp = newContentRecursive;
|
|
35
|
+
// biome-ignore lint/style/noParameterAssign: based on webpack's logic
|
|
36
|
+
newContentRecursive = undefined;
|
|
37
|
+
}
|
|
38
|
+
rawOptions.newContentResource = newContentResource;
|
|
39
|
+
rawOptions.newContentRecursive = newContentRecursive;
|
|
40
|
+
rawOptions.newContentRegExp = newContentRegExp;
|
|
41
|
+
}
|
|
42
|
+
return rawOptions;
|
|
43
|
+
});
|
|
@@ -16,11 +16,7 @@ exports.LightningCssMinimizerRspackPlugin = (0, base_1.create)(binding_1.Builtin
|
|
|
16
16
|
errorRecovery: options?.minimizerOptions?.errorRecovery ?? true,
|
|
17
17
|
unusedSymbols: options?.minimizerOptions?.unusedSymbols ?? [],
|
|
18
18
|
include: include ? (0, lightningcss_1.toFeatures)(include) : undefined,
|
|
19
|
-
exclude: exclude
|
|
20
|
-
? (0, lightningcss_1.toFeatures)(exclude)
|
|
21
|
-
: // exclude all features, avoid downgrade css syntax when minimize
|
|
22
|
-
// 1048575 = Features.Empty | Features.Nesting | ... | Features.LogicalProperties
|
|
23
|
-
1048575,
|
|
19
|
+
exclude: exclude ? (0, lightningcss_1.toFeatures)(exclude) : undefined,
|
|
24
20
|
targets: typeof targets === "string" ? [targets] : targets,
|
|
25
21
|
draft: draft ? { customMedia: draft.customMedia ?? false } : undefined,
|
|
26
22
|
nonStandard: nonStandard
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuiltinPluginName, type RawProgressPluginOptions } from "@rspack/binding";
|
|
2
|
-
export type ProgressPluginArgument = Partial<RawProgressPluginOptions
|
|
2
|
+
export type ProgressPluginArgument = Partial<Omit<RawProgressPluginOptions, "handler">> | ((percentage: number, msg: string, ...args: string[]) => void) | undefined;
|
|
3
3
|
export declare const ProgressPlugin: {
|
|
4
4
|
new (progress?: ProgressPluginArgument): {
|
|
5
5
|
name: BuiltinPluginName;
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ProgressPlugin = void 0;
|
|
4
4
|
const binding_1 = require("@rspack/binding");
|
|
5
5
|
const base_1 = require("./base");
|
|
6
|
-
exports.ProgressPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ProgressPlugin, (progress = {}) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
6
|
+
exports.ProgressPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ProgressPlugin, (progress = {}) => {
|
|
7
|
+
if (typeof progress === "function") {
|
|
8
|
+
return {
|
|
9
|
+
handler: (percentage, msg, items) => {
|
|
10
|
+
progress(percentage, msg, ...items);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return progress;
|
|
15
|
+
});
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.CssExtractRspackPlugin = void 0;
|
|
18
|
+
const binding_1 = require("@rspack/binding");
|
|
18
19
|
const loader_1 = require("./loader");
|
|
19
20
|
__exportStar(require("./loader"), exports);
|
|
20
21
|
const DEFAULT_FILENAME = "[name].css";
|
|
@@ -37,8 +38,7 @@ class CssExtractRspackPlugin {
|
|
|
37
38
|
this.options.pathinfo = true;
|
|
38
39
|
}
|
|
39
40
|
compiler.__internal__registerBuiltinPlugin({
|
|
40
|
-
|
|
41
|
-
name: "CssExtractRspackPlugin",
|
|
41
|
+
name: binding_1.BuiltinPluginName.CssExtractRspackPlugin,
|
|
42
42
|
options: this.normalizeOptions(this.options)
|
|
43
43
|
});
|
|
44
44
|
}
|
|
@@ -90,7 +90,6 @@ class CssExtractRspackPlugin {
|
|
|
90
90
|
JSON.stringify(options.attributes[k])
|
|
91
91
|
])
|
|
92
92
|
.reduce((obj, [k, v]) => {
|
|
93
|
-
// @ts-expect-error
|
|
94
93
|
obj[k] = v;
|
|
95
94
|
return obj;
|
|
96
95
|
}, {})
|
|
@@ -12,7 +12,6 @@ exports.MODULE_TYPE = "css/mini-extract";
|
|
|
12
12
|
exports.AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
13
13
|
exports.ABSOLUTE_PUBLIC_PATH = `${exports.BASE_URI}/mini-css-extract-plugin/`;
|
|
14
14
|
exports.SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
15
|
-
const SERIALIZE_SEP = "__RSPACK_CSS_EXTRACT_SEP__";
|
|
16
15
|
function hotLoader(content, context) {
|
|
17
16
|
const localsJsonString = JSON.stringify(JSON.stringify(context.locals));
|
|
18
17
|
return `${content}
|
|
@@ -66,6 +65,7 @@ const pitch = function (request, _, data) {
|
|
|
66
65
|
const emit = typeof options.emit !== "undefined" ? options.emit : true;
|
|
67
66
|
const callback = this.async();
|
|
68
67
|
const filepath = this.resourcePath;
|
|
68
|
+
const parseMeta = this.__internal__parseMeta;
|
|
69
69
|
let { publicPath } = this._compilation.outputOptions;
|
|
70
70
|
if (typeof options.publicPath === "string") {
|
|
71
71
|
// eslint-disable-next-line prefer-destructuring
|
|
@@ -182,15 +182,11 @@ const pitch = function (request, _, data) {
|
|
|
182
182
|
this.hot && emit
|
|
183
183
|
? hotLoader(result, { loaderContext: this, options, locals: locals })
|
|
184
184
|
: result;
|
|
185
|
-
const additionalData = { ...data };
|
|
186
185
|
if (dependencies.length > 0) {
|
|
187
|
-
|
|
188
|
-
.
|
|
189
|
-
return JSON.stringify(dep);
|
|
190
|
-
})
|
|
191
|
-
.join(SERIALIZE_SEP);
|
|
186
|
+
parseMeta[index_1.CssExtractRspackPlugin.pluginName] =
|
|
187
|
+
JSON.stringify(dependencies);
|
|
192
188
|
}
|
|
193
|
-
callback(null, resultSource, undefined,
|
|
189
|
+
callback(null, resultSource, undefined, data);
|
|
194
190
|
};
|
|
195
191
|
this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
|
|
196
192
|
layer: options.layer,
|
|
@@ -81,3 +81,4 @@ __exportStar(require("./WebWorkerTemplatePlugin"), exports);
|
|
|
81
81
|
__exportStar(require("./WorkerPlugin"), exports);
|
|
82
82
|
__exportStar(require("./FetchCompileAsyncWasmPlugin"), exports);
|
|
83
83
|
__exportStar(require("./NoEmitOnErrorsPlugin"), exports);
|
|
84
|
+
__exportStar(require("./ContextReplacementPlugin"), exports);
|
package/dist/config/adapter.js
CHANGED
|
@@ -468,18 +468,14 @@ function getRawParserOptions(parser, type) {
|
|
|
468
468
|
}
|
|
469
469
|
function getRawJavascriptParserOptions(parser) {
|
|
470
470
|
return {
|
|
471
|
-
dynamicImportMode: parser.dynamicImportMode
|
|
472
|
-
dynamicImportPreload: parser.dynamicImportPreload?.toString()
|
|
473
|
-
dynamicImportPrefetch: parser.dynamicImportPrefetch?.toString()
|
|
474
|
-
dynamicImportFetchPriority: parser.dynamicImportFetchPriority
|
|
475
|
-
importMeta: parser.importMeta
|
|
476
|
-
url: parser.url
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
? parser.url
|
|
480
|
-
: "true",
|
|
481
|
-
exprContextCritical: parser.exprContextCritical ?? true,
|
|
482
|
-
wrappedContextCritical: parser.wrappedContextCritical ?? false,
|
|
471
|
+
dynamicImportMode: parser.dynamicImportMode,
|
|
472
|
+
dynamicImportPreload: parser.dynamicImportPreload?.toString(),
|
|
473
|
+
dynamicImportPrefetch: parser.dynamicImportPrefetch?.toString(),
|
|
474
|
+
dynamicImportFetchPriority: parser.dynamicImportFetchPriority,
|
|
475
|
+
importMeta: parser.importMeta,
|
|
476
|
+
url: parser.url?.toString(),
|
|
477
|
+
exprContextCritical: parser.exprContextCritical,
|
|
478
|
+
wrappedContextCritical: parser.wrappedContextCritical,
|
|
483
479
|
exportsPresence: parser.exportsPresence === false ? "false" : parser.exportsPresence,
|
|
484
480
|
importExportsPresence: parser.importExportsPresence === false
|
|
485
481
|
? "false"
|
|
@@ -487,12 +483,12 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
487
483
|
reexportExportsPresence: parser.reexportExportsPresence === false
|
|
488
484
|
? "false"
|
|
489
485
|
: parser.reexportExportsPresence,
|
|
490
|
-
strictExportPresence: parser.strictExportPresence
|
|
486
|
+
strictExportPresence: parser.strictExportPresence,
|
|
491
487
|
worker: typeof parser.worker === "boolean"
|
|
492
488
|
? parser.worker
|
|
493
489
|
? ["..."]
|
|
494
490
|
: []
|
|
495
|
-
: parser.worker
|
|
491
|
+
: parser.worker,
|
|
496
492
|
overrideStrict: parser.overrideStrict
|
|
497
493
|
};
|
|
498
494
|
}
|
|
@@ -28,14 +28,45 @@ export interface SourceMap {
|
|
|
28
28
|
export interface AdditionalData {
|
|
29
29
|
[index: string]: any;
|
|
30
30
|
}
|
|
31
|
+
export type LoaderContextCallback = (err?: Error | null, content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => void;
|
|
32
|
+
export type ErrorWithDetails = Error & {
|
|
33
|
+
details?: string;
|
|
34
|
+
};
|
|
35
|
+
export type ResolveCallback = (err: null | ErrorWithDetails, res?: string | false, req?: ResolveRequest) => void;
|
|
36
|
+
export interface DiagnosticLocation {
|
|
37
|
+
/** Text for highlighting the location */
|
|
38
|
+
text?: string;
|
|
39
|
+
/** 1-based line */
|
|
40
|
+
line: number;
|
|
41
|
+
/** 0-based column in bytes */
|
|
42
|
+
column: number;
|
|
43
|
+
/** Length in bytes */
|
|
44
|
+
length: number;
|
|
45
|
+
}
|
|
46
|
+
export interface Diagnostic {
|
|
47
|
+
message: string;
|
|
48
|
+
help?: string;
|
|
49
|
+
sourceCode?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Location to the source code.
|
|
52
|
+
*
|
|
53
|
+
* If `sourceCode` is not provided, location will be omitted.
|
|
54
|
+
*/
|
|
55
|
+
location?: DiagnosticLocation;
|
|
56
|
+
file?: string;
|
|
57
|
+
severity: "error" | "warning";
|
|
58
|
+
}
|
|
59
|
+
interface LoaderExperiments {
|
|
60
|
+
emitDiagnostic(diagnostic: Diagnostic): void;
|
|
61
|
+
}
|
|
31
62
|
export interface LoaderContext<OptionsType = {}> {
|
|
32
63
|
version: 2;
|
|
33
64
|
resource: string;
|
|
34
65
|
resourcePath: string;
|
|
35
66
|
resourceQuery: string;
|
|
36
67
|
resourceFragment: string;
|
|
37
|
-
async():
|
|
38
|
-
callback
|
|
68
|
+
async(): LoaderContextCallback;
|
|
69
|
+
callback: LoaderContextCallback;
|
|
39
70
|
cacheable(cacheable?: boolean): void;
|
|
40
71
|
sourceMap: boolean;
|
|
41
72
|
rootContext: string;
|
|
@@ -72,7 +103,7 @@ export interface LoaderContext<OptionsType = {}> {
|
|
|
72
103
|
*/
|
|
73
104
|
getOptions(schema?: any): OptionsType;
|
|
74
105
|
resolve(context: string, request: string, callback: (arg0: null | Error, arg1?: string | false, arg2?: ResolveRequest) => void): void;
|
|
75
|
-
getResolve(options: Resolve): (context:
|
|
106
|
+
getResolve(options: Resolve): ((context: string, request: string, callback: ResolveCallback) => void) | ((context: string, request: string) => Promise<string | false | undefined>);
|
|
76
107
|
getLogger(name: string): Logger;
|
|
77
108
|
emitError(error: Error): void;
|
|
78
109
|
emitWarning(warning: Error): void;
|
|
@@ -92,6 +123,11 @@ export interface LoaderContext<OptionsType = {}> {
|
|
|
92
123
|
baseUri?: string;
|
|
93
124
|
}, callback: (err?: Error, res?: any) => void): void;
|
|
94
125
|
fs: any;
|
|
126
|
+
/**
|
|
127
|
+
* This is an experimental API and maybe subject to change.
|
|
128
|
+
* @experimental
|
|
129
|
+
*/
|
|
130
|
+
experiments: LoaderExperiments;
|
|
95
131
|
utils: {
|
|
96
132
|
absolutify: (context: string, request: string) => string;
|
|
97
133
|
contextify: (context: string, request: string) => string;
|
|
@@ -102,6 +138,13 @@ export interface LoaderContext<OptionsType = {}> {
|
|
|
102
138
|
_compiler: Compiler;
|
|
103
139
|
_compilation: Compilation;
|
|
104
140
|
_module: Module;
|
|
141
|
+
/**
|
|
142
|
+
* Note: This is not a webpack public API, maybe removed in future.
|
|
143
|
+
* Store some data from loader, and consume it from parser, it may be removed in the future
|
|
144
|
+
*
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
__internal__parseMeta: Record<string, string>;
|
|
105
148
|
}
|
|
106
149
|
export type LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => string | void | Buffer | Promise<string | Buffer>;
|
|
107
150
|
export type PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object) => string | void | Buffer | Promise<string | Buffer>;
|
|
@@ -112,3 +155,4 @@ export type LoaderDefinition<OptionsType = {}, ContextAdditions = {}> = LoaderDe
|
|
|
112
155
|
export declare function createRawModuleRuleUses(uses: RuleSetUseItem | RuleSetUseItem[], path: string, options: ComposeJsUseOptions): RawModuleRuleUse[];
|
|
113
156
|
export declare function isUseSourceMap(devtool: RawOptions["devtool"]): boolean;
|
|
114
157
|
export declare function isUseSimpleSourceMap(devtool: RawOptions["devtool"]): boolean;
|
|
158
|
+
export {};
|
package/dist/config/defaults.js
CHANGED
|
@@ -74,10 +74,10 @@ const applyRspackOptionsDefaults = (options) => {
|
|
|
74
74
|
applyExternalsPresetsDefaults(options.externalsPresets, {
|
|
75
75
|
targetProperties
|
|
76
76
|
});
|
|
77
|
-
// @ts-expect-error
|
|
78
77
|
F(options, "externalsType", () => {
|
|
79
78
|
return options.output.library
|
|
80
|
-
?
|
|
79
|
+
? // loose type 'string', actual type is "commonjs" | "var" | "commonjs2"....
|
|
80
|
+
options.output.library.type
|
|
81
81
|
: options.output.module
|
|
82
82
|
? "module-import"
|
|
83
83
|
: "var";
|
|
@@ -159,12 +159,8 @@ const applyJavascriptParserOptionsDefaults = (parserOptions) => {
|
|
|
159
159
|
D(parserOptions, "url", true);
|
|
160
160
|
D(parserOptions, "exprContextCritical", true);
|
|
161
161
|
D(parserOptions, "wrappedContextCritical", false);
|
|
162
|
-
D(parserOptions, "exportsPresence", undefined);
|
|
163
|
-
D(parserOptions, "importExportsPresence", undefined);
|
|
164
|
-
D(parserOptions, "reexportExportsPresence", undefined);
|
|
165
162
|
D(parserOptions, "strictExportPresence", false);
|
|
166
163
|
D(parserOptions, "worker", ["..."]);
|
|
167
|
-
D(parserOptions, "overrideStrict", undefined);
|
|
168
164
|
D(parserOptions, "importMeta", true);
|
|
169
165
|
};
|
|
170
166
|
const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
|
|
@@ -851,7 +847,6 @@ const A = (obj, prop, factory) => {
|
|
|
851
847
|
if (item === "...") {
|
|
852
848
|
if (newArray === undefined) {
|
|
853
849
|
newArray = value.slice(0, i);
|
|
854
|
-
// @ts-expect-error
|
|
855
850
|
obj[prop] = newArray;
|
|
856
851
|
}
|
|
857
852
|
const items = factory();
|