@rspack/core 1.0.4 → 1.0.5
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/Compiler.js +7 -9
- package/dist/MultiCompiler.js +6 -26
- package/dist/MultiWatching.d.ts +3 -6
- package/dist/MultiWatching.js +6 -7
- package/dist/Watching.d.ts +5 -5
- package/dist/Watching.js +3 -11
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -5
- 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/config/adapterRuleUse.d.ts +7 -0
- package/dist/config/defaults.js +2 -3
- package/dist/loader-runner/index.js +4 -4
- package/dist/node/NodeWatchFileSystem.d.ts +1 -1
- package/dist/node/NodeWatchFileSystem.js +1 -4
- package/dist/node/nodeConsole.js +2 -1
- package/dist/util/comparators.js +0 -1
- package/dist/util/index.js +12 -1
- package/package.json +2 -2
package/dist/Compiler.js
CHANGED
|
@@ -220,8 +220,7 @@ class Compiler {
|
|
|
220
220
|
let normalizedChildName = childName;
|
|
221
221
|
if (typeof normalizedName === "function") {
|
|
222
222
|
if (typeof normalizedChildName === "function") {
|
|
223
|
-
|
|
224
|
-
return this.getInfrastructureLogger(_ => {
|
|
223
|
+
return this.getInfrastructureLogger(() => {
|
|
225
224
|
if (typeof normalizedName === "function") {
|
|
226
225
|
normalizedName = normalizedName();
|
|
227
226
|
if (!normalizedName) {
|
|
@@ -268,12 +267,13 @@ class Compiler {
|
|
|
268
267
|
*/
|
|
269
268
|
watch(watchOptions, handler) {
|
|
270
269
|
if (this.running) {
|
|
271
|
-
//
|
|
270
|
+
// cannot be resolved without assertion
|
|
271
|
+
// copy from webpack
|
|
272
|
+
// Type 'void' is not assignable to type 'Watching'.
|
|
272
273
|
return handler(new ConcurrentCompilationError_1.default());
|
|
273
274
|
}
|
|
274
275
|
this.running = true;
|
|
275
276
|
this.watchMode = true;
|
|
276
|
-
// @ts-expect-error
|
|
277
277
|
this.watching = new Watching_1.Watching(this, watchOptions, handler);
|
|
278
278
|
return this.watching;
|
|
279
279
|
}
|
|
@@ -287,7 +287,6 @@ class Compiler {
|
|
|
287
287
|
const startTime = Date.now();
|
|
288
288
|
this.running = true;
|
|
289
289
|
const doRun = () => {
|
|
290
|
-
// @ts-expect-error
|
|
291
290
|
const finalCallback = (err, stats) => {
|
|
292
291
|
this.idle = true;
|
|
293
292
|
this.cache.beginIdle();
|
|
@@ -426,11 +425,10 @@ class Compiler {
|
|
|
426
425
|
...__classPrivateFieldGet(childCompiler, _Compiler_builtinPlugins, "f"),
|
|
427
426
|
...__classPrivateFieldGet(this, _Compiler_builtinPlugins, "f").filter(plugin => plugin.canInherentFromParent === true)
|
|
428
427
|
], "f");
|
|
429
|
-
for (const
|
|
428
|
+
for (const hookName in this.hooks) {
|
|
429
|
+
const name = hookName;
|
|
430
430
|
if ((0, base_1.canInherentFromParent)(name)) {
|
|
431
|
-
//@ts-ignore
|
|
432
431
|
if (childCompiler.hooks[name]) {
|
|
433
|
-
//@ts-ignore
|
|
434
432
|
childCompiler.hooks[name].taps = this.hooks[name].taps.slice();
|
|
435
433
|
}
|
|
436
434
|
}
|
|
@@ -849,7 +847,7 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
849
847
|
}
|
|
850
848
|
}
|
|
851
849
|
if (__classPrivateFieldGet(this, _Compiler_nonSkippableRegisters, "f").join() !== kinds.join()) {
|
|
852
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (
|
|
850
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (_error, instance) => {
|
|
853
851
|
instance.setNonSkippableRegisters(kinds);
|
|
854
852
|
__classPrivateFieldSet(this, _Compiler_nonSkippableRegisters, kinds, "f");
|
|
855
853
|
});
|
package/dist/MultiCompiler.js
CHANGED
|
@@ -171,7 +171,6 @@ class MultiCompiler {
|
|
|
171
171
|
}
|
|
172
172
|
return false;
|
|
173
173
|
};
|
|
174
|
-
// @ts-expect-error
|
|
175
174
|
const sortEdges = (e1, e2) => {
|
|
176
175
|
return (e1.source.name.localeCompare(e2.source.name) ||
|
|
177
176
|
e1.target.name.localeCompare(e2.target.name));
|
|
@@ -193,7 +192,6 @@ class MultiCompiler {
|
|
|
193
192
|
}
|
|
194
193
|
}
|
|
195
194
|
}
|
|
196
|
-
/** @type {string[]} */
|
|
197
195
|
const errors = missing.map(m => `Compiler dependency \`${m}\` not found.`);
|
|
198
196
|
const stack = this.compilers.filter(c => !targetFound(c));
|
|
199
197
|
while (stack.length > 0) {
|
|
@@ -209,7 +207,6 @@ class MultiCompiler {
|
|
|
209
207
|
}
|
|
210
208
|
}
|
|
211
209
|
if (edges.size > 0) {
|
|
212
|
-
/** @type {string[]} */
|
|
213
210
|
const lines = Array.from(edges)
|
|
214
211
|
.sort(sortEdges)
|
|
215
212
|
.map(edge => `${edge.source.name} -> ${edge.target.name}`);
|
|
@@ -234,14 +231,8 @@ class MultiCompiler {
|
|
|
234
231
|
}
|
|
235
232
|
this.running = true;
|
|
236
233
|
if (this.validateDependencies(handler)) {
|
|
237
|
-
const watchings = __classPrivateFieldGet(this, _MultiCompiler_instances, "m", _MultiCompiler_runGraph).call(this,
|
|
238
|
-
|
|
239
|
-
(compiler, idx, done, isBlocked, setChanged, setInvalid) => {
|
|
240
|
-
const watching = compiler.watch(
|
|
241
|
-
// @ts-expect-error
|
|
242
|
-
Array.isArray(watchOptions) ? watchOptions[idx] : watchOptions,
|
|
243
|
-
// @ts-expect-error
|
|
244
|
-
done);
|
|
234
|
+
const watchings = __classPrivateFieldGet(this, _MultiCompiler_instances, "m", _MultiCompiler_runGraph).call(this, (compiler, idx, done, isBlocked, setChanged, setInvalid) => {
|
|
235
|
+
const watching = compiler.watch(Array.isArray(watchOptions) ? watchOptions[idx] : watchOptions, done);
|
|
245
236
|
if (watching) {
|
|
246
237
|
watching.onInvalid = setInvalid;
|
|
247
238
|
watching.onChange = setChanged;
|
|
@@ -254,7 +245,6 @@ class MultiCompiler {
|
|
|
254
245
|
if (!watching.running)
|
|
255
246
|
watching.invalidate();
|
|
256
247
|
}, handler);
|
|
257
|
-
// @ts-expect-error
|
|
258
248
|
return new MultiWatching_1.default(watchings, this);
|
|
259
249
|
}
|
|
260
250
|
return new MultiWatching_1.default([], this);
|
|
@@ -282,13 +272,13 @@ class MultiCompiler {
|
|
|
282
272
|
neo_async_1.default.each(this.compilers, (compiler, cb) => {
|
|
283
273
|
compiler.close(cb);
|
|
284
274
|
},
|
|
285
|
-
//
|
|
275
|
+
// cannot be resolved without assertion
|
|
276
|
+
// Type 'Error | null | undefined' is not assignable to type 'Error | null'
|
|
286
277
|
callback);
|
|
287
278
|
}
|
|
288
279
|
}
|
|
289
280
|
exports.MultiCompiler = MultiCompiler;
|
|
290
281
|
_MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _MultiCompiler_runGraph(setup, run, callback) {
|
|
291
|
-
/** @typedef {{ compiler: Compiler, setupResult: SetupResult, result: Stats, state: "pending" | "blocked" | "queued" | "starting" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] }} Node */
|
|
292
282
|
// State transitions for nodes:
|
|
293
283
|
// -> blocked (initial)
|
|
294
284
|
// blocked -> starting [running++] (when all parents done)
|
|
@@ -332,12 +322,6 @@ _MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _Mu
|
|
|
332
322
|
let errored = false;
|
|
333
323
|
let running = 0;
|
|
334
324
|
const parallelism = this._options.parallelism;
|
|
335
|
-
/**
|
|
336
|
-
* @param {Node} node node
|
|
337
|
-
* @param {Error=} err error
|
|
338
|
-
* @param {Stats=} stats result
|
|
339
|
-
* @returns {void}
|
|
340
|
-
*/
|
|
341
325
|
const nodeDone = (node, err, stats) => {
|
|
342
326
|
if (errored)
|
|
343
327
|
return;
|
|
@@ -401,8 +385,7 @@ _MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _Mu
|
|
|
401
385
|
* @param {Node} node node
|
|
402
386
|
* @returns {void}
|
|
403
387
|
*/
|
|
404
|
-
|
|
405
|
-
const nodeChange = node => {
|
|
388
|
+
const nodeChange = (node) => {
|
|
406
389
|
nodeInvalid(node);
|
|
407
390
|
if (node.state === "pending") {
|
|
408
391
|
node.state = "blocked";
|
|
@@ -414,9 +397,7 @@ _MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _Mu
|
|
|
414
397
|
};
|
|
415
398
|
const setupResults = [];
|
|
416
399
|
nodes.forEach((node, i) => {
|
|
417
|
-
setupResults.push((node.setupResult = setup(node.compiler, i,
|
|
418
|
-
// @ts-expect-error
|
|
419
|
-
nodeDone.bind(null, node), () => node.state !== "starting" && node.state !== "running", () => nodeChange(node), () => nodeInvalid(node))));
|
|
400
|
+
setupResults.push((node.setupResult = setup(node.compiler, i, nodeDone.bind(null, node), () => node.state !== "starting" && node.state !== "running", () => nodeChange(node), () => nodeInvalid(node))));
|
|
420
401
|
});
|
|
421
402
|
let processing = true;
|
|
422
403
|
const processQueue = () => {
|
|
@@ -433,7 +414,6 @@ _MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _Mu
|
|
|
433
414
|
node.parents.every(p => p.state === "done"))) {
|
|
434
415
|
running++;
|
|
435
416
|
node.state = "starting";
|
|
436
|
-
// @ts-expect-error
|
|
437
417
|
run(node.compiler, node.setupResult, nodeDone.bind(null, node));
|
|
438
418
|
node.state = "running";
|
|
439
419
|
}
|
package/dist/MultiWatching.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
+
import type { Callback } from "@rspack/lite-tapable";
|
|
10
11
|
import type { MultiCompiler } from "./MultiCompiler";
|
|
11
12
|
import type { Watching } from "./Watching";
|
|
12
13
|
declare class MultiWatching {
|
|
@@ -17,12 +18,8 @@ declare class MultiWatching {
|
|
|
17
18
|
* @param compiler - the compiler
|
|
18
19
|
*/
|
|
19
20
|
constructor(watchings: Watching[], compiler: MultiCompiler);
|
|
20
|
-
invalidate(callback:
|
|
21
|
-
|
|
22
|
-
* @param {Callback<void>} callback signals when the watcher is closed
|
|
23
|
-
* @returns {void}
|
|
24
|
-
*/
|
|
25
|
-
close(callback: any): void;
|
|
21
|
+
invalidate(callback: Callback<Error, void>): void;
|
|
22
|
+
close(callback: Callback<Error, void>): void;
|
|
26
23
|
suspend(): void;
|
|
27
24
|
resume(): void;
|
|
28
25
|
}
|
package/dist/MultiWatching.js
CHANGED
|
@@ -22,10 +22,12 @@ class MultiWatching {
|
|
|
22
22
|
this.watchings = watchings;
|
|
23
23
|
this.compiler = compiler;
|
|
24
24
|
}
|
|
25
|
-
// @ts-expect-error
|
|
26
25
|
invalidate(callback) {
|
|
27
26
|
if (callback) {
|
|
28
|
-
neo_async_1.default.each(this.watchings, (watching, callback) => watching.invalidate(callback),
|
|
27
|
+
neo_async_1.default.each(this.watchings, (watching, callback) => watching.invalidate(callback),
|
|
28
|
+
// cannot be resolved without assertion
|
|
29
|
+
// Type 'Error | null | undefined' is not assignable to type 'Error | null'
|
|
30
|
+
callback);
|
|
29
31
|
}
|
|
30
32
|
else {
|
|
31
33
|
for (const watching of this.watchings) {
|
|
@@ -33,11 +35,6 @@ class MultiWatching {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
|
-
/**
|
|
37
|
-
* @param {Callback<void>} callback signals when the watcher is closed
|
|
38
|
-
* @returns {void}
|
|
39
|
-
*/
|
|
40
|
-
// @ts-expect-error
|
|
41
38
|
close(callback) {
|
|
42
39
|
neo_async_1.default.forEach(this.watchings, (watching, finishedCallback) => {
|
|
43
40
|
watching.close(finishedCallback);
|
|
@@ -45,6 +42,8 @@ class MultiWatching {
|
|
|
45
42
|
this.compiler.hooks.watchClose.call();
|
|
46
43
|
if (typeof callback === "function") {
|
|
47
44
|
this.compiler.running = false;
|
|
45
|
+
// cannot be resolved without assertion
|
|
46
|
+
// Type 'Error | null | undefined' is not assignable to type 'Error | null'
|
|
48
47
|
callback(err);
|
|
49
48
|
}
|
|
50
49
|
});
|
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
|
}
|
|
@@ -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
|
|
@@ -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,
|
|
@@ -102,6 +102,13 @@ export interface LoaderContext<OptionsType = {}> {
|
|
|
102
102
|
_compiler: Compiler;
|
|
103
103
|
_compilation: Compilation;
|
|
104
104
|
_module: Module;
|
|
105
|
+
/**
|
|
106
|
+
* Note: This is not a webpack public API, maybe removed in future.
|
|
107
|
+
* Store some data from loader, and consume it from parser, it may be removed in the future
|
|
108
|
+
*
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
__internal__parseMeta: Record<string, string>;
|
|
105
112
|
}
|
|
106
113
|
export type LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => string | void | Buffer | Promise<string | Buffer>;
|
|
107
114
|
export type PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object) => string | void | Buffer | Promise<string | Buffer>;
|
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";
|
|
@@ -851,7 +851,6 @@ const A = (obj, prop, factory) => {
|
|
|
851
851
|
if (item === "...") {
|
|
852
852
|
if (newArray === undefined) {
|
|
853
853
|
newArray = value.slice(0, i);
|
|
854
|
-
// @ts-expect-error
|
|
855
854
|
obj[prop] = newArray;
|
|
856
855
|
}
|
|
857
856
|
const items = factory();
|
|
@@ -513,10 +513,8 @@ async function runLoaders(compiler, context) {
|
|
|
513
513
|
if (!(error instanceof Error)) {
|
|
514
514
|
error = new RspackError_1.NonErrorEmittedError(error);
|
|
515
515
|
}
|
|
516
|
-
const hasStack = !!error.stack;
|
|
517
516
|
error.name = "ModuleError";
|
|
518
517
|
error.message = `${error.message} (from: ${(0, util_1.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`;
|
|
519
|
-
!hasStack && Error.captureStackTrace(error);
|
|
520
518
|
error = (0, util_1.concatErrorMsgAndStack)(error);
|
|
521
519
|
error.moduleIdentifier = this._module.identifier();
|
|
522
520
|
compiler._lastCompilation.__internal__pushDiagnostic({
|
|
@@ -529,10 +527,8 @@ async function runLoaders(compiler, context) {
|
|
|
529
527
|
if (!(warning instanceof Error)) {
|
|
530
528
|
warning = new RspackError_1.NonErrorEmittedError(warning);
|
|
531
529
|
}
|
|
532
|
-
const hasStack = !!warning.stack;
|
|
533
530
|
warning.name = "ModuleWarning";
|
|
534
531
|
warning.message = `${warning.message} (from: ${(0, util_1.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`;
|
|
535
|
-
hasStack && Error.captureStackTrace(warning);
|
|
536
532
|
warning = (0, util_1.concatErrorMsgAndStack)(warning);
|
|
537
533
|
warning.moduleIdentifier = this._module.identifier();
|
|
538
534
|
compiler._lastCompilation.__internal__pushDiagnostic({
|
|
@@ -641,6 +637,10 @@ async function runLoaders(compiler, context) {
|
|
|
641
637
|
get: () => loaderContext.loaders[loaderContext.loaderIndex].data,
|
|
642
638
|
set: data => (loaderContext.loaders[loaderContext.loaderIndex].data = data)
|
|
643
639
|
});
|
|
640
|
+
Object.defineProperty(loaderContext, "__internal__parseMeta", {
|
|
641
|
+
enumerable: true,
|
|
642
|
+
get: () => context.__internal__parseMeta
|
|
643
|
+
});
|
|
644
644
|
switch (loaderState) {
|
|
645
645
|
case binding_1.JsLoaderState.Pitching: {
|
|
646
646
|
while (loaderContext.loaderIndex < loaderContext.loaders.length) {
|
|
@@ -14,5 +14,5 @@ export default class NodeWatchFileSystem implements WatchFileSystem {
|
|
|
14
14
|
watcherOptions: Watchpack.WatchOptions;
|
|
15
15
|
watcher: Watchpack;
|
|
16
16
|
constructor(inputFileSystem: InputFileSystem);
|
|
17
|
-
watch(files: Iterable<string>, directories: Iterable<string>, missing: Iterable<string>, startTime: number, options: Watchpack.WatchOptions, callback: (error: Error, fileTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, contextTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
|
|
17
|
+
watch(files: Iterable<string>, directories: Iterable<string>, missing: Iterable<string>, startTime: number, options: Watchpack.WatchOptions, callback: (error: Error | null, fileTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, contextTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
|
|
18
18
|
}
|
|
@@ -70,9 +70,7 @@ class NodeWatchFileSystem {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
|
|
73
|
-
callback(
|
|
74
|
-
// @ts-expect-error
|
|
75
|
-
null, fileTimeInfoEntries, contextTimeInfoEntries, changes, removals);
|
|
73
|
+
callback(null, fileTimeInfoEntries, contextTimeInfoEntries, changes, removals);
|
|
76
74
|
});
|
|
77
75
|
this.watcher.watch({ files, directories, missing, startTime });
|
|
78
76
|
if (oldWatcher) {
|
|
@@ -82,7 +80,6 @@ class NodeWatchFileSystem {
|
|
|
82
80
|
close: () => {
|
|
83
81
|
if (this.watcher) {
|
|
84
82
|
this.watcher.close();
|
|
85
|
-
// @ts-expect-error
|
|
86
83
|
this.watcher = null;
|
|
87
84
|
}
|
|
88
85
|
},
|
package/dist/node/nodeConsole.js
CHANGED
|
@@ -60,7 +60,8 @@ function default_1({ colors, appendOnly, stream }) {
|
|
|
60
60
|
const writeStatusMessage = () => {
|
|
61
61
|
if (!currentStatusMessage)
|
|
62
62
|
return;
|
|
63
|
-
|
|
63
|
+
// cannot be resolved without assertion, copy from webpack
|
|
64
|
+
// Property 'columns' does not exist on type 'WritableStream'.ts(2339)
|
|
64
65
|
const l = stream.columns;
|
|
65
66
|
const args = l
|
|
66
67
|
? (0, truncateArgs_1.truncateArgs)(currentStatusMessage, l - 1)
|
package/dist/util/comparators.js
CHANGED
|
@@ -69,7 +69,6 @@ const compareChunksById = (a, b) => {
|
|
|
69
69
|
};
|
|
70
70
|
exports.compareChunksById = compareChunksById;
|
|
71
71
|
const compareChunkGroupsByIndex = (a, b) => {
|
|
72
|
-
//@ts-expect-error copy from webpack
|
|
73
72
|
return a.index < b.index ? -1 : 1;
|
|
74
73
|
};
|
|
75
74
|
exports.compareChunkGroupsByIndex = compareChunkGroupsByIndex;
|
package/dist/util/index.js
CHANGED
|
@@ -65,7 +65,18 @@ function concatErrorMsgAndStack(err) {
|
|
|
65
65
|
}
|
|
66
66
|
const hideStack = "hideStack" in err && err.hideStack;
|
|
67
67
|
if (!hideStack && "stack" in err) {
|
|
68
|
-
|
|
68
|
+
// This is intended to be different than webpack,
|
|
69
|
+
// here we want to treat the almost the same as `Error.stack` just without the stack.
|
|
70
|
+
// Webpack uses `Error.message`, however it does not contain the `Error.prototype.name`
|
|
71
|
+
// `xxx` -> `Error: xxx`. So they behave the same even if `hideStack` is set to `true`.
|
|
72
|
+
err.message = err.stack || err.toString();
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// This is intended to be different than webpack,
|
|
76
|
+
// here we want to treat the almost the same as `Error.stack` just without the stack.
|
|
77
|
+
// Webpack uses `Error.message`, however it does not contain the `Error.prototype.name`
|
|
78
|
+
// `xxx` -> `Error: xxx`. So they behave the same even if `hideStack` is set to `true`.
|
|
79
|
+
err.message = err.toString();
|
|
69
80
|
}
|
|
70
81
|
// maybe `null`, use `undefined` to compatible with `Option<String>`
|
|
71
82
|
err.stack = err.stack || undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"webpackVersion": "5.75.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "The fast Rust-based web bundler with webpack-compatible API",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@module-federation/runtime-tools": "0.5.1",
|
|
61
61
|
"@rspack/lite-tapable": "1.0.0",
|
|
62
62
|
"caniuse-lite": "^1.0.30001616",
|
|
63
|
-
"@rspack/binding": "1.0.
|
|
63
|
+
"@rspack/binding": "1.0.5"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@swc/helpers": ">=0.5.1"
|