@rspack/core 1.0.3 → 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.
@@ -1,7 +1,7 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 577:
4
+ /***/ 129:
5
5
  /***/ ((module) => {
6
6
 
7
7
  "use strict";
@@ -32,13 +32,13 @@ function clone (obj) {
32
32
 
33
33
  /***/ }),
34
34
 
35
- /***/ 500:
35
+ /***/ 545:
36
36
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
37
37
 
38
38
  var fs = __nccwpck_require__(147)
39
- var polyfills = __nccwpck_require__(722)
40
- var legacy = __nccwpck_require__(89)
41
- var clone = __nccwpck_require__(577)
39
+ var polyfills = __nccwpck_require__(325)
40
+ var legacy = __nccwpck_require__(560)
41
+ var clone = __nccwpck_require__(129)
42
42
 
43
43
  var util = __nccwpck_require__(837)
44
44
 
@@ -216,7 +216,7 @@ function patch (fs) {
216
216
 
217
217
  function go$copyFile (src, dest, flags, cb, startTime) {
218
218
  return fs$copyFile(src, dest, flags, function (err) {
219
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
219
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE' || err.code === 'EBUSY'))
220
220
  enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()])
221
221
  else {
222
222
  if (typeof cb === 'function')
@@ -487,7 +487,7 @@ function retry () {
487
487
 
488
488
  /***/ }),
489
489
 
490
- /***/ 89:
490
+ /***/ 560:
491
491
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
492
492
 
493
493
  var Stream = (__nccwpck_require__(781).Stream)
@@ -612,7 +612,7 @@ function legacy (fs) {
612
612
 
613
613
  /***/ }),
614
614
 
615
- /***/ 722:
615
+ /***/ 325:
616
616
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
617
617
 
618
618
  var constants = __nccwpck_require__(57)
@@ -1056,7 +1056,7 @@ module.exports = require("util");
1056
1056
  /******/ // startup
1057
1057
  /******/ // Load entry module and return exports
1058
1058
  /******/ // This entry module is referenced by other modules so it can't be inlined
1059
- /******/ var __webpack_exports__ = __nccwpck_require__(500);
1059
+ /******/ var __webpack_exports__ = __nccwpck_require__(545);
1060
1060
  /******/ module.exports = __webpack_exports__;
1061
1061
  /******/
1062
1062
  /******/ })()
@@ -201,7 +201,7 @@ export declare class Compilation {
201
201
  /**
202
202
  * Get the named chunk groups.
203
203
  *
204
- * Note: This is a proxy for webpack internal API, only method `get` and `keys` are supported now.
204
+ * Note: This is a proxy for webpack internal API, only method `get`, `keys`, `values` and `entries` are supported now.
205
205
  */
206
206
  get namedChunkGroups(): ReadonlyMap<string, Readonly<ChunkGroup>>;
207
207
  get modules(): ReadonlySet<Module>;
@@ -209,7 +209,7 @@ export declare class Compilation {
209
209
  /**
210
210
  * Get the named chunks.
211
211
  *
212
- * Note: This is a proxy for webpack internal API, only method `get` and `keys` is supported now.
212
+ * Note: This is a proxy for webpack internal API, only method `get`, `keys`, `values` and `entries` are supported now.
213
213
  */
214
214
  get namedChunks(): ReadonlyMap<string, Readonly<Chunk>>;
215
215
  get entries(): Map<string, EntryData>;
@@ -54,6 +54,7 @@ const StatsFactory_1 = require("./stats/StatsFactory");
54
54
  const StatsPrinter_1 = require("./stats/StatsPrinter");
55
55
  const AssetInfo_1 = require("./util/AssetInfo");
56
56
  const MergeCaller_1 = __importDefault(require("./util/MergeCaller"));
57
+ const createReadonlyMap_1 = require("./util/createReadonlyMap");
57
58
  const fake_1 = require("./util/fake");
58
59
  const memoize_1 = require("./util/memoize");
59
60
  const source_1 = require("./util/source");
@@ -199,10 +200,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
199
200
  /**
200
201
  * Get the named chunk groups.
201
202
  *
202
- * Note: This is a proxy for webpack internal API, only method `get` and `keys` are supported now.
203
+ * Note: This is a proxy for webpack internal API, only method `get`, `keys`, `values` and `entries` are supported now.
203
204
  */
204
205
  get namedChunkGroups() {
205
- return {
206
+ return (0, createReadonlyMap_1.createReadonlyMap)({
206
207
  keys: () => {
207
208
  const names = __classPrivateFieldGet(this, _Compilation_inner, "f").getNamedChunkGroupKeys();
208
209
  return names[Symbol.iterator]();
@@ -213,7 +214,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
213
214
  return chunk && ChunkGroup_1.ChunkGroup.__from_binding(chunk, __classPrivateFieldGet(this, _Compilation_inner, "f"));
214
215
  }
215
216
  }
216
- };
217
+ });
217
218
  }
218
219
  get modules() {
219
220
  return new Set(__classPrivateFieldGet(this, _Compilation_inner, "f").modules.map(module => Module_1.Module.__from_binding(module, this)));
@@ -224,10 +225,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
224
225
  /**
225
226
  * Get the named chunks.
226
227
  *
227
- * Note: This is a proxy for webpack internal API, only method `get` and `keys` is supported now.
228
+ * Note: This is a proxy for webpack internal API, only method `get`, `keys`, `values` and `entries` are supported now.
228
229
  */
229
230
  get namedChunks() {
230
- return {
231
+ return (0, createReadonlyMap_1.createReadonlyMap)({
231
232
  keys: () => {
232
233
  const names = __classPrivateFieldGet(this, _Compilation_inner, "f").getNamedChunkKeys();
233
234
  return names[Symbol.iterator]();
@@ -238,7 +239,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
238
239
  return chunk && Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compilation_inner, "f"));
239
240
  }
240
241
  }
241
- };
242
+ });
242
243
  }
243
244
  get entries() {
244
245
  return new Entries(__classPrivateFieldGet(this, _Compilation_inner, "f").entries);
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
- // @ts-expect-error
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
- // @ts-expect-error
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 name in this.hooks) {
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, (error, instance) => {
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
  });
@@ -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
- // @ts-expect-error
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
- // @ts-expect-error
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
- // @ts-expect-error
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
  }
@@ -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: any): void;
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
  }
@@ -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), 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
  });
@@ -8,19 +8,19 @@ export declare class Watching {
8
8
  watcher?: Watcher;
9
9
  pausedWatcher?: Watcher;
10
10
  compiler: Compiler;
11
- handler: (error?: Error, stats?: Stats) => void;
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?: () => boolean;
18
- onChange?: () => void;
19
- onInvalid?: () => void;
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: (error?: Error, stats?: Stats) => void);
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 (!__classPrivateFieldGet(this, _Watching_collectedChangedFiles, "f")) {
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
  }
@@ -34,14 +34,14 @@ declare const htmlRspackPluginOptions: z.ZodObject<{
34
34
  publicPath?: string | undefined;
35
35
  hash?: boolean | undefined;
36
36
  chunks?: string[] | undefined;
37
- template?: string | undefined;
38
- templateContent?: string | ((args_0: Record<string, any>, ...args_1: unknown[]) => string | Promise<string>) | undefined;
39
- templateParameters?: boolean | Record<string, string> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, any> | Promise<Record<string, any>>) | undefined;
40
- inject?: boolean | "head" | "body" | undefined;
41
37
  base?: string | {
42
38
  target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
43
39
  href?: string | undefined;
44
40
  } | undefined;
41
+ template?: string | undefined;
42
+ templateContent?: string | ((args_0: Record<string, any>, ...args_1: unknown[]) => string | Promise<string>) | undefined;
43
+ templateParameters?: boolean | Record<string, string> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, any> | Promise<Record<string, any>>) | undefined;
44
+ inject?: boolean | "head" | "body" | undefined;
45
45
  scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
46
46
  excludeChunks?: string[] | undefined;
47
47
  sri?: "sha256" | "sha384" | "sha512" | undefined;
@@ -54,14 +54,14 @@ declare const htmlRspackPluginOptions: z.ZodObject<{
54
54
  publicPath?: string | undefined;
55
55
  hash?: boolean | undefined;
56
56
  chunks?: string[] | undefined;
57
- template?: string | undefined;
58
- templateContent?: string | ((args_0: Record<string, any>, ...args_1: unknown[]) => string | Promise<string>) | undefined;
59
- templateParameters?: boolean | Record<string, string> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, any> | Promise<Record<string, any>>) | undefined;
60
- inject?: boolean | "head" | "body" | undefined;
61
57
  base?: string | {
62
58
  target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
63
59
  href?: string | undefined;
64
60
  } | undefined;
61
+ template?: string | undefined;
62
+ templateContent?: string | ((args_0: Record<string, any>, ...args_1: unknown[]) => string | Promise<string>) | undefined;
63
+ templateParameters?: boolean | Record<string, string> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, any> | Promise<Record<string, any>>) | undefined;
64
+ inject?: boolean | "head" | "body" | undefined;
65
65
  scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
66
66
  excludeChunks?: string[] | undefined;
67
67
  sri?: "sha256" | "sha384" | "sha512" | undefined;
@@ -100,14 +100,14 @@ declare const HtmlRspackPlugin: {
100
100
  publicPath?: string | undefined;
101
101
  hash?: boolean | undefined;
102
102
  chunks?: string[] | undefined;
103
- template?: string | undefined;
104
- templateContent?: string | ((args_0: Record<string, any>, ...args_1: unknown[]) => string | Promise<string>) | undefined;
105
- templateParameters?: boolean | Record<string, string> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, any> | Promise<Record<string, any>>) | undefined;
106
- inject?: boolean | "head" | "body" | undefined;
107
103
  base?: string | {
108
104
  target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
109
105
  href?: string | undefined;
110
106
  } | undefined;
107
+ template?: string | undefined;
108
+ templateContent?: string | ((args_0: Record<string, any>, ...args_1: unknown[]) => string | Promise<string>) | undefined;
109
+ templateParameters?: boolean | Record<string, string> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, any> | Promise<Record<string, any>>) | undefined;
110
+ inject?: boolean | "head" | "body" | undefined;
111
111
  scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
112
112
  excludeChunks?: string[] | undefined;
113
113
  sri?: "sha256" | "sha384" | "sha512" | undefined;
@@ -122,14 +122,14 @@ declare const HtmlRspackPlugin: {
122
122
  publicPath?: string | undefined;
123
123
  hash?: boolean | undefined;
124
124
  chunks?: string[] | undefined;
125
- template?: string | undefined;
126
- templateContent?: string | ((args_0: Record<string, any>, ...args_1: unknown[]) => string | Promise<string>) | undefined;
127
- templateParameters?: boolean | Record<string, string> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, any> | Promise<Record<string, any>>) | undefined;
128
- inject?: boolean | "head" | "body" | undefined;
129
125
  base?: string | {
130
126
  target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
131
127
  href?: string | undefined;
132
128
  } | undefined;
129
+ template?: string | undefined;
130
+ templateContent?: string | ((args_0: Record<string, any>, ...args_1: unknown[]) => string | Promise<string>) | undefined;
131
+ templateParameters?: boolean | Record<string, string> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, any> | Promise<Record<string, any>>) | undefined;
132
+ inject?: boolean | "head" | "body" | undefined;
133
133
  scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
134
134
  excludeChunks?: string[] | undefined;
135
135
  sri?: "sha256" | "sha384" | "sha512" | undefined;
@@ -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,4 +1,4 @@
1
- import type { RawCssExtractPluginOption } from "@rspack/binding";
1
+ import { type RawCssExtractPluginOption } from "@rspack/binding";
2
2
  import type { Compiler } from "../..";
3
3
  export * from "./loader";
4
4
  export type { CssExtractRspackLoaderOptions } from "./loader";
@@ -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
- // @ts-expect-error CssExtractRspackPlugin is a constant value of BuiltinPlugin
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,9 +65,8 @@ 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;
69
- let { publicPath } =
70
- /** @type {Compilation} */
71
- this._compilation.outputOptions;
68
+ const parseMeta = this.__internal__parseMeta;
69
+ let { publicPath } = this._compilation.outputOptions;
72
70
  if (typeof options.publicPath === "string") {
73
71
  // eslint-disable-next-line prefer-destructuring
74
72
  publicPath = options.publicPath;
@@ -90,7 +88,6 @@ const pitch = function (request, _, data) {
90
88
  publicPathForExtract = publicPath;
91
89
  }
92
90
  const handleExports = (originalExports) => {
93
- /** @type {Locals | undefined} */
94
91
  let locals;
95
92
  let namedExport;
96
93
  const esModule = typeof options.esModule !== "undefined" ? options.esModule : true;
@@ -110,7 +107,7 @@ const pitch = function (request, _, data) {
110
107
  if (!locals) {
111
108
  locals = {};
112
109
  }
113
- /** @type {Locals} */ locals[key] = originalExports[key];
110
+ locals[key] = originalExports[key];
114
111
  }
115
112
  }
116
113
  }
@@ -158,8 +155,7 @@ const pitch = function (request, _, data) {
158
155
  }
159
156
  })());
160
157
  const localsString = identifiers
161
- .map(([id, key]) => `\nvar ${id} = ${(0, utils_1.stringifyLocal)(
162
- /** @type {Locals} */ locals[key])};`)
158
+ .map(([id, key]) => `\nvar ${id} = ${(0, utils_1.stringifyLocal)(locals[key])};`)
163
159
  .join("");
164
160
  const exportsString = `export { ${identifiers
165
161
  .map(([id, key]) => `${id} as ${JSON.stringify(key)}`)
@@ -186,19 +182,15 @@ const pitch = function (request, _, data) {
186
182
  this.hot && emit
187
183
  ? hotLoader(result, { loaderContext: this, options, locals: locals })
188
184
  : result;
189
- const additionalData = { ...data };
190
185
  if (dependencies.length > 0) {
191
- additionalData[index_1.CssExtractRspackPlugin.pluginName] = dependencies
192
- .map(dep => {
193
- return JSON.stringify(dep);
194
- })
195
- .join(SERIALIZE_SEP);
186
+ parseMeta[index_1.CssExtractRspackPlugin.pluginName] =
187
+ JSON.stringify(dependencies);
196
188
  }
197
- callback(null, resultSource, undefined, additionalData);
189
+ callback(null, resultSource, undefined, data);
198
190
  };
199
191
  this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
200
192
  layer: options.layer,
201
- publicPath: /** @type {Filename} */ publicPathForExtract,
193
+ publicPath: publicPathForExtract,
202
194
  baseUri: `${exports.BASE_URI}/`
203
195
  }, (error, exports) => {
204
196
  if (error) {
@@ -221,8 +221,8 @@ function getRawModule(module, options) {
221
221
  const rules = ruleSet.map((rule, index) => getRawModuleRule(rule, `ruleSet[${index}]`, options, "javascript/auto"));
222
222
  return {
223
223
  rules,
224
- parser: getRawParserOptionsByModuleType(module.parser),
225
- generator: getRawGeneratorOptionsByModuleType(module.generator),
224
+ parser: getRawParserOptionsMap(module.parser),
225
+ generator: getRawGeneratorOptionsMap(module.generator),
226
226
  noParse: module.noParse
227
227
  };
228
228
  }
@@ -404,13 +404,13 @@ function getRawRuleSetLogicalConditions(logical) {
404
404
  not: logical.not ? getRawRuleSetCondition(logical.not) : undefined
405
405
  };
406
406
  }
407
- function getRawParserOptionsByModuleType(parser) {
407
+ function getRawParserOptionsMap(parser) {
408
408
  return Object.fromEntries(Object.entries(parser)
409
409
  .map(([k, v]) => [k, getRawParserOptions(v, k)])
410
410
  .filter(([k, v]) => v !== undefined));
411
411
  }
412
- function getRawGeneratorOptionsByModuleType(parser) {
413
- return Object.fromEntries(Object.entries(parser)
412
+ function getRawGeneratorOptionsMap(generator) {
413
+ return Object.fromEntries(Object.entries(generator)
414
414
  .map(([k, v]) => [k, getRawGeneratorOptions(v, k)])
415
415
  .filter(([k, v]) => v !== undefined));
416
416
  }
@@ -422,8 +422,10 @@ function getRawParserOptions(parser, type) {
422
422
  };
423
423
  }
424
424
  if (type === "javascript") {
425
- // Filter this out, since `parser["javascript"]` already merge into `parser["javascript/*"]` in default.ts
426
- return;
425
+ return {
426
+ type: "javascript",
427
+ javascript: getRawJavascriptParserOptions(parser)
428
+ };
427
429
  }
428
430
  if (type === "javascript/auto") {
429
431
  return {
@@ -486,19 +488,14 @@ function getRawJavascriptParserOptions(parser) {
486
488
  ? "false"
487
489
  : parser.reexportExportsPresence,
488
490
  strictExportPresence: parser.strictExportPresence ?? false,
489
- worker: getRawJavascriptParserOptionsWorker(parser.worker),
491
+ worker: typeof parser.worker === "boolean"
492
+ ? parser.worker
493
+ ? ["..."]
494
+ : []
495
+ : parser.worker ?? ["..."],
490
496
  overrideStrict: parser.overrideStrict
491
497
  };
492
498
  }
493
- function getRawJavascriptParserOptionsWorker(worker) {
494
- const DEFAULT_SYNTAX = [
495
- "Worker",
496
- "SharedWorker",
497
- "navigator.serviceWorker.register()",
498
- "Worker from worker_threads"
499
- ];
500
- return (worker === false ? [] : Array.isArray(worker) ? worker : ["..."]).flatMap(item => (item === "..." ? DEFAULT_SYNTAX : item));
501
- }
502
499
  function getRawAssetParserOptions(parser) {
503
500
  return {
504
501
  dataUrlCondition: parser.dataUrlCondition
@@ -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>;
@@ -54,13 +54,13 @@ function createRawModuleRuleUsesImpl(uses, path, options) {
54
54
  let o;
55
55
  let isBuiltin = false;
56
56
  if (use.loader.startsWith(exports.BUILTIN_LOADER_PREFIX)) {
57
- o = getBuiltinLoaderOptions(use.loader, use.options, options);
57
+ const temp = getBuiltinLoaderOptions(use.loader, use.options, options);
58
58
  // keep json with indent so miette can show pretty error
59
- o = (0, util_1.isNil)(o)
59
+ o = (0, util_1.isNil)(temp)
60
60
  ? undefined
61
- : typeof o === "string"
62
- ? o
63
- : JSON.stringify(o, null, 2);
61
+ : typeof temp === "string"
62
+ ? temp
63
+ : JSON.stringify(temp, null, 2);
64
64
  isBuiltin = true;
65
65
  }
66
66
  return {
@@ -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
- ? options.output.library.type
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";
@@ -152,20 +152,20 @@ const applybundlerInfoDefaults = (rspackFuture, library) => {
152
152
  }
153
153
  };
154
154
  const applySnapshotDefaults = (_snapshot, _env) => { };
155
- const applyJavascriptParserOptionsDefaults = (parserOptions, fallback) => {
156
- D(parserOptions, "dynamicImportMode", fallback?.dynamicImportMode ?? "lazy");
157
- D(parserOptions, "dynamicImportPrefetch", fallback?.dynamicImportPrefetch ?? false);
158
- D(parserOptions, "dynamicImportPreload", fallback?.dynamicImportPreload ?? false);
159
- D(parserOptions, "url", fallback?.url ?? true);
160
- D(parserOptions, "exprContextCritical", fallback?.exprContextCritical ?? true);
161
- D(parserOptions, "wrappedContextCritical", fallback?.wrappedContextCritical ?? false);
162
- D(parserOptions, "exportsPresence", fallback?.exportsPresence);
163
- D(parserOptions, "importExportsPresence", fallback?.importExportsPresence);
164
- D(parserOptions, "reexportExportsPresence", fallback?.reexportExportsPresence);
165
- D(parserOptions, "strictExportPresence", fallback?.strictExportPresence ?? false);
166
- D(parserOptions, "worker", fallback?.worker ?? ["..."]);
167
- D(parserOptions, "overrideStrict", fallback?.overrideStrict ?? undefined);
168
- D(parserOptions, "importMeta", fallback?.importMeta ?? true);
155
+ const applyJavascriptParserOptionsDefaults = (parserOptions) => {
156
+ D(parserOptions, "dynamicImportMode", "lazy");
157
+ D(parserOptions, "dynamicImportPrefetch", false);
158
+ D(parserOptions, "dynamicImportPreload", false);
159
+ D(parserOptions, "url", true);
160
+ D(parserOptions, "exprContextCritical", true);
161
+ D(parserOptions, "wrappedContextCritical", false);
162
+ D(parserOptions, "exportsPresence", undefined);
163
+ D(parserOptions, "importExportsPresence", undefined);
164
+ D(parserOptions, "reexportExportsPresence", undefined);
165
+ D(parserOptions, "strictExportPresence", false);
166
+ D(parserOptions, "worker", ["..."]);
167
+ D(parserOptions, "overrideStrict", undefined);
168
+ D(parserOptions, "importMeta", true);
169
169
  };
170
170
  const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
171
171
  (0, assertNotNil_1.assertNotNill)(module.parser);
@@ -180,15 +180,6 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }
180
180
  F(module.parser, "javascript", () => ({}));
181
181
  (0, assertNotNil_1.assertNotNill)(module.parser.javascript);
182
182
  applyJavascriptParserOptionsDefaults(module.parser.javascript);
183
- F(module.parser, "javascript/auto", () => ({}));
184
- (0, assertNotNil_1.assertNotNill)(module.parser["javascript/auto"]);
185
- applyJavascriptParserOptionsDefaults(module.parser["javascript/auto"], module.parser.javascript);
186
- F(module.parser, "javascript/dynamic", () => ({}));
187
- (0, assertNotNil_1.assertNotNill)(module.parser["javascript/dynamic"]);
188
- applyJavascriptParserOptionsDefaults(module.parser["javascript/dynamic"], module.parser.javascript);
189
- F(module.parser, "javascript/esm", () => ({}));
190
- (0, assertNotNil_1.assertNotNill)(module.parser["javascript/esm"]);
191
- applyJavascriptParserOptionsDefaults(module.parser["javascript/esm"], module.parser.javascript);
192
183
  if (css) {
193
184
  F(module.parser, "css", () => ({}));
194
185
  (0, assertNotNil_1.assertNotNill)(module.parser.css);
@@ -860,7 +851,6 @@ const A = (obj, prop, factory) => {
860
851
  if (item === "...") {
861
852
  if (newArray === undefined) {
862
853
  newArray = value.slice(0, i);
863
- // @ts-expect-error
864
854
  obj[prop] = newArray;
865
855
  }
866
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) {
@@ -41,12 +41,7 @@ function loadLoader(loader, callback) {
41
41
  if (e instanceof Error &&
42
42
  e.code === "EMFILE") {
43
43
  const retry = loadLoader.bind(null, loader, callback);
44
- if (typeof setImmediate === "function") {
45
- // node >= 0.9.0
46
- return void setImmediate(retry);
47
- }
48
- // node < 0.9.0
49
- return process.nextTick(retry);
44
+ return void setImmediate(retry);
50
45
  }
51
46
  return callback(e);
52
47
  }
@@ -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
  },
@@ -60,7 +60,8 @@ function default_1({ colors, appendOnly, stream }) {
60
60
  const writeStatusMessage = () => {
61
61
  if (!currentStatusMessage)
62
62
  return;
63
- //@ts-expect-error Property 'columns' does not exist on type 'WritableStream'.ts(2339)
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)
@@ -33,7 +33,12 @@ const getResourceName = (resource) => {
33
33
  return `${resource.slice(0, Math.min(resource.length - /* '..'.length */ 2, len))}..`;
34
34
  };
35
35
  const getModuleName = (name) => {
36
- const [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(name) || [];
36
+ const matchResourceMatch = /^([^!]+)!=!/.exec(name);
37
+ const n = matchResourceMatch
38
+ ? matchResourceMatch[0] +
39
+ getResourceName(name.slice(matchResourceMatch[0].length))
40
+ : name;
41
+ const [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(n) || [];
37
42
  return [prefix, getResourceName(resource)];
38
43
  };
39
44
  const mapLines = (str, fn) => str.split("\n").map(fn).join("\n");
@@ -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;
@@ -0,0 +1 @@
1
+ export declare function createReadonlyMap<T>(obj: Pick<ReadonlyMap<string, T>, "get" | "keys">): ReadonlyMap<string, Readonly<T>>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createReadonlyMap = void 0;
4
+ function createReadonlyMap(obj) {
5
+ return {
6
+ ...obj,
7
+ *values() {
8
+ const keys = this.keys();
9
+ for (const key of keys) {
10
+ yield this.get(key);
11
+ }
12
+ },
13
+ *entries() {
14
+ const keys = this.keys();
15
+ for (const key of keys) {
16
+ yield [key, this.get(key)];
17
+ }
18
+ },
19
+ forEach(callback, thisArg) {
20
+ for (const [key, value] of this) {
21
+ callback.call(thisArg, value, key, this);
22
+ }
23
+ },
24
+ [Symbol.iterator]() {
25
+ return this.entries();
26
+ }
27
+ };
28
+ }
29
+ exports.createReadonlyMap = createReadonlyMap;
@@ -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
- err.message = err.stack || err.message;
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",
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.3"
63
+ "@rspack/binding": "1.0.5"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@swc/helpers": ">=0.5.1"