@rspack-debug/test-tools 1.4.11 → 1.6.4

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 (259) hide show
  1. package/README.md +1 -1
  2. package/dist/case/builtin.d.ts +3 -0
  3. package/dist/case/builtin.js +152 -14
  4. package/dist/case/cache.d.ts +2 -2
  5. package/dist/case/cache.js +214 -12
  6. package/dist/case/common.d.ts +11 -0
  7. package/dist/case/common.js +249 -0
  8. package/dist/case/compiler.d.ts +17 -4
  9. package/dist/case/compiler.js +149 -12
  10. package/dist/case/config.d.ts +7 -2
  11. package/dist/case/config.js +106 -18
  12. package/dist/case/defaults.d.ts +13 -4
  13. package/dist/case/defaults.js +73 -18
  14. package/dist/case/diagnostic.d.ts +6 -0
  15. package/dist/case/diagnostic.js +121 -14
  16. package/dist/case/error.d.ts +15 -4
  17. package/dist/case/error.js +137 -12
  18. package/dist/case/esm-output.d.ts +1 -0
  19. package/dist/case/esm-output.js +117 -0
  20. package/dist/case/example.d.ts +1 -0
  21. package/dist/case/example.js +57 -0
  22. package/dist/case/hash.d.ts +2 -2
  23. package/dist/case/hash.js +72 -9
  24. package/dist/case/hook.d.ts +36 -4
  25. package/dist/case/hook.js +209 -20
  26. package/dist/case/hot-step.d.ts +2 -2
  27. package/dist/case/hot-step.js +309 -13
  28. package/dist/case/hot.d.ts +11 -2
  29. package/dist/case/hot.js +217 -12
  30. package/dist/case/incremental.d.ts +2 -2
  31. package/dist/case/incremental.js +24 -45
  32. package/dist/case/index.d.ts +31 -20
  33. package/dist/case/index.js +50 -34
  34. package/dist/case/multi-compiler.d.ts +19 -0
  35. package/dist/case/multi-compiler.js +97 -0
  36. package/dist/case/{nativeWatcher.js → native-watcher.js} +11 -23
  37. package/dist/case/normal.d.ts +3 -0
  38. package/dist/case/normal.js +202 -18
  39. package/dist/case/runner.d.ts +19 -0
  40. package/dist/case/runner.js +113 -0
  41. package/dist/case/serial.d.ts +2 -2
  42. package/dist/case/serial.js +10 -14
  43. package/dist/case/stats-api.d.ts +8 -3
  44. package/dist/case/stats-api.js +69 -10
  45. package/dist/case/stats-output.d.ts +11 -0
  46. package/dist/case/stats-output.js +199 -8
  47. package/dist/case/treeshaking.js +34 -7
  48. package/dist/case/watch.d.ts +27 -0
  49. package/dist/case/watch.js +318 -22
  50. package/dist/compiler.d.ts +16 -16
  51. package/dist/compiler.js +120 -15
  52. package/dist/helper/directory.d.ts +1 -1
  53. package/dist/helper/directory.js +6 -2
  54. package/dist/helper/disable-iconv-lite-warning.d.ts +1 -0
  55. package/dist/helper/disable-iconv-lite-warning.js +12 -0
  56. package/dist/helper/expect/error.js +1 -1
  57. package/dist/helper/expect/placeholder.js +7 -7
  58. package/dist/helper/expect/to-match-file-snapshot.d.ts +1 -2
  59. package/dist/helper/expect/to-match-file-snapshot.js +3 -3
  60. package/dist/helper/hot-update/loader.d.ts +2 -1
  61. package/dist/helper/hot-update/loader.js +5 -30
  62. package/dist/helper/hot-update/plugin.d.ts +1 -1
  63. package/dist/helper/hot-update/plugin.js +14 -13
  64. package/dist/helper/index.d.ts +2 -1
  65. package/dist/helper/index.js +2 -1
  66. package/dist/helper/is.d.ts +2 -0
  67. package/dist/helper/is.js +15 -0
  68. package/dist/helper/legacy/LogTestPlugin.d.ts +6 -0
  69. package/dist/helper/legacy/LogTestPlugin.js +35 -0
  70. package/dist/helper/legacy/asModule.js +0 -2
  71. package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -1
  72. package/dist/helper/legacy/checkArrayExpectation.js +8 -8
  73. package/dist/helper/legacy/createFakeWorker.d.ts +2 -2
  74. package/dist/helper/legacy/createFakeWorker.js +44 -20
  75. package/dist/helper/legacy/createLazyTestEnv.d.ts +3 -2
  76. package/dist/helper/legacy/createLazyTestEnv.js +3 -3
  77. package/dist/helper/legacy/deprecationTracking.d.ts +1 -0
  78. package/dist/helper/legacy/deprecationTracking.js +41 -0
  79. package/dist/helper/legacy/expectSource.d.ts +10 -0
  80. package/dist/helper/legacy/expectSource.js +23 -0
  81. package/dist/helper/legacy/findOutputFiles.d.ts +6 -0
  82. package/dist/helper/legacy/findOutputFiles.js +14 -0
  83. package/dist/helper/legacy/regexEscape.d.ts +2 -0
  84. package/dist/helper/legacy/regexEscape.js +5 -0
  85. package/dist/helper/legacy/supportDefaultAssignment.js +13 -0
  86. package/dist/helper/legacy/supportsTextDecoder.d.ts +2 -0
  87. package/dist/helper/legacy/supportsTextDecoder.js +9 -0
  88. package/dist/helper/legacy/supportsUsing.d.ts +2 -0
  89. package/dist/helper/legacy/supportsUsing.js +26 -0
  90. package/dist/helper/legacy/urlToRelativePath.js +5 -2
  91. package/dist/helper/read-config-file.d.ts +3 -2
  92. package/dist/helper/read-config-file.js +12 -2
  93. package/dist/helper/setup-env.js +26 -4
  94. package/dist/helper/setup-expect.js +2 -2
  95. package/dist/helper/setup-wasm.js +2 -2
  96. package/dist/helper/stringify-config.d.ts +2 -0
  97. package/dist/helper/stringify-config.js +43 -0
  98. package/dist/helper/util/checkStats.d.ts +0 -1
  99. package/dist/helper/util/checkStats.js +0 -18
  100. package/dist/helper/util/expectWarningFactory.js +2 -4
  101. package/dist/index.d.ts +0 -4
  102. package/dist/index.js +1 -4
  103. package/dist/plugin/index.d.ts +0 -3
  104. package/dist/plugin/index.js +0 -3
  105. package/dist/plugin/lazy-compilation-test-plugin.js +4 -4
  106. package/dist/runner/index.d.ts +2 -9
  107. package/dist/runner/index.js +2 -9
  108. package/dist/runner/node/index.d.ts +41 -0
  109. package/dist/runner/node/index.js +450 -0
  110. package/dist/runner/web/index.d.ts +30 -0
  111. package/dist/runner/web/index.js +343 -0
  112. package/dist/test/context.d.ts +15 -18
  113. package/dist/test/context.js +52 -57
  114. package/dist/test/creator.d.ts +20 -19
  115. package/dist/test/creator.js +69 -57
  116. package/dist/test/debug.d.ts +15 -0
  117. package/dist/test/debug.js +205 -0
  118. package/dist/test/tester.d.ts +1 -0
  119. package/dist/test/tester.js +44 -6
  120. package/dist/type.d.ts +94 -64
  121. package/dist/type.js +8 -12
  122. package/package.json +22 -61
  123. package/rstest.d.ts +24 -0
  124. package/dist/case/diff.d.ts +0 -3
  125. package/dist/case/diff.js +0 -126
  126. package/dist/compare/comparator.d.ts +0 -17
  127. package/dist/compare/comparator.js +0 -52
  128. package/dist/compare/compare.d.ts +0 -17
  129. package/dist/compare/compare.js +0 -175
  130. package/dist/compare/format-code.d.ts +0 -16
  131. package/dist/compare/format-code.js +0 -239
  132. package/dist/compare/index.d.ts +0 -5
  133. package/dist/compare/index.js +0 -21
  134. package/dist/compare/replace-module-argument.d.ts +0 -1
  135. package/dist/compare/replace-module-argument.js +0 -8
  136. package/dist/compare/replace-runtime-module-name.d.ts +0 -1
  137. package/dist/compare/replace-runtime-module-name.js +0 -71
  138. package/dist/helper/legacy/FakeDocument.d.ts +0 -54
  139. package/dist/helper/legacy/FakeDocument.js +0 -278
  140. package/dist/helper/legacy/createLogger.d.ts +0 -23
  141. package/dist/helper/legacy/createLogger.js +0 -20
  142. package/dist/helper/legacy/supportsImportFn.d.ts +0 -1
  143. package/dist/helper/legacy/supportsImportFn.js +0 -15
  144. package/dist/helper/legacy/supportsWorker.js +0 -17
  145. package/dist/helper/legacy/walkCssTokens.d.ts +0 -40
  146. package/dist/helper/legacy/walkCssTokens.js +0 -761
  147. package/dist/helper/legacy/warmup-webpack.d.ts +0 -1
  148. package/dist/helper/legacy/warmup-webpack.js +0 -26
  149. package/dist/helper/loaders/hot-update.d.ts +0 -1
  150. package/dist/helper/loaders/hot-update.js +0 -40
  151. package/dist/helper/plugins/hot-update.d.ts +0 -7
  152. package/dist/helper/plugins/hot-update.js +0 -40
  153. package/dist/helper/plugins/index.d.ts +0 -1
  154. package/dist/helper/plugins/index.js +0 -17
  155. package/dist/helper/util/currentWatchStep.d.ts +0 -1
  156. package/dist/helper/util/currentWatchStep.js +0 -2
  157. package/dist/helper/util/identifier.d.ts +0 -76
  158. package/dist/helper/util/identifier.js +0 -339
  159. package/dist/helper/util/replaceMitteDiagnostic.d.ts +0 -2
  160. package/dist/helper/util/replaceMitteDiagnostic.js +0 -17
  161. package/dist/plugin/rspack-diff-config-plugin.d.ts +0 -7
  162. package/dist/plugin/rspack-diff-config-plugin.js +0 -42
  163. package/dist/plugin/webpack-diff-config-plugin.d.ts +0 -7
  164. package/dist/plugin/webpack-diff-config-plugin.js +0 -41
  165. package/dist/plugin/webpack-module-placeholder-plugin.d.ts +0 -3
  166. package/dist/plugin/webpack-module-placeholder-plugin.js +0 -106
  167. package/dist/processor/basic.d.ts +0 -24
  168. package/dist/processor/basic.js +0 -146
  169. package/dist/processor/builtin.d.ts +0 -9
  170. package/dist/processor/builtin.js +0 -171
  171. package/dist/processor/cache.d.ts +0 -20
  172. package/dist/processor/cache.js +0 -128
  173. package/dist/processor/config.d.ts +0 -11
  174. package/dist/processor/config.js +0 -81
  175. package/dist/processor/defaults.d.ts +0 -30
  176. package/dist/processor/defaults.js +0 -72
  177. package/dist/processor/diagnostic.d.ts +0 -15
  178. package/dist/processor/diagnostic.js +0 -102
  179. package/dist/processor/diff.d.ts +0 -30
  180. package/dist/processor/diff.js +0 -140
  181. package/dist/processor/error.d.ts +0 -23
  182. package/dist/processor/error.js +0 -95
  183. package/dist/processor/hash.d.ts +0 -10
  184. package/dist/processor/hash.js +0 -63
  185. package/dist/processor/hook.d.ts +0 -44
  186. package/dist/processor/hook.js +0 -204
  187. package/dist/processor/hot-incremental.d.ts +0 -14
  188. package/dist/processor/hot-incremental.js +0 -43
  189. package/dist/processor/hot-step.d.ts +0 -18
  190. package/dist/processor/hot-step.js +0 -304
  191. package/dist/processor/hot.d.ts +0 -17
  192. package/dist/processor/hot.js +0 -140
  193. package/dist/processor/index.d.ts +0 -20
  194. package/dist/processor/index.js +0 -36
  195. package/dist/processor/multi.d.ts +0 -17
  196. package/dist/processor/multi.js +0 -73
  197. package/dist/processor/normal.d.ts +0 -12
  198. package/dist/processor/normal.js +0 -150
  199. package/dist/processor/simple.d.ts +0 -23
  200. package/dist/processor/simple.js +0 -49
  201. package/dist/processor/snapshot.d.ts +0 -12
  202. package/dist/processor/snapshot.js +0 -66
  203. package/dist/processor/stats-api.d.ts +0 -18
  204. package/dist/processor/stats-api.js +0 -48
  205. package/dist/processor/stats.d.ts +0 -18
  206. package/dist/processor/stats.js +0 -206
  207. package/dist/processor/treeshaking.d.ts +0 -10
  208. package/dist/processor/treeshaking.js +0 -33
  209. package/dist/processor/watch.d.ts +0 -30
  210. package/dist/processor/watch.js +0 -241
  211. package/dist/reporter/diff-html.d.ts +0 -15
  212. package/dist/reporter/diff-html.js +0 -69
  213. package/dist/reporter/diff-stats.d.ts +0 -24
  214. package/dist/reporter/diff-stats.js +0 -131
  215. package/dist/reporter/index.d.ts +0 -2
  216. package/dist/reporter/index.js +0 -18
  217. package/dist/runner/basic.d.ts +0 -10
  218. package/dist/runner/basic.js +0 -63
  219. package/dist/runner/cache.d.ts +0 -5
  220. package/dist/runner/cache.js +0 -90
  221. package/dist/runner/hot-step.d.ts +0 -5
  222. package/dist/runner/hot-step.js +0 -87
  223. package/dist/runner/hot.d.ts +0 -5
  224. package/dist/runner/hot.js +0 -83
  225. package/dist/runner/multiple.d.ts +0 -11
  226. package/dist/runner/multiple.js +0 -38
  227. package/dist/runner/normal.d.ts +0 -5
  228. package/dist/runner/normal.js +0 -20
  229. package/dist/runner/runner/basic.d.ts +0 -30
  230. package/dist/runner/runner/basic.js +0 -107
  231. package/dist/runner/runner/cjs.d.ts +0 -14
  232. package/dist/runner/runner/cjs.js +0 -151
  233. package/dist/runner/runner/esm.d.ts +0 -7
  234. package/dist/runner/runner/esm.js +0 -125
  235. package/dist/runner/runner/index.d.ts +0 -8
  236. package/dist/runner/runner/index.js +0 -24
  237. package/dist/runner/runner/normal.d.ts +0 -9
  238. package/dist/runner/runner/normal.js +0 -23
  239. package/dist/runner/runner/watch.d.ts +0 -16
  240. package/dist/runner/runner/watch.js +0 -27
  241. package/dist/runner/runner/web/fake.d.ts +0 -18
  242. package/dist/runner/runner/web/fake.js +0 -143
  243. package/dist/runner/runner/web/jsdom.d.ts +0 -26
  244. package/dist/runner/runner/web/jsdom.js +0 -219
  245. package/dist/runner/runner/web.d.ts +0 -15
  246. package/dist/runner/runner/web.js +0 -32
  247. package/dist/runner/type.d.ts +0 -42
  248. package/dist/runner/type.js +0 -9
  249. package/dist/runner/watch.d.ts +0 -7
  250. package/dist/runner/watch.js +0 -60
  251. package/dist/test/simple.d.ts +0 -5
  252. package/dist/test/simple.js +0 -43
  253. package/jest.d.ts +0 -25
  254. package/template/diff.bundle.css +0 -1
  255. package/template/diff.bundle.js +0 -144
  256. package/template/diff.html +0 -14
  257. package/template/editor.worker.js +0 -1
  258. /package/dist/case/{nativeWatcher.d.ts → native-watcher.d.ts} +0 -0
  259. /package/dist/helper/legacy/{supportsWorker.d.ts → supportDefaultAssignment.d.ts} +0 -0
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.normalizePlaceholder = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
4
  const path_serializer_1 = require("path-serializer");
9
5
  // 1. escapeEOL \r\n -> \n
10
6
  // 2. replace <RSPACK_ROOT> etc
@@ -13,14 +9,18 @@ const placeholderSerializer = (0, path_serializer_1.createSnapshotSerializer)({
13
9
  root: __dirname.includes("node_modules")
14
10
  ? // Use `process.cwd()` when using outside Rspack
15
11
  process.cwd()
16
- : node_path_1.default.resolve(__dirname, "../../../../../"),
12
+ : __ROOT_PATH__,
17
13
  replace: [
18
14
  {
19
- match: node_path_1.default.resolve(__dirname, "../../../"),
15
+ match: __RSPACK_TEST_TOOLS_PATH__,
20
16
  mark: "test_tools_root"
21
17
  },
22
18
  {
23
- match: node_path_1.default.resolve(__dirname, "../../../../rspack"),
19
+ match: __TEST_PATH__,
20
+ mark: "test_root"
21
+ },
22
+ {
23
+ match: __RSPACK_PATH__,
24
24
  mark: "rspack_root"
25
25
  },
26
26
  {
@@ -1,4 +1,3 @@
1
- import type { FileMatcherOptions } from "../../../jest";
2
1
  /**
3
2
  * Match given content against content of the specified file.
4
3
  *
@@ -6,7 +5,7 @@ import type { FileMatcherOptions } from "../../../jest";
6
5
  * @param filepath Path to the file to match against
7
6
  * @param options Additional options for matching
8
7
  */
9
- export declare function toMatchFileSnapshot(this: {
8
+ export declare function toMatchFileSnapshotSync(this: {
10
9
  testPath: string;
11
10
  currentTestName: string;
12
11
  assertionCalls: number;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.toMatchFileSnapshot = toMatchFileSnapshot;
7
+ exports.toMatchFileSnapshotSync = toMatchFileSnapshotSync;
8
8
  /* istanbul ignore file */
9
9
  const node_fs_1 = __importDefault(require("node:fs"));
10
10
  const node_path_1 = __importDefault(require("node:path"));
@@ -19,7 +19,7 @@ const { getSerializers } = require(node_path_1.default.join(node_path_1.default.
19
19
  * Check if 2 strings or buffer are equal
20
20
  */
21
21
  const isEqual = (a, b) => {
22
- // @ts-ignore: TypeScript gives error if we pass string to buffer.equals
22
+ // @ts-expect-error: TypeScript gives error if we pass string to buffer.equals
23
23
  return Buffer.isBuffer(a) ? a.equals(b) : a === b;
24
24
  };
25
25
  /**
@@ -29,7 +29,7 @@ const isEqual = (a, b) => {
29
29
  * @param filepath Path to the file to match against
30
30
  * @param options Additional options for matching
31
31
  */
32
- function toMatchFileSnapshot(rawContent, filepath, options = {}) {
32
+ function toMatchFileSnapshotSync(rawContent, filepath, options = {}) {
33
33
  const content = Buffer.isBuffer(rawContent)
34
34
  ? rawContent
35
35
  : serialize(rawContent, /* ident */ 2, {
@@ -1 +1,2 @@
1
- export default function (c: string): string;
1
+ declare const loader: (c: string) => string;
2
+ export default loader;
@@ -1,32 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- function default_1(c) {
5
- let content = c;
6
- if (content.includes("NEXT_HMR")) {
7
- content = `
8
- ${content}
9
- let __hmr_children__ = [...module.children];
10
- let __hmr_used_exports__ = __hmr_children__.reduce((res, child) => {
11
- if (__webpack_module_cache__[child]) {
12
- res[child] = __webpack_module_cache__[child].exports;
13
- }
14
- return res;
15
- }, {});
16
- module.hot.accept(__hmr_children__, () => {
17
- __hmr_children__.forEach((child) => {
18
- const reexports = __webpack_require__(child);
19
- for (let key in reexports) {
20
- if (!__hmr_used_exports__[child]) { continue; }
21
- Object.defineProperty(__hmr_used_exports__[child], key, {
22
- configurable: true,
23
- enumerable: true,
24
- get: () => reexports[key]
25
- });
26
- }
27
- });
28
- });
29
- `;
30
- }
31
- return content.replace(/NEXT_HMR/g, "NEXT_HMR.bind(null, module)");
32
- }
3
+ const loader = function (c) {
4
+ return c.replace(/NEXT_HMR/g, "NEXT_HMR.bind(null, module)");
5
+ };
6
+ module.exports = loader;
7
+ exports.default = loader;
@@ -6,10 +6,10 @@ export declare class HotUpdatePlugin {
6
6
  private updateIndex;
7
7
  private files;
8
8
  constructor(projectDir: string, tempDir: string);
9
- private getModifiedFiles;
10
9
  private getContent;
11
10
  private updateFiles;
12
11
  initialize(): Promise<void>;
12
+ getModifiedFiles(): string[];
13
13
  getUpdateIndex(): number;
14
14
  getTotalUpdates(): number;
15
15
  goNext(): Promise<void>;
@@ -4,15 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HotUpdatePlugin = void 0;
7
- const promises_1 = __importDefault(require("node:fs/promises"));
8
7
  const node_path_1 = __importDefault(require("node:path"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const rimraf_1 = require("rimraf");
9
10
  async function loopFile(dir, callback) {
10
- const children = await promises_1.default.readdir(dir);
11
+ const children = await fs_extra_1.default.readdir(dir);
11
12
  await Promise.all(children.map(async (filename) => {
12
13
  const filePath = node_path_1.default.join(dir, filename);
13
- const stat = await promises_1.default.stat(filePath);
14
+ const stat = await fs_extra_1.default.stat(filePath);
14
15
  if (stat.isFile()) {
15
- const content = await promises_1.default.readFile(filePath);
16
+ const content = await fs_extra_1.default.readFile(filePath);
16
17
  callback(filePath, content.toString());
17
18
  }
18
19
  else if (stat.isDirectory()) {
@@ -29,9 +30,6 @@ class HotUpdatePlugin {
29
30
  this.updateIndex = 0;
30
31
  this.files = {};
31
32
  }
32
- getModifiedFiles() {
33
- return Object.keys(this.files);
34
- }
35
33
  getContent(filePath, index) {
36
34
  const contents = this.files[filePath] || [];
37
35
  let content = contents[index] === undefined ? contents.at(-1) || "" : contents[index];
@@ -51,11 +49,11 @@ class HotUpdatePlugin {
51
49
  const { content, command } = this.getContent(filePath, this.updateIndex);
52
50
  // match command
53
51
  if (command === "delete") {
54
- await promises_1.default.unlink(filePath);
52
+ await fs_extra_1.default.remove(filePath);
55
53
  return;
56
54
  }
57
55
  if (command === "force_write") {
58
- await promises_1.default.writeFile(filePath, content);
56
+ await fs_extra_1.default.writeFile(filePath, content);
59
57
  return;
60
58
  }
61
59
  // default
@@ -63,7 +61,7 @@ class HotUpdatePlugin {
63
61
  if (this.updateIndex !== 0 && content === oldContent) {
64
62
  return;
65
63
  }
66
- await promises_1.default.writeFile(filePath, content);
64
+ await fs_extra_1.default.writeFile(filePath, content);
67
65
  }));
68
66
  }
69
67
  async initialize() {
@@ -71,8 +69,8 @@ class HotUpdatePlugin {
71
69
  return;
72
70
  }
73
71
  this.initialized = true;
74
- await promises_1.default.rmdir(this.tempDir, { recursive: true });
75
- await promises_1.default.cp(this.projectDir, this.tempDir, { recursive: true });
72
+ (0, rimraf_1.rimrafSync)(this.tempDir);
73
+ fs_extra_1.default.copySync(this.projectDir, this.tempDir);
76
74
  await loopFile(this.tempDir, (filePath, content) => {
77
75
  const contents = content.split(/---+\r?\n/g);
78
76
  if (contents.length > 1) {
@@ -81,13 +79,16 @@ class HotUpdatePlugin {
81
79
  });
82
80
  await this.updateFiles();
83
81
  }
82
+ getModifiedFiles() {
83
+ return Object.keys(this.files);
84
+ }
84
85
  getUpdateIndex() {
85
86
  return this.updateIndex;
86
87
  }
87
88
  getTotalUpdates() {
88
89
  return Object.values(this.files).reduce((max, item) => {
89
90
  return Math.max(max, item.length);
90
- }, 0);
91
+ }, 1);
91
92
  }
92
93
  async goNext() {
93
94
  this.updateIndex++;
@@ -1,7 +1,8 @@
1
1
  export * from "./directory";
2
- export * from "./legacy/supportsImportFn";
2
+ export * from "./is";
3
3
  export * from "./parse-modules";
4
4
  export * from "./read-config-file";
5
+ export * from "./stringify-config";
5
6
  export * from "./update-snapshot";
6
7
  export * from "./util/checkStats";
7
8
  export * from "./win";
@@ -15,9 +15,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./directory"), exports);
18
- __exportStar(require("./legacy/supportsImportFn"), exports);
18
+ __exportStar(require("./is"), exports);
19
19
  __exportStar(require("./parse-modules"), exports);
20
20
  __exportStar(require("./read-config-file"), exports);
21
+ __exportStar(require("./stringify-config"), exports);
21
22
  __exportStar(require("./update-snapshot"), exports);
22
23
  __exportStar(require("./util/checkStats"), exports);
23
24
  __exportStar(require("./win"), exports);
@@ -0,0 +1,2 @@
1
+ export declare function isJavaScript(filePath: string): boolean;
2
+ export declare function isCss(filePath: string): boolean;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isJavaScript = isJavaScript;
7
+ exports.isCss = isCss;
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ function isJavaScript(filePath) {
10
+ const ext = node_path_1.default.extname(filePath).toLowerCase();
11
+ return ext === ".js" || ext === ".mjs";
12
+ }
13
+ function isCss(filePath) {
14
+ return node_path_1.default.extname(filePath).toLowerCase() === ".css";
15
+ }
@@ -0,0 +1,6 @@
1
+ export = LogTestPlugin;
2
+ declare class LogTestPlugin {
3
+ constructor(noTraced: any);
4
+ noTraced: any;
5
+ apply(compiler: any): void;
6
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ module.exports = class LogTestPlugin {
4
+ constructor(noTraced) {
5
+ this.noTraced = noTraced;
6
+ }
7
+ apply(compiler) {
8
+ const logSome = logger => {
9
+ logger.group("Group");
10
+ if (!this.noTraced) {
11
+ logger.error("Error");
12
+ logger.warn("Warning");
13
+ }
14
+ logger.info("Info");
15
+ logger.log("Log");
16
+ logger.debug("Debug");
17
+ logger.groupCollapsed("Collapsed group");
18
+ logger.log("Log inside collapsed group");
19
+ logger.group("Inner group");
20
+ logger.log("Inner inner message");
21
+ logger.groupEnd();
22
+ logger.groupEnd();
23
+ logger.log("Log");
24
+ logger.groupEnd();
25
+ logger.log("End");
26
+ };
27
+ logSome(compiler.getInfrastructureLogger("LogTestPlugin"));
28
+ compiler.hooks.compilation.tap("LogTestPlugin", compilation => {
29
+ const logger = compilation.getLogger("LogTestPlugin");
30
+ logSome(logger);
31
+ const otherLogger = compilation.getLogger("LogOtherTestPlugin");
32
+ otherLogger.debug("debug message only");
33
+ });
34
+ }
35
+ };
@@ -18,8 +18,6 @@ module.exports = async (something, context, unlinked) => {
18
18
  if (unlinked)
19
19
  return m;
20
20
  await m.link(() => { });
21
- if (m.instantiate)
22
- m.instantiate();
23
21
  await m.evaluate();
24
22
  return m;
25
23
  };
@@ -1,2 +1,2 @@
1
- declare function _exports(testDirectory: any, object: any, kind: any, filename: any, upperCaseKind: any, done: any): Promise<true | undefined>;
1
+ declare function _exports(testDirectory: any, object: any, kind: any, filename: any, upperCaseKind: any, options: any, done: any): Promise<true | undefined>;
2
2
  export = _exports;
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  "use strict";
3
- const fs = require("graceful-fs");
3
+ const fs = require("fs-extra");
4
4
  const path = require("node:path");
5
5
  const check = (expected, actual) => {
6
6
  if (expected instanceof RegExp) {
@@ -59,16 +59,13 @@ ${tooMuch.map(item => `${explain(item)}`).join("\n\n")}`);
59
59
  }
60
60
  return diff.join("\n\n");
61
61
  };
62
- module.exports = async function checkArrayExpectation(testDirectory, object, kind, filename, upperCaseKind, done) {
63
- const usePromise = typeof done === "function";
62
+ module.exports = async function checkArrayExpectation(testDirectory, object, kind, filename, upperCaseKind, options, done) {
64
63
  done = typeof done === "function" ? done : error => {
65
64
  throw error;
66
65
  };
67
66
  let array = object[`${kind}s`];
68
- if (Array.isArray(array)) {
69
- if (kind === "warning") {
70
- array = array.filter(item => !/from Terser/.test(item));
71
- }
67
+ if (Array.isArray(array) && kind === "warning") {
68
+ array = array.filter(item => !/from Terser/.test(item));
72
69
  }
73
70
  if (fs.existsSync(path.join(testDirectory, `${filename}.js`))) {
74
71
  // CHANGE: added file for sorting messages in multi-thread environment
@@ -77,7 +74,10 @@ module.exports = async function checkArrayExpectation(testDirectory, object, kin
77
74
  array = sorter(array);
78
75
  }
79
76
  const expectedFilename = path.join(testDirectory, `${filename}.js`);
80
- const expected = require(expectedFilename);
77
+ let expected = require(expectedFilename);
78
+ if (typeof expected === "function") {
79
+ expected = expected(options);
80
+ }
81
81
  const diff = diffItems(array, expected, kind);
82
82
  if (expected.length < array.length) {
83
83
  done(new Error(`More ${kind}s (${array.length} instead of ${expected.length}) while compiling than expected:\n\n${diff}\n\nCheck expected ${kind}s: ${expectedFilename}`));
@@ -1,11 +1,11 @@
1
1
  declare function _exports(env: any, { outputDirectory }: {
2
2
  outputDirectory: any;
3
3
  }): {
4
- new (url: any, options?: {}): {
4
+ new (resource: any, options?: {}): {
5
5
  url: any;
6
6
  worker: import("worker_threads").Worker;
7
7
  _onmessage: ((data: any) => void) | undefined;
8
- onmessage: any;
8
+ set onmessage(value: any);
9
9
  postMessage(data: any): void;
10
10
  terminate(): Promise<number>;
11
11
  };
@@ -1,28 +1,38 @@
1
- "use strict";
2
1
  // @ts-nocheck
3
- const path = require("node:path");
2
+ "use strict";
3
+ const path = require("path");
4
4
  module.exports = (env, { outputDirectory }) => class Worker {
5
- constructor(url, options = {}) {
6
- env.expect(url).toBeInstanceOf(URL);
7
- env.expect(url.origin).toBe("https://test.cases");
8
- env.expect(url.pathname.startsWith("/path/")).toBe(true);
9
- this.url = url;
10
- const file = url.pathname.slice(6);
5
+ constructor(resource, options = {}) {
6
+ const isFileURL = /^file:/i.test(resource);
7
+ const isBlobURL = /^blob:/i.test(resource);
8
+ if (!isFileURL && !isBlobURL) {
9
+ env.expect(resource.origin).toBe("https://test.cases");
10
+ env.expect(resource.pathname.startsWith("/path/")).toBe(true);
11
+ }
12
+ this.url = resource;
13
+ const file = isFileURL
14
+ ? resource
15
+ : path.resolve(outputDirectory, isBlobURL
16
+ ? options.originalURL.pathname.slice(6)
17
+ : resource.pathname.slice(6));
11
18
  const workerBootstrap = `
12
19
  const { parentPort } = require("worker_threads");
13
- const { URL } = require("url");
20
+ const { URL, fileURLToPath } = require("url");
14
21
  const path = require("path");
15
22
  const fs = require("fs");
16
23
  global.self = global;
17
24
  self.URL = URL;
18
- self.location = new URL(${JSON.stringify(url.toString())});
25
+ self.location = new URL(${JSON.stringify(isBlobURL
26
+ ? resource.toString().replace("nodedata:", "https://test.cases/path/")
27
+ : resource.toString())});
19
28
  const urlToPath = url => {
20
- if(url.startsWith("https://test.cases/path/")) url = url.slice(24);
29
+ if (/^file:/i.test(url)) return fileURLToPath(url);
30
+ if (url.startsWith("https://test.cases/path/")) url = url.slice(24);
21
31
  return path.resolve(${JSON.stringify(outputDirectory)}, \`./\${url}\`);
22
32
  };
23
33
  self.importScripts = url => {
24
34
  ${options.type === "module"
25
- ? `throw new Error("importScripts is not supported in module workers")`
35
+ ? 'throw new Error("importScripts is not supported in module workers")'
26
36
  : "require(urlToPath(url))"};
27
37
  };
28
38
  self.fetch = async url => {
@@ -33,8 +43,10 @@ self.fetch = async url => {
33
43
  )
34
44
  );
35
45
  return {
46
+ headers: { get(name) { } },
36
47
  status: 200,
37
48
  ok: true,
49
+ arrayBuffer() { return buffer; },
38
50
  json: async () => JSON.parse(buffer.toString("utf-8"))
39
51
  };
40
52
  } catch(err) {
@@ -47,25 +59,37 @@ self.fetch = async url => {
47
59
  throw err;
48
60
  }
49
61
  };
50
- parentPort.on("message", data => {
51
- if(self.onmessage) self.onmessage({
52
- data
53
- });
54
- });
62
+
55
63
  self.postMessage = data => {
56
64
  parentPort.postMessage(data);
57
65
  };
58
- require(${JSON.stringify(path.resolve(outputDirectory, file))});
66
+ if (${options.type === "module"}) {
67
+ import(${JSON.stringify(file)}).then(() => {
68
+ parentPort.on("message", data => {
69
+ if(self.onmessage) self.onmessage({
70
+ data
71
+ });
72
+ });
73
+ });
74
+ } else {
75
+ parentPort.on("message", data => {
76
+ if(self.onmessage) self.onmessage({
77
+ data
78
+ });
79
+ });
80
+ require(${JSON.stringify(file)});
81
+ }
59
82
  `;
60
- this.worker = new (require("node:worker_threads").Worker)(workerBootstrap, {
83
+ this.worker = new (require("worker_threads").Worker)(workerBootstrap, {
61
84
  eval: true
62
85
  });
63
86
  this._onmessage = undefined;
64
87
  }
88
+ // eslint-disable-next-line accessor-pairs
65
89
  set onmessage(value) {
66
90
  if (this._onmessage)
67
91
  this.worker.off("message", this._onmessage);
68
- this.worker.on("message", (this._onmessage = data => {
92
+ this.worker.on("message", (this._onmessage = (data) => {
69
93
  value({
70
94
  data
71
95
  });
@@ -4,7 +4,8 @@ declare function _exports(globalTimeout?: number, nameSuffix?: string): {
4
4
  it(...args: any[]): void;
5
5
  beforeEach(...args: any[]): void;
6
6
  afterEach(...args: any[]): void;
7
- expect: jest.Expect;
8
- jest: typeof jest;
7
+ /** @type {import('@rstest/core').Expect} */
8
+ expect: import("@rstest/core").Expect;
9
+ rstest: import("@rstest/core", { with: { "resolution-mode": "import" } }).RstestUtilities;
9
10
  };
10
11
  export = _exports;
@@ -39,11 +39,10 @@ module.exports = (globalTimeout = 2000, nameSuffix = "") => {
39
39
  it("should run the exported tests", () => {
40
40
  runTests++;
41
41
  });
42
- afterAll(done => {
42
+ afterAll(() => {
43
43
  for (const dispose of disposables) {
44
44
  dispose();
45
45
  }
46
- done();
47
46
  });
48
47
  currentDescribeBlock = state.currentDescribeBlock;
49
48
  currentlyRunningTest = state.currentlyRunningTest;
@@ -110,7 +109,8 @@ module.exports = (globalTimeout = 2000, nameSuffix = "") => {
110
109
  fixAsyncError(currentDescribeBlock.hooks[currentDescribeBlock.hooks.length - 1]);
111
110
  });
112
111
  },
112
+ /** @type {import('@rstest/core').Expect} */
113
113
  expect,
114
- jest
114
+ rstest,
115
115
  };
116
116
  };
@@ -0,0 +1 @@
1
+ export function start(handler: any): () => any[];
@@ -0,0 +1,41 @@
1
+ // @ts-nocheck
2
+ /*
3
+ MIT License http://www.opensource.org/licenses/mit-license.php
4
+ Author Tobias Koppers @sokra
5
+ */
6
+ "use strict";
7
+ const util = require("util");
8
+ let interception = undefined;
9
+ const originalDeprecate = util.deprecate;
10
+ util.deprecate = (fn, message, code) => {
11
+ const original = originalDeprecate(fn, message, code);
12
+ return function (...args) {
13
+ if (interception) {
14
+ interception.set(`${code}: ${message}`, {
15
+ code,
16
+ message,
17
+ stack: new Error(message).stack
18
+ });
19
+ return fn.apply(this, args);
20
+ }
21
+ else {
22
+ return original.apply(this, args);
23
+ }
24
+ };
25
+ };
26
+ exports.start = handler => {
27
+ interception = new Map();
28
+ return () => {
29
+ const map = interception;
30
+ interception = undefined;
31
+ return Array.from(map || [])
32
+ .sort(([a], [b]) => {
33
+ if (a < b)
34
+ return -1;
35
+ if (a > b)
36
+ return 1;
37
+ return 0;
38
+ })
39
+ .map(([key, data]) => data);
40
+ };
41
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @param {string} source value
3
+ * @param {string} str string for searching
4
+ */
5
+ export function expectSourceToContain(source: string, str: string): void;
6
+ /**
7
+ * @param {string} source value
8
+ * @param {RegExp} regexStr regexp
9
+ */
10
+ export function expectSourceToMatch(source: string, regexStr: RegExp): void;
@@ -0,0 +1,23 @@
1
+ // @ts-nocheck
2
+ "use strict";
3
+ const regexEscape = require("./regexEscape");
4
+ // These expect* methods are necessary because 'source' contains the code for this test file, which will always contain the string
5
+ // being tested for, so we have to use the "DO NOT MATCH BELOW..." technique to exclude the actual testing code from the test.
6
+ // Place your jest 'expect' calls below a line containing the DO NOT MATCH BELOW... string constructed below. See other tests for examples.
7
+ // Break up the match string so we don't match it in these expect* functions either.
8
+ const doNotMatch = ["DO", "NOT", "MATCH", "BELOW", "THIS", "LINE"].join(" ");
9
+ /**
10
+ * @param {string} source value
11
+ * @param {string} str string for searching
12
+ */
13
+ function expectSourceToContain(source, str) {
14
+ expect(source).toMatch(new RegExp(`${regexEscape(str)}.*${doNotMatch}`, "s"));
15
+ }
16
+ /**
17
+ * @param {string} source value
18
+ * @param {RegExp} regexStr regexp
19
+ */
20
+ function expectSourceToMatch(source, regexStr) {
21
+ expect(source).toMatch(new RegExp(`${regexStr}.*${doNotMatch}`, "s"));
22
+ }
23
+ module.exports = { expectSourceToContain, expectSourceToMatch };
@@ -0,0 +1,6 @@
1
+ declare function _exports(options: {
2
+ output: {
3
+ path: string;
4
+ };
5
+ }, regexp: RegExp, subpath?: string | undefined): string[];
6
+ export = _exports;
@@ -0,0 +1,14 @@
1
+ // @ts-nocheck
2
+ "use strict";
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ /**
6
+ * @param {{output: {path: string}}} options options
7
+ * @param {RegExp} regexp regexp
8
+ * @param {string=} subpath path in output directory
9
+ * @returns {string[]} files
10
+ */
11
+ module.exports = function findOutputFiles(options, regexp, subpath) {
12
+ const files = fs.readdirSync(subpath ? path.join(options.output.path, subpath) : options.output.path);
13
+ return files.filter(file => regexp.test(file));
14
+ };
@@ -0,0 +1,2 @@
1
+ declare function _exports(string: any): any;
2
+ export = _exports;
@@ -0,0 +1,5 @@
1
+ // @ts-nocheck
2
+ "use strict";
3
+ module.exports = function regexEscape(string) {
4
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
5
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ module.exports = function supportDefaultAssignment() {
4
+ try {
5
+ // eslint-disable-next-line no-unused-vars
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";
9
+ }
10
+ catch (e) {
11
+ return false;
12
+ }
13
+ };
@@ -0,0 +1,2 @@
1
+ declare function _exports(): boolean;
2
+ export = _exports;