@rspack/test-tools 1.7.0-beta.0 → 1.7.0

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.
Files changed (117) hide show
  1. package/dist/case/builtin.d.ts +2 -2
  2. package/dist/case/builtin.js +58 -58
  3. package/dist/case/cache.d.ts +2 -2
  4. package/dist/case/cache.js +34 -34
  5. package/dist/case/common.d.ts +2 -2
  6. package/dist/case/common.js +45 -45
  7. package/dist/case/compiler.d.ts +3 -3
  8. package/dist/case/compiler.js +21 -21
  9. package/dist/case/config.d.ts +3 -3
  10. package/dist/case/config.js +19 -19
  11. package/dist/case/defaults.d.ts +2 -2
  12. package/dist/case/defaults.js +10 -10
  13. package/dist/case/diagnostic.js +29 -29
  14. package/dist/case/error.d.ts +2 -2
  15. package/dist/case/error.js +21 -21
  16. package/dist/case/esm-output.js +30 -26
  17. package/dist/case/example.js +7 -7
  18. package/dist/case/hash.d.ts +2 -2
  19. package/dist/case/hash.js +16 -16
  20. package/dist/case/hook.d.ts +3 -3
  21. package/dist/case/hook.js +42 -42
  22. package/dist/case/hot-step.d.ts +2 -2
  23. package/dist/case/hot-step.js +46 -46
  24. package/dist/case/hot.d.ts +5 -5
  25. package/dist/case/hot.js +43 -43
  26. package/dist/case/incremental.d.ts +2 -2
  27. package/dist/case/incremental.js +9 -9
  28. package/dist/case/index.d.ts +31 -31
  29. package/dist/case/multi-compiler.d.ts +3 -3
  30. package/dist/case/multi-compiler.js +15 -15
  31. package/dist/case/native-watcher.js +6 -6
  32. package/dist/case/normal.js +46 -46
  33. package/dist/case/runner.d.ts +2 -2
  34. package/dist/case/runner.js +22 -15
  35. package/dist/case/serial.d.ts +2 -2
  36. package/dist/case/serial.js +4 -4
  37. package/dist/case/stats-api.d.ts +2 -2
  38. package/dist/case/stats-api.js +7 -7
  39. package/dist/case/stats-output.d.ts +2 -2
  40. package/dist/case/stats-output.js +45 -45
  41. package/dist/case/treeshaking.js +6 -6
  42. package/dist/case/watch.d.ts +1 -1
  43. package/dist/case/watch.js +59 -59
  44. package/dist/compiler.d.ts +3 -3
  45. package/dist/compiler.js +31 -31
  46. package/dist/helper/directory.d.ts +1 -1
  47. package/dist/helper/directory.js +15 -15
  48. package/dist/helper/disable-iconv-lite-warning.js +3 -3
  49. package/dist/helper/expect/diff.js +8 -8
  50. package/dist/helper/expect/error.js +9 -9
  51. package/dist/helper/expect/placeholder.js +9 -9
  52. package/dist/helper/expect/rspack.js +5 -5
  53. package/dist/helper/expect/to-be-typeof.js +2 -2
  54. package/dist/helper/expect/to-end-with.js +3 -3
  55. package/dist/helper/expect/to-match-file-snapshot.d.ts +1 -1
  56. package/dist/helper/expect/to-match-file-snapshot.js +23 -23
  57. package/dist/helper/hot-update/index.d.ts +1 -1
  58. package/dist/helper/hot-update/loader.js +1 -1
  59. package/dist/helper/hot-update/plugin.d.ts +1 -1
  60. package/dist/helper/hot-update/plugin.js +15 -15
  61. package/dist/helper/index.d.ts +8 -8
  62. package/dist/helper/is.js +2 -2
  63. package/dist/helper/legacy/EventSourceForNode.js +8 -8
  64. package/dist/helper/legacy/LogTestPlugin.js +18 -18
  65. package/dist/helper/legacy/asModule.js +6 -6
  66. package/dist/helper/legacy/captureStdio.js +6 -6
  67. package/dist/helper/legacy/checkArrayExpectation.js +26 -23
  68. package/dist/helper/legacy/copyDiff.js +5 -5
  69. package/dist/helper/legacy/createFakeWorker.js +13 -13
  70. package/dist/helper/legacy/createLazyTestEnv.js +11 -11
  71. package/dist/helper/legacy/currentScript.js +1 -1
  72. package/dist/helper/legacy/deprecationTracking.js +13 -19
  73. package/dist/helper/legacy/expectSource.js +5 -5
  74. package/dist/helper/legacy/fakeSystem.js +14 -14
  75. package/dist/helper/legacy/findOutputFiles.js +4 -4
  76. package/dist/helper/legacy/parseResource.js +4 -4
  77. package/dist/helper/legacy/regexEscape.js +2 -2
  78. package/dist/helper/legacy/supportDefaultAssignment.js +2 -2
  79. package/dist/helper/legacy/supportsTextDecoder.js +2 -2
  80. package/dist/helper/legacy/supportsUsing.js +1 -1
  81. package/dist/helper/legacy/urlToRelativePath.js +3 -3
  82. package/dist/helper/parse-modules.js +13 -13
  83. package/dist/helper/read-config-file.d.ts +2 -2
  84. package/dist/helper/read-config-file.js +3 -3
  85. package/dist/helper/serializers.d.ts +1 -1
  86. package/dist/helper/serializers.js +11 -11
  87. package/dist/helper/setup-env.js +17 -17
  88. package/dist/helper/setup-expect.js +1 -1
  89. package/dist/helper/setup-wasm.js +4 -4
  90. package/dist/helper/stringify-config.d.ts +1 -1
  91. package/dist/helper/stringify-config.js +3 -3
  92. package/dist/helper/update-snapshot.js +1 -1
  93. package/dist/helper/util/checkSourceMap.js +16 -17
  94. package/dist/helper/util/checkStats.js +3 -3
  95. package/dist/helper/util/expectWarningFactory.js +2 -2
  96. package/dist/helper/util/filterUtil.js +9 -9
  97. package/dist/index.d.ts +8 -8
  98. package/dist/index.js +1 -1
  99. package/dist/plugin/index.d.ts +1 -1
  100. package/dist/plugin/lazy-compilation-test-plugin.d.ts +1 -1
  101. package/dist/plugin/lazy-compilation-test-plugin.js +13 -13
  102. package/dist/runner/index.d.ts +2 -2
  103. package/dist/runner/node/index.d.ts +2 -2
  104. package/dist/runner/node/index.js +75 -74
  105. package/dist/runner/web/index.d.ts +2 -2
  106. package/dist/runner/web/index.js +45 -45
  107. package/dist/test/context.d.ts +2 -2
  108. package/dist/test/context.js +4 -4
  109. package/dist/test/creator.d.ts +1 -1
  110. package/dist/test/creator.js +28 -28
  111. package/dist/test/debug.d.ts +1 -1
  112. package/dist/test/debug.js +31 -31
  113. package/dist/test/tester.d.ts +1 -1
  114. package/dist/test/tester.js +11 -11
  115. package/dist/type.d.ts +3 -3
  116. package/package.json +7 -7
  117. package/rstest.d.ts +12 -12
@@ -3,9 +3,9 @@
3
3
  const System = {
4
4
  register: (name, deps, fn) => {
5
5
  if (!System.registry) {
6
- throw new Error("System is no initialized");
6
+ throw new Error('System is no initialized');
7
7
  }
8
- if (typeof name !== "string") {
8
+ if (typeof name !== 'string') {
9
9
  fn = deps;
10
10
  deps = name;
11
11
  name = System._nextName;
@@ -14,7 +14,7 @@ const System = {
14
14
  fn = deps;
15
15
  deps = [];
16
16
  }
17
- const dynamicExport = result => {
17
+ const dynamicExport = (result) => {
18
18
  if (System.registry[name] !== entry) {
19
19
  throw new Error(`Module ${name} calls dynamicExport too late`);
20
20
  }
@@ -34,11 +34,11 @@ const System = {
34
34
  };
35
35
  const systemContext = {
36
36
  meta: {
37
- url: `/${name}.js`
37
+ url: `/${name}.js`,
38
38
  },
39
39
  import() {
40
40
  return Promise.resolve();
41
- }
41
+ },
42
42
  };
43
43
  if (name in System.registry) {
44
44
  throw new Error(`Module ${name} is already registered`);
@@ -58,7 +58,7 @@ const System = {
58
58
  fn,
59
59
  mod,
60
60
  executed: false,
61
- exports: undefined
61
+ exports: undefined,
62
62
  };
63
63
  System.registry[name] = entry;
64
64
  },
@@ -66,27 +66,27 @@ const System = {
66
66
  System.registry[name] = {
67
67
  name,
68
68
  executed: true,
69
- exports
69
+ exports,
70
70
  };
71
71
  },
72
72
  registry: undefined,
73
73
  _require: undefined,
74
- _nextName: "(anonym)",
75
- setRequire: req => {
74
+ _nextName: '(anonym)',
75
+ setRequire: (req) => {
76
76
  System._require = req;
77
77
  },
78
- init: modules => {
78
+ init: (modules) => {
79
79
  System.registry = {};
80
80
  if (modules) {
81
81
  for (const name of Object.keys(modules)) {
82
82
  System.registry[name] = {
83
83
  executed: true,
84
- exports: modules[name]
84
+ exports: modules[name],
85
85
  };
86
86
  }
87
87
  }
88
88
  },
89
- execute: name => {
89
+ execute: (name) => {
90
90
  const m = System.registry[name];
91
91
  if (!m)
92
92
  throw new Error(`Module ${name} not registered`);
@@ -94,7 +94,7 @@ const System = {
94
94
  throw new Error(`Module ${name} was already executed`);
95
95
  return System.ensureExecuted(name);
96
96
  },
97
- ensureExecuted: name => {
97
+ ensureExecuted: (name) => {
98
98
  let m = System.registry[name];
99
99
  if (!m && System._require) {
100
100
  const oldName = System._nextName;
@@ -119,6 +119,6 @@ const System = {
119
119
  m.mod.execute();
120
120
  }
121
121
  return m.exports;
122
- }
122
+ },
123
123
  };
124
124
  module.exports = System;
@@ -1,7 +1,7 @@
1
1
  // @ts-nocheck
2
- "use strict";
3
- const fs = require("fs");
4
- const path = require("path");
2
+ 'use strict';
3
+ const fs = require('fs');
4
+ const path = require('path');
5
5
  /**
6
6
  * @param {{output: {path: string}}} options options
7
7
  * @param {RegExp} regexp regexp
@@ -10,5 +10,5 @@ const path = require("path");
10
10
  */
11
11
  module.exports = function findOutputFiles(options, regexp, subpath) {
12
12
  const files = fs.readdirSync(subpath ? path.join(options.output.path, subpath) : options.output.path);
13
- return files.filter(file => regexp.test(file));
13
+ return files.filter((file) => regexp.test(file));
14
14
  };
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.parseResource = void 0;
5
5
  const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/;
6
- const parseResource = str => {
6
+ const parseResource = (str) => {
7
7
  const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
8
8
  return {
9
9
  resource: str,
10
- path: match[1].replace(/\u200b(.)/g, "$1"),
11
- query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : "",
12
- fragment: match[3] || ""
10
+ path: match[1].replace(/\u200b(.)/g, '$1'),
11
+ query: match[2] ? match[2].replace(/\u200b(.)/g, '$1') : '',
12
+ fragment: match[3] || '',
13
13
  };
14
14
  };
15
15
  exports.parseResource = parseResource;
@@ -1,5 +1,5 @@
1
1
  // @ts-nocheck
2
- "use strict";
2
+ 'use strict';
3
3
  module.exports = function regexEscape(string) {
4
- return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
4
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
5
5
  };
@@ -4,8 +4,8 @@ module.exports = function supportDefaultAssignment() {
4
4
  try {
5
5
  // eslint-disable-next-line no-unused-vars
6
6
  var E = eval("class E { toString() { return 'default' } }");
7
- var f1 = eval("(function f1({a, b = E}) {return new b().toString();})");
8
- return f1({ a: "test" }) === "default";
7
+ var f1 = eval('(function f1({a, b = E}) {return new b().toString();})');
8
+ return f1({ a: 'test' }) === 'default';
9
9
  }
10
10
  catch (e) {
11
11
  return false;
@@ -1,7 +1,7 @@
1
- "use strict";
1
+ 'use strict';
2
2
  module.exports = function supportsTextDecoder() {
3
3
  try {
4
- return typeof TextDecoder !== "undefined";
4
+ return typeof TextDecoder !== 'undefined';
5
5
  }
6
6
  catch (_err) {
7
7
  return false;
@@ -1,5 +1,5 @@
1
1
  // @ts-nocheck
2
- "use strict";
2
+ 'use strict';
3
3
  module.exports = function supportsUsing() {
4
4
  try {
5
5
  const f = eval(`(function f() {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  // @ts-nocheck
3
- const URL = require("url").URL;
3
+ const URL = require('url').URL;
4
4
  module.exports = function urlToRelativePath(url) {
5
- if (url.startsWith("https://") || url.startsWith("file://")) {
5
+ if (url.startsWith('https://') || url.startsWith('file://')) {
6
6
  const urlObj = new URL(url);
7
- return `./${urlObj.pathname.split("/").pop()}`;
7
+ return `./${urlObj.pathname.split('/').pop()}`;
8
8
  }
9
9
  return `./${url}`;
10
10
  };
@@ -1,35 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseModules = parseModules;
4
- const BOOTSTRAP_SPLIT_LINE = "/************************************************************************/";
5
- const MODULE_START_FLAG = "/* start::";
6
- const MODULE_END_FLAG = "/* end::";
7
- const MODULE_FLAG_END = " */";
4
+ const BOOTSTRAP_SPLIT_LINE = '/************************************************************************/';
5
+ const MODULE_START_FLAG = '/* start::';
6
+ const MODULE_END_FLAG = '/* end::';
7
+ const MODULE_FLAG_END = ' */';
8
8
  function getStringBetween(raw, position, start, end) {
9
9
  const startFlagIndex = raw.indexOf(start, position);
10
10
  if (startFlagIndex === -1) {
11
11
  return {
12
12
  result: null,
13
- remain: position
13
+ remain: position,
14
14
  };
15
15
  }
16
16
  const endFlagIndex = raw.indexOf(end, startFlagIndex + start.length);
17
17
  if (endFlagIndex === -1) {
18
18
  return {
19
19
  result: null,
20
- remain: position
20
+ remain: position,
21
21
  };
22
22
  }
23
23
  return {
24
24
  result: raw.slice(startFlagIndex + start.length, endFlagIndex),
25
- remain: endFlagIndex + end.length
25
+ remain: endFlagIndex + end.length,
26
26
  };
27
27
  }
28
28
  function isValidModule(name) {
29
- if (name.startsWith("data:")) {
29
+ if (name.startsWith('data:')) {
30
30
  return false;
31
31
  }
32
- if (name.startsWith("https:")) {
32
+ if (name.startsWith('https:')) {
33
33
  return false;
34
34
  }
35
35
  return true;
@@ -42,7 +42,7 @@ function parseModules(content, options = {}) {
42
42
  // parse bootstrap code
43
43
  const bootstrap = getStringBetween(content, 0, BOOTSTRAP_SPLIT_LINE, BOOTSTRAP_SPLIT_LINE);
44
44
  if (bootstrap.result) {
45
- runtimeModules["webpack/runtime/bootstrap"] = bootstrap.result;
45
+ runtimeModules['webpack/runtime/bootstrap'] = bootstrap.result;
46
46
  }
47
47
  }
48
48
  // parse module & runtime module code
@@ -52,10 +52,10 @@ function parseModules(content, options = {}) {
52
52
  if (!moduleContent.result) {
53
53
  throw new Error(`Module code parsed error: ${moduleName}`);
54
54
  }
55
- const renamedModuleName = typeof options.renameModule === "function"
55
+ const renamedModuleName = typeof options.renameModule === 'function'
56
56
  ? options.renameModule(moduleName)
57
57
  : moduleName;
58
- if (moduleName.startsWith("webpack/runtime")) {
58
+ if (moduleName.startsWith('webpack/runtime')) {
59
59
  runtimeModules[renamedModuleName] = moduleContent.result;
60
60
  }
61
61
  else {
@@ -68,6 +68,6 @@ function parseModules(content, options = {}) {
68
68
  }
69
69
  return {
70
70
  modules,
71
- runtimeModules
71
+ runtimeModules,
72
72
  };
73
73
  }
@@ -1,3 +1,3 @@
1
- import type { RspackOptions } from "@rspack/core";
2
- import type { ITestContext } from "../type";
1
+ import type { RspackOptions } from '@rspack/core';
2
+ import type { ITestContext } from '../type';
3
3
  export declare function readConfigFile(files: string[], context: ITestContext, prevOption?: RspackOptions, functionApply?: (config: (RspackOptions | ((...args: unknown[]) => RspackOptions))[]) => RspackOptions[]): RspackOptions[];
@@ -7,16 +7,16 @@ exports.readConfigFile = readConfigFile;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const debug_1 = require("../test/debug");
9
9
  function readConfigFile(files, context, prevOption, functionApply) {
10
- const existsFile = files.find(i => fs_extra_1.default.existsSync(i));
10
+ const existsFile = files.find((i) => fs_extra_1.default.existsSync(i));
11
11
  let fileConfig = existsFile ? require(existsFile) : {};
12
- if (typeof fileConfig === "function") {
12
+ if (typeof fileConfig === 'function') {
13
13
  fileConfig = fileConfig({ config: prevOption }, { testPath: context.getDist(), tempPath: context.getTemp() });
14
14
  }
15
15
  const configArr = Array.isArray(fileConfig) ? fileConfig : [fileConfig];
16
16
  if (existsFile) {
17
17
  context.setValue(debug_1.DEBUG_SCOPES.CompilerOptionsReadConfigFile, {
18
18
  file: existsFile,
19
- config: fileConfig
19
+ config: fileConfig,
20
20
  });
21
21
  }
22
22
  return functionApply ? functionApply(configArr) : configArr;
@@ -1,2 +1,2 @@
1
- import type { Plugins } from "pretty-format";
1
+ import type { Plugins } from 'pretty-format';
2
2
  export declare const serializers: Plugins;
@@ -8,45 +8,45 @@ const rspack_1 = require("./expect/rspack");
8
8
  exports.serializers = [
9
9
  {
10
10
  test(received) {
11
- return typeof received === "string";
11
+ return typeof received === 'string';
12
12
  },
13
13
  print(received) {
14
14
  return (0, placeholder_1.normalizePlaceholder)(received.trim());
15
- }
15
+ },
16
16
  },
17
17
  // for diff
18
18
  {
19
19
  test(received) {
20
- return received?.constructor?.name === "RspackTestDiff";
20
+ return received?.constructor?.name === 'RspackTestDiff';
21
21
  },
22
22
  print(received, next) {
23
23
  return next((0, diff_1.normalizeDiff)(received));
24
- }
24
+ },
25
25
  },
26
26
  // for errors
27
27
  {
28
28
  test(received) {
29
- return received?.constructor?.name === "RspackStatsDiagnostics";
29
+ return received?.constructor?.name === 'RspackStatsDiagnostics';
30
30
  },
31
31
  print(received, next) {
32
32
  return next((0, error_1.normalizeDignostics)(received));
33
- }
33
+ },
34
34
  },
35
35
  {
36
36
  test(received) {
37
- return typeof received?.message === "string";
37
+ return typeof received?.message === 'string';
38
38
  },
39
39
  print(received, next) {
40
40
  return next((0, error_1.normalizeError)(received));
41
- }
41
+ },
42
42
  },
43
43
  // for stats
44
44
  {
45
45
  test(received) {
46
- return received?.constructor?.name === "RspackStats";
46
+ return received?.constructor?.name === 'RspackStats';
47
47
  },
48
48
  print(received, next) {
49
49
  return next((0, rspack_1.normalizeStats)(received));
50
- }
51
- }
50
+ },
51
+ },
52
52
  ];
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // @ts-nocheck
4
- const path = require("node:path");
4
+ const path = require('node:path');
5
5
  // Setup environment variable for binding testing
6
6
  if (process.env.RSPACK_BINDING_BUILDER_TESTING) {
7
- process.env.RSPACK_BINDING = path.resolve(__dirname, "../../node_modules/@rspack/binding-testing");
7
+ process.env.RSPACK_BINDING = path.resolve(__dirname, '../../node_modules/@rspack/binding-testing');
8
8
  }
9
9
  if (process.env.RSTEST) {
10
- global.printLogger ??= process.env.printLogger === "true";
10
+ global.printLogger ??= process.env.printLogger === 'true';
11
11
  global.__TEST_FIXTURES_PATH__ ??= process.env.__TEST_FIXTURES_PATH__;
12
- global.updateSnapshot ??= process.env.updateSnapshot === "true";
12
+ global.updateSnapshot ??= process.env.updateSnapshot === 'true';
13
13
  global.testFilter ??= process.env.testFilter;
14
14
  global.__TEST_PATH__ ??= process.env.__TEST_PATH__;
15
15
  global.__TEST_DIST_PATH__ ??= process.env.__TEST_DIST_PATH__;
16
16
  global.__ROOT_PATH__ ??= process.env.__ROOT_PATH__;
17
17
  global.__RSPACK_PATH__ ??= process.env.__RSPACK_PATH__;
18
18
  global.__RSPACK_TEST_TOOLS_PATH__ ??= process.env.__RSPACK_TEST_TOOLS_PATH__;
19
- global.__DEBUG__ ??= process.env.DEBUG === "test";
19
+ global.__DEBUG__ ??= process.env.DEBUG === 'test';
20
20
  }
21
21
  if (process.env.ALTERNATIVE_SORT) {
22
22
  const oldSort = Array.prototype.sort;
@@ -45,7 +45,7 @@ if (process.env.ALTERNATIVE_SORT) {
45
45
  }
46
46
  // Setup debugging info for tests
47
47
  if (process.env.DEBUG_INFO) {
48
- const addDebugInfo = it => {
48
+ const addDebugInfo = (it) => {
49
49
  return (name, fn, timeout) => {
50
50
  if (fn.length === 0) {
51
51
  it(name, () => {
@@ -53,10 +53,10 @@ if (process.env.DEBUG_INFO) {
53
53
  try {
54
54
  const promise = fn();
55
55
  if (promise?.then) {
56
- return promise.then(r => {
56
+ return promise.then((r) => {
57
57
  process.stdout.write(`DONE OK ${name}\n`);
58
58
  return r;
59
- }, e => {
59
+ }, (e) => {
60
60
  process.stdout.write(`DONE FAIL ${name}\n`);
61
61
  throw e;
62
62
  });
@@ -71,9 +71,9 @@ if (process.env.DEBUG_INFO) {
71
71
  }
72
72
  else {
73
73
  it(name, () => new Promise((resolve, reject) => {
74
- const done = err => (err ? reject(err) : resolve());
74
+ const done = (err) => (err ? reject(err) : resolve());
75
75
  process.stdout.write(`START2 ${name}\n`);
76
- return fn(err => {
76
+ return fn((err) => {
77
77
  if (err) {
78
78
  process.stdout.write(`DONE FAIL ${name}\n`);
79
79
  }
@@ -89,19 +89,19 @@ if (process.env.DEBUG_INFO) {
89
89
  // eslint-disable-next-line no-global-assign
90
90
  it = addDebugInfo(it);
91
91
  }
92
- const uncaughtExceptionListenersLength = process.listeners("uncaughtException").length;
93
- const unhandledRejectionListenersLength = process.listeners("unhandledRejection").length;
92
+ const uncaughtExceptionListenersLength = process.listeners('uncaughtException').length;
93
+ const unhandledRejectionListenersLength = process.listeners('unhandledRejection').length;
94
94
  // cspell:word wabt
95
95
  // Workaround for a memory leak in wabt
96
96
  // It leaks an Error object on construction
97
97
  // so it leaks the whole stack trace
98
- require("wast-loader");
98
+ require('wast-loader');
99
99
  // remove the last uncaughtException / unhandledRejection listener added by wast-loader
100
- const listeners = process.listeners("uncaughtException");
100
+ const listeners = process.listeners('uncaughtException');
101
101
  if (listeners.length > uncaughtExceptionListenersLength) {
102
- process.off("uncaughtException", listeners[listeners.length - 1]);
102
+ process.off('uncaughtException', listeners[listeners.length - 1]);
103
103
  }
104
- const listeners1 = process.listeners("unhandledRejection");
104
+ const listeners1 = process.listeners('unhandledRejection');
105
105
  if (listeners1.length > unhandledRejectionListenersLength) {
106
- process.off("unhandledRejection", listeners1[listeners1.length - 1]);
106
+ process.off('unhandledRejection', listeners1[listeners1.length - 1]);
107
107
  }
@@ -9,7 +9,7 @@ expect.extend({
9
9
  // @ts-expect-error
10
10
  toMatchFileSnapshotSync: to_match_file_snapshot_1.toMatchFileSnapshotSync,
11
11
  toBeTypeOf: to_be_typeof_1.toBeTypeOf,
12
- toEndWith: to_end_with_1.toEndWith
12
+ toEndWith: to_end_with_1.toEndWith,
13
13
  });
14
14
  for (const serializer of serializers_1.serializers) {
15
15
  expect.addSnapshotSerializer(serializer);
@@ -4,16 +4,16 @@
4
4
  // 2. Wasm target is a 32-bit platform, where all hash results are diffeference from the native targets.
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  function toMatchSnapshot() {
7
- return { pass: true, message: () => "" };
7
+ return { pass: true, message: () => '' };
8
8
  }
9
9
  function toMatchInlineSnapshot() {
10
- return { pass: true, message: () => "" };
10
+ return { pass: true, message: () => '' };
11
11
  }
12
12
  function toMatchFileSnapshotSync() {
13
- return { pass: true, message: () => "" };
13
+ return { pass: true, message: () => '' };
14
14
  }
15
15
  expect.extend({
16
16
  toMatchSnapshot,
17
17
  toMatchInlineSnapshot,
18
- toMatchFileSnapshotSync
18
+ toMatchFileSnapshotSync,
19
19
  });
@@ -1,2 +1,2 @@
1
- import type { RspackOptions } from "@rspack/core";
1
+ import type { RspackOptions } from '@rspack/core';
2
2
  export default function stringifyConfig(config: RspackOptions, verbose?: boolean): string | undefined;
@@ -25,15 +25,15 @@ function stringifyConfig(config, verbose = false) {
25
25
  if (value?.__ruleNames) {
26
26
  const ruleTypes = value.__ruleTypes;
27
27
  const prefix = `/* config.module${value.__ruleNames
28
- .map((r, index) => `.${ruleTypes ? ruleTypes[index] : "rule"}('${r}')`)
29
- .join("")}${value.__useName ? `.use('${value.__useName}')` : ``} */\n`;
28
+ .map((r, index) => `.${ruleTypes ? ruleTypes[index] : 'rule'}('${r}')`)
29
+ .join('')}${value.__useName ? `.use('${value.__useName}')` : ``} */\n`;
30
30
  return prefix + stringify(value);
31
31
  }
32
32
  if (value?.__expression) {
33
33
  return value.__expression;
34
34
  }
35
35
  // shorten long functions
36
- if (typeof value === "function") {
36
+ if (typeof value === 'function') {
37
37
  if (!verbose && value.toString().length > 100) {
38
38
  return `function () { /* omitted long function */ }`;
39
39
  }
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isUpdateSnapshot = isUpdateSnapshot;
4
4
  function isUpdateSnapshot() {
5
- return global.updateSnapshot || process.env.UPDATE_SNAPSHOT === "true";
5
+ return global.updateSnapshot || process.env.UPDATE_SNAPSHOT === 'true';
6
6
  }
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = checkSourceMap;
4
4
  // @ts-nocheck
5
5
  // Check the mapping of various key locations back to the original source
6
- async function checkSourceMap(out, outCodeMap, toSearch, _checkColumn = true // passing `false` indicating it's an `OriginalSource`.
7
- ) {
6
+ async function checkSourceMap(out, outCodeMap, toSearch, _checkColumn = true) {
8
7
  let failed = false;
9
8
  const recordCheck = (success, message) => {
10
9
  if (!success) {
@@ -12,17 +11,17 @@ async function checkSourceMap(out, outCodeMap, toSearch, _checkColumn = true //
12
11
  console.error(`❌ ${message}`);
13
12
  }
14
13
  };
15
- const sourceMap = require("source-map");
16
- const path = require("node:path");
14
+ const sourceMap = require('source-map');
15
+ const path = require('node:path');
17
16
  const sources = JSON.parse(outCodeMap).sources;
18
17
  for (const source of sources) {
19
- if (sources.filter(s => s === source).length > 1) {
18
+ if (sources.filter((s) => s === source).length > 1) {
20
19
  throw new Error(`Duplicate source ${JSON.stringify(source)} found in source map`);
21
20
  }
22
21
  }
23
22
  const map = await new sourceMap.SourceMapConsumer(outCodeMap);
24
23
  for (const id in toSearch) {
25
- const isSearchConfig = typeof toSearch[id] === "object" && toSearch[id] !== null;
24
+ const isSearchConfig = typeof toSearch[id] === 'object' && toSearch[id] !== null;
26
25
  const outId = isSearchConfig ? (toSearch[id].outId ?? id) : id;
27
26
  const checkColumn = isSearchConfig
28
27
  ? (toSearch[id].checkColumn ?? _checkColumn)
@@ -31,26 +30,26 @@ async function checkSourceMap(out, outCodeMap, toSearch, _checkColumn = true //
31
30
  const outIndex = out.indexOf(outId);
32
31
  if (outIndex < 0)
33
32
  throw new Error(`Failed to find "${outId}" in output ${out}`);
34
- const outLines = out.slice(0, outIndex).split("\n");
33
+ const outLines = out.slice(0, outIndex).split('\n');
35
34
  const outLine = outLines.length;
36
35
  const outLastLine = outLines[outLines.length - 1];
37
36
  let outColumn = outLastLine.length;
38
37
  const { source, line, column } = map.originalPositionFor({
39
38
  line: outLine,
40
- column: outColumn
39
+ column: outColumn,
41
40
  });
42
- recordCheck(source === inSource, `expected source: ${inSource}, observed source: ${source}@${line}:${column}, {out_source}@${outLine}:${outColumn}. ${checkColumn ? "" : "(column ignored)"}`);
41
+ recordCheck(source === inSource, `expected source: ${inSource}, observed source: ${source}@${line}:${column}, {out_source}@${outLine}:${outColumn}. ${checkColumn ? '' : '(column ignored)'}`);
43
42
  const inCode = map.sourceContentFor(source);
44
43
  let inIndex = inCode.indexOf(id);
45
44
  if (inIndex < 0)
46
45
  inIndex = inCode.indexOf(`'${id}'`);
47
46
  if (inIndex < 0)
48
47
  throw new Error(`Failed to find "${id}" in input ${inCode}`);
49
- const inLines = inCode.slice(0, inIndex).split("\n");
48
+ const inLines = inCode.slice(0, inIndex).split('\n');
50
49
  const inLine = inLines.length;
51
50
  const inLastLine = inLines[inLines.length - 1];
52
51
  let inColumn = inLastLine.length;
53
- if (path.extname(source) === "css") {
52
+ if (path.extname(source) === 'css') {
54
53
  const outMatch = /\s*content:\s*$/.exec(outLastLine);
55
54
  const inMatch = /\bcontent:\s*$/.exec(inLastLine);
56
55
  if (outMatch)
@@ -61,17 +60,17 @@ async function checkSourceMap(out, outCodeMap, toSearch, _checkColumn = true //
61
60
  const expected = JSON.stringify({
62
61
  source,
63
62
  line: inLine,
64
- column: checkColumn ? inColumn : 0
63
+ column: checkColumn ? inColumn : 0,
65
64
  });
66
65
  const observed = JSON.stringify({ source, line, column });
67
- recordCheck(expected === observed, `expected original position: ${expected}, observed original position: ${observed}, out: ${`${outLine},${outColumn},${outIndex}:${outId}`}, ${checkColumn ? "" : "(column ignored)"}`);
66
+ recordCheck(expected === observed, `expected original position: ${expected}, observed original position: ${observed}, out: ${`${outLine},${outColumn},${outIndex}:${outId}`}, ${checkColumn ? '' : '(column ignored)'}`);
68
67
  // Also check the reverse mapping
69
68
  const positions = map.allGeneratedPositionsFor({
70
69
  source,
71
70
  line: inLine,
72
- column: checkColumn ? inColumn : 0
71
+ column: checkColumn ? inColumn : 0,
73
72
  });
74
- recordCheck(positions.length > 0, `expected generated positions: 1, observed generated positions: ${positions.length} ${checkColumn ? "" : "(column ignored)"}`);
73
+ recordCheck(positions.length > 0, `expected generated positions: 1, observed generated positions: ${positions.length} ${checkColumn ? '' : '(column ignored)'}`);
75
74
  let found = false;
76
75
  for (const { line, column } of positions) {
77
76
  if (line === outLine) {
@@ -87,10 +86,10 @@ async function checkSourceMap(out, outCodeMap, toSearch, _checkColumn = true //
87
86
  }
88
87
  const expectedPosition = JSON.stringify({
89
88
  line: outLine,
90
- column: outColumn
89
+ column: outColumn,
91
90
  });
92
91
  const observedPositions = JSON.stringify(positions);
93
- recordCheck(found, `expected generated position: ${expectedPosition}, observed generated positions: ${observedPositions} ${checkColumn ? "" : "(column ignored)"}`);
92
+ recordCheck(found, `expected generated position: ${expectedPosition}, observed generated positions: ${observedPositions} ${checkColumn ? '' : '(column ignored)'}`);
94
93
  }
95
94
  return !failed;
96
95
  }
@@ -4,12 +4,12 @@ exports.checkChunkModules = function checkChunkModules(statsJson, chunkModulesMa
4
4
  for (const chunkId of Reflect.ownKeys(chunkModulesMap)) {
5
5
  const chunk = getChunk(statsJson, chunkId);
6
6
  const expectedModules = chunkModulesMap[chunkId];
7
- const chunkModules = chunk.modules.map(m => m.identifier);
7
+ const chunkModules = chunk.modules.map((m) => m.identifier);
8
8
  if (strict && expectedModules.length !== chunkModules.length) {
9
9
  throw new Error(`expect chunk ${chunkId} has ${expectedModules.length} modules: ${expectedModules}\nbut received ${chunkModules.length} modules`);
10
10
  }
11
11
  for (const module of expectedModules) {
12
- if (!chunkModules.find(moduleId => moduleId.includes(module))) {
12
+ if (!chunkModules.find((moduleId) => moduleId.includes(module))) {
13
13
  throw new Error(`chunk ${chunkId} has no module contains id: ${module}`);
14
14
  }
15
15
  }
@@ -17,7 +17,7 @@ exports.checkChunkModules = function checkChunkModules(statsJson, chunkModulesMa
17
17
  return true;
18
18
  };
19
19
  function getChunk(statsJson, id) {
20
- const chunk = statsJson.chunks.find(chunk => chunk.id.includes(id));
20
+ const chunk = statsJson.chunks.find((chunk) => chunk.id.includes(id));
21
21
  if (!chunk) {
22
22
  throw new Error(`cannot find chunk with id: ${id}`);
23
23
  }
@@ -5,14 +5,14 @@ module.exports = () => {
5
5
  let oldWarn;
6
6
  beforeEach(() => {
7
7
  oldWarn = console.warn;
8
- console.warn = m => warnings.push(m);
8
+ console.warn = (m) => warnings.push(m);
9
9
  });
10
10
  afterEach(() => {
11
11
  expectWarning();
12
12
  console.warn = oldWarn;
13
13
  });
14
14
  const expectWarning = (...regexp) => {
15
- expect(warnings).toEqual(regexp.map(r => expect.stringMatching(r)));
15
+ expect(warnings).toEqual(regexp.map((r) => expect.stringMatching(r)));
16
16
  warnings.length = 0;
17
17
  };
18
18
  return expectWarning;