@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 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- describe("warmup", () => {
4
- it("should warmup webpack", done => {
5
- let webpack = require("@rspack/core");
6
- const END = new Error("end warmup");
7
- webpack({
8
- entry: "data:text/javascript,import 'data:text/javascript,'",
9
- plugins: [
10
- c => c.hooks.emit.tap("Warmup", () => {
11
- throw END;
12
- })
13
- ]
14
- }, err => {
15
- webpack = undefined;
16
- try {
17
- // CHANGE: rspack will format error into diagnostic.
18
- expect(err.message).toContain("end warmup");
19
- done();
20
- }
21
- catch (e) {
22
- done(e);
23
- }
24
- });
25
- }, 300000);
26
- });
@@ -1 +0,0 @@
1
- export default function (this: any, c: string): string;
@@ -1,40 +0,0 @@
1
- "use strict";
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
- content = content.replace(/NEXT_HMR/g, "NEXT_HMR.bind(null, module)");
32
- const options = this.getOptions();
33
- const items = content.split(/---+\r?\n/g);
34
- if (items.length <= 1) {
35
- return content;
36
- }
37
- options.totalUpdates = Math.max(options.totalUpdates, items.length);
38
- options.changedFiles.push(this.resourcePath);
39
- return items[options.updateIndex];
40
- }
@@ -1,7 +0,0 @@
1
- import type { Compiler } from "@rspack/core";
2
- import type { TUpdateOptions } from "../../type";
3
- export declare class TestHotUpdatePlugin {
4
- private updateOptions;
5
- constructor(updateOptions: TUpdateOptions);
6
- apply(compiler: Compiler): void;
7
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestHotUpdatePlugin = void 0;
4
- class TestHotUpdatePlugin {
5
- constructor(updateOptions) {
6
- this.updateOptions = updateOptions;
7
- }
8
- apply(compiler) {
9
- let isRebuild = false;
10
- compiler.hooks.beforeRun.tap("TestHotUpdatePlugin", () => {
11
- if (isRebuild) {
12
- compiler.modifiedFiles = new Set(this.updateOptions.changedFiles);
13
- }
14
- else {
15
- compiler.modifiedFiles = new Set();
16
- }
17
- this.updateOptions.changedFiles = [];
18
- isRebuild = true;
19
- });
20
- compiler.hooks.compilation.tap("TestHotUpdatePlugin", compilation => {
21
- compilation.hooks.additionalTreeRuntimeRequirements.tap("HMR_TEST_PLUGIN", (_chunk, set) => {
22
- set.add(compiler.webpack.RuntimeGlobals.moduleCache);
23
- });
24
- compilation.hooks.runtimeModule.tap("HMR_TEST_PLUGIN", (module, _set) => {
25
- if (module.constructorName === "DefinePropertyGettersRuntimeModule") {
26
- module.source.source = Buffer.from(`
27
- __webpack_require__.d = function (exports, definition) {
28
- for (var key in definition) {
29
- if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
30
- Object.defineProperty(exports, key, { configurable: true, enumerable: true, get: definition[key] });
31
- }
32
- }
33
- };
34
- `, "utf-8");
35
- }
36
- });
37
- });
38
- }
39
- }
40
- exports.TestHotUpdatePlugin = TestHotUpdatePlugin;
@@ -1 +0,0 @@
1
- export * from "./hot-update";
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./hot-update"), exports);
@@ -1 +0,0 @@
1
- export const step: {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- exports.step = {};
@@ -1,76 +0,0 @@
1
- /**
2
- * @param {string} context context used to create relative path
3
- * @param {string} identifier identifier used to create relative path
4
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
5
- * @returns {string} the returned relative path
6
- */
7
- export function makePathsRelative(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
8
- export namespace makePathsRelative {
9
- /**
10
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
11
- * @returns {function(string, string): string} cached function
12
- */
13
- function bindCache(associatedObjectForCache?: Object | undefined): (arg0: string, arg1: string) => string;
14
- /**
15
- * @param {string} context context used to create relative path
16
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
17
- * @returns {function(string): string} cached function
18
- */
19
- function bindContextCache(context: string, associatedObjectForCache?: Object | undefined): (arg0: string) => string;
20
- }
21
- /**
22
- * @param {string} context context used to create relative path
23
- * @param {string} identifier identifier used to create relative path
24
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
25
- * @returns {string} the returned relative path
26
- */
27
- export function makePathsRelative(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
28
- export namespace makePathsRelative { }
29
- /**
30
- * @param {string} str the path with query and fragment
31
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
32
- * @returns {ParsedResource} parsed parts
33
- */
34
- export function parseResource(str: string, associatedObjectForCache?: Object | undefined): ParsedResource;
35
- export namespace parseResource {
36
- function bindCache(associatedObjectForCache: any): (str: any) => any;
37
- }
38
- /**
39
- * @param {string} str the path with query and fragment
40
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
41
- * @returns {ParsedResource} parsed parts
42
- */
43
- export function parseResource(str: string, associatedObjectForCache?: Object | undefined): ParsedResource;
44
- export namespace parseResource { }
45
- export function getUndoPath(filename: string, outputPath: string, enforceRelative: boolean): string;
46
- export type MakeRelativePathsCache = {
47
- relativePaths?: Map<string, Map<string, string>> | undefined;
48
- };
49
- export type ParsedResource = {
50
- resource: string;
51
- path: string;
52
- query: string;
53
- fragment: string;
54
- };
55
- export type ParsedResourceWithoutFragment = {
56
- resource: string;
57
- path: string;
58
- query: string;
59
- };
60
- /**
61
- * @param {string} context context used to create relative path
62
- * @param {string} identifier identifier used to create relative path
63
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
64
- * @returns {string} the returned relative path
65
- */
66
- declare function makePathsRelative(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
67
- declare namespace makePathsRelative { }
68
- /**
69
- * @param {string} context context used to create relative path
70
- * @param {string} identifier identifier used to create relative path
71
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
72
- * @returns {string} the returned relative path
73
- */
74
- declare function makePathsRelative(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
75
- declare namespace makePathsRelative { }
76
- export { contextify, absolutify };
@@ -1,339 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- /*
4
- * MIT License http://www.opensource.org/licenses/mit-license.php
5
- */
6
- const path = require("node:path");
7
- const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
8
- const SEGMENTS_SPLIT_REGEXP = /([|!])/;
9
- const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
10
- /**
11
- * @typedef {Object} MakeRelativePathsCache
12
- * @property {Map<string, Map<string, string>>=} relativePaths
13
- */
14
- const relativePathToRequest = relativePath => {
15
- if (relativePath === "")
16
- return "./.";
17
- if (relativePath === "..")
18
- return "../.";
19
- if (relativePath.startsWith("../"))
20
- return relativePath;
21
- return `./${relativePath}`;
22
- };
23
- /**
24
- * @param {string} context context for relative path
25
- * @param {string} maybeAbsolutePath path to make relative
26
- * @returns {string} relative path in request style
27
- */
28
- const absoluteToRequest = (context, maybeAbsolutePath) => {
29
- if (maybeAbsolutePath[0] === "/") {
30
- if (maybeAbsolutePath.length > 1 &&
31
- maybeAbsolutePath[maybeAbsolutePath.length - 1] === "/") {
32
- // this 'path' is actually a regexp generated by dynamic requires.
33
- // Don't treat it as an absolute path.
34
- return maybeAbsolutePath;
35
- }
36
- const querySplitPos = maybeAbsolutePath.indexOf("?");
37
- let resource = querySplitPos === -1
38
- ? maybeAbsolutePath
39
- : maybeAbsolutePath.slice(0, querySplitPos);
40
- resource = relativePathToRequest(path.posix.relative(context, resource));
41
- return querySplitPos === -1
42
- ? resource
43
- : resource + maybeAbsolutePath.slice(querySplitPos);
44
- }
45
- if (WINDOWS_ABS_PATH_REGEXP.test(maybeAbsolutePath)) {
46
- const querySplitPos = maybeAbsolutePath.indexOf("?");
47
- let resource = querySplitPos === -1
48
- ? maybeAbsolutePath
49
- : maybeAbsolutePath.slice(0, querySplitPos);
50
- resource = path.win32.relative(context, resource);
51
- if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) {
52
- resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/"));
53
- }
54
- return querySplitPos === -1
55
- ? resource
56
- : resource + maybeAbsolutePath.slice(querySplitPos);
57
- }
58
- // not an absolute path
59
- return maybeAbsolutePath;
60
- };
61
- /**
62
- * @param {string} context context for relative path
63
- * @param {string} relativePath path
64
- * @returns {string} absolute path
65
- */
66
- const requestToAbsolute = (context, relativePath) => {
67
- if (relativePath.startsWith("./") || relativePath.startsWith("../"))
68
- return path.join(context, relativePath);
69
- return relativePath;
70
- };
71
- const makeCacheable = realFn => {
72
- /** @type {WeakMap<object, Map<string, ParsedResource>>} */
73
- const cache = new WeakMap();
74
- const getCache = associatedObjectForCache => {
75
- const entry = cache.get(associatedObjectForCache);
76
- if (entry !== undefined)
77
- return entry;
78
- /** @type {Map<string, ParsedResource>} */
79
- const map = new Map();
80
- cache.set(associatedObjectForCache, map);
81
- return map;
82
- };
83
- /**
84
- * @param {string} str the path with query and fragment
85
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
86
- * @returns {ParsedResource} parsed parts
87
- */
88
- const fn = (str, associatedObjectForCache) => {
89
- if (!associatedObjectForCache)
90
- return realFn(str);
91
- const cache = getCache(associatedObjectForCache);
92
- const entry = cache.get(str);
93
- if (entry !== undefined)
94
- return entry;
95
- const result = realFn(str);
96
- cache.set(str, result);
97
- return result;
98
- };
99
- fn.bindCache = associatedObjectForCache => {
100
- const cache = getCache(associatedObjectForCache);
101
- return str => {
102
- const entry = cache.get(str);
103
- if (entry !== undefined)
104
- return entry;
105
- const result = realFn(str);
106
- cache.set(str, result);
107
- return result;
108
- };
109
- };
110
- return fn;
111
- };
112
- const makeCacheableWithContext = fn => {
113
- /** @type {WeakMap<object, Map<string, Map<string, string>>>} */
114
- const cache = new WeakMap();
115
- /**
116
- * @param {string} context context used to create relative path
117
- * @param {string} identifier identifier used to create relative path
118
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
119
- * @returns {string} the returned relative path
120
- */
121
- const cachedFn = (context, identifier, associatedObjectForCache) => {
122
- if (!associatedObjectForCache)
123
- return fn(context, identifier);
124
- let innerCache = cache.get(associatedObjectForCache);
125
- if (innerCache === undefined) {
126
- innerCache = new Map();
127
- cache.set(associatedObjectForCache, innerCache);
128
- }
129
- let cachedResult;
130
- let innerSubCache = innerCache.get(context);
131
- if (innerSubCache === undefined) {
132
- innerCache.set(context, (innerSubCache = new Map()));
133
- }
134
- else {
135
- cachedResult = innerSubCache.get(identifier);
136
- }
137
- if (cachedResult !== undefined) {
138
- return cachedResult;
139
- }
140
- const result = fn(context, identifier);
141
- innerSubCache.set(identifier, result);
142
- return result;
143
- };
144
- /**
145
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
146
- * @returns {function(string, string): string} cached function
147
- */
148
- cachedFn.bindCache = associatedObjectForCache => {
149
- let innerCache;
150
- if (associatedObjectForCache) {
151
- innerCache = cache.get(associatedObjectForCache);
152
- if (innerCache === undefined) {
153
- innerCache = new Map();
154
- cache.set(associatedObjectForCache, innerCache);
155
- }
156
- }
157
- else {
158
- innerCache = new Map();
159
- }
160
- /**
161
- * @param {string} context context used to create relative path
162
- * @param {string} identifier identifier used to create relative path
163
- * @returns {string} the returned relative path
164
- */
165
- const boundFn = (context, identifier) => {
166
- let cachedResult;
167
- let innerSubCache = innerCache.get(context);
168
- if (innerSubCache === undefined) {
169
- innerCache.set(context, (innerSubCache = new Map()));
170
- }
171
- else {
172
- cachedResult = innerSubCache.get(identifier);
173
- }
174
- if (cachedResult !== undefined) {
175
- return cachedResult;
176
- }
177
- const result = fn(context, identifier);
178
- innerSubCache.set(identifier, result);
179
- return result;
180
- };
181
- return boundFn;
182
- };
183
- /**
184
- * @param {string} context context used to create relative path
185
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
186
- * @returns {function(string): string} cached function
187
- */
188
- cachedFn.bindContextCache = (context, associatedObjectForCache) => {
189
- let innerSubCache;
190
- if (associatedObjectForCache) {
191
- let innerCache = cache.get(associatedObjectForCache);
192
- if (innerCache === undefined) {
193
- innerCache = new Map();
194
- cache.set(associatedObjectForCache, innerCache);
195
- }
196
- innerSubCache = innerCache.get(context);
197
- if (innerSubCache === undefined) {
198
- innerCache.set(context, (innerSubCache = new Map()));
199
- }
200
- }
201
- else {
202
- innerSubCache = new Map();
203
- }
204
- /**
205
- * @param {string} identifier identifier used to create relative path
206
- * @returns {string} the returned relative path
207
- */
208
- const boundFn = identifier => {
209
- const cachedResult = innerSubCache.get(identifier);
210
- if (cachedResult !== undefined) {
211
- return cachedResult;
212
- }
213
- const result = fn(context, identifier);
214
- innerSubCache.set(identifier, result);
215
- return result;
216
- };
217
- return boundFn;
218
- };
219
- return cachedFn;
220
- };
221
- /**
222
- *
223
- * @param {string} context context for relative path
224
- * @param {string} identifier identifier for path
225
- * @returns {string} a converted relative path
226
- */
227
- const _makePathsRelative = (context, identifier) => {
228
- return identifier
229
- .split(SEGMENTS_SPLIT_REGEXP)
230
- .map(str => absoluteToRequest(context, str))
231
- .join("");
232
- };
233
- exports.makePathsRelative = makeCacheableWithContext(_makePathsRelative);
234
- /**
235
- *
236
- * @param {string} context context for relative path
237
- * @param {string} identifier identifier for path
238
- * @returns {string} a converted relative path
239
- */
240
- const _makePathsAbsolute = (context, identifier) => {
241
- return identifier
242
- .split(SEGMENTS_SPLIT_REGEXP)
243
- .map(str => requestToAbsolute(context, str))
244
- .join("");
245
- };
246
- exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);
247
- /**
248
- * @param {string} context absolute context path
249
- * @param {string} request any request string may containing absolute paths, query string, etc.
250
- * @returns {string} a new request string avoiding absolute paths when possible
251
- */
252
- const _contextify = (context, request) => {
253
- return request
254
- .split("!")
255
- .map(r => absoluteToRequest(context, r))
256
- .join("!");
257
- };
258
- const contextify = makeCacheableWithContext(_contextify);
259
- exports.contextify = contextify;
260
- /**
261
- * @param {string} context absolute context path
262
- * @param {string} request any request string
263
- * @returns {string} a new request string using absolute paths when possible
264
- */
265
- const _absolutify = (context, request) => {
266
- return request
267
- .split("!")
268
- .map(r => requestToAbsolute(context, r))
269
- .join("!");
270
- };
271
- const absolutify = makeCacheableWithContext(_absolutify);
272
- exports.absolutify = absolutify;
273
- const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/;
274
- const PATH_QUERY_REGEXP = /^((?:\u200b.|[^?\u200b])*)(\?.*)?$/;
275
- /** @typedef {{ resource: string, path: string, query: string, fragment: string }} ParsedResource */
276
- /** @typedef {{ resource: string, path: string, query: string }} ParsedResourceWithoutFragment */
277
- /**
278
- * @param {string} str the path with query and fragment
279
- * @returns {ParsedResource} parsed parts
280
- */
281
- const _parseResource = str => {
282
- const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
283
- return {
284
- resource: str,
285
- path: match[1].replace(/\u200b(.)/g, "$1"),
286
- query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : "",
287
- fragment: match[3] || ""
288
- };
289
- };
290
- exports.parseResource = makeCacheable(_parseResource);
291
- /**
292
- * Parse resource, skips fragment part
293
- * @param {string} str the path with query and fragment
294
- * @returns {ParsedResourceWithoutFragment} parsed parts
295
- */
296
- const _parseResourceWithoutFragment = str => {
297
- const match = PATH_QUERY_REGEXP.exec(str);
298
- return {
299
- resource: str,
300
- path: match[1].replace(/\u200b(.)/g, "$1"),
301
- query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : ""
302
- };
303
- };
304
- exports.parseResourceWithoutFragment = makeCacheable(_parseResourceWithoutFragment);
305
- /**
306
- * @param {string} filename the filename which should be undone
307
- * @param {string} outputPath the output path that is restored (only relevant when filename contains "..")
308
- * @param {boolean} enforceRelative true returns ./ for empty paths
309
- * @returns {string} repeated ../ to leave the directory of the provided filename to be back on output dir
310
- */
311
- exports.getUndoPath = (filename, outputPath, enforceRelative) => {
312
- let depth = -1;
313
- let append = "";
314
- let path = outputPath.replace(/[\\/]$/, "");
315
- for (const part of filename.split(/[/\\]+/)) {
316
- if (part === "..") {
317
- if (depth > -1) {
318
- depth--;
319
- }
320
- else {
321
- const i = path.lastIndexOf("/");
322
- const j = path.lastIndexOf("\\");
323
- const pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
324
- if (pos < 0)
325
- return `${path}/`;
326
- append = `${path.slice(pos + 1)}/${append}`;
327
- path = path.slice(0, pos);
328
- }
329
- }
330
- else if (part !== ".") {
331
- depth++;
332
- }
333
- }
334
- return depth > 0
335
- ? `${"../".repeat(depth)}${append}`
336
- : enforceRelative
337
- ? `./${append}`
338
- : append;
339
- };
@@ -1,2 +0,0 @@
1
- export function replace(s: any): any;
2
- export function replaceStack(s: any): any;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- // Remove the "|" padding from miette,
4
- // used to ensure no line breaks with padding being returned,
5
- // miette generates diagnostics lines with respect to terminal size
6
- // and this might varies among different `process.cwd()` being used,
7
- // which breaks local and CI checks.
8
- const replace = s => s.replace(/\r?\n[ ]+│ /g, "");
9
- // HOW THIS WORKS:
10
- // 1. Remove potential line break and "|"
11
- // 2. Save the JS stack for each line
12
- // 3. If the current line was splitted because of terminal size, merge them together
13
- const replaceStack = s => s.replace(/(?:\s|│)*(at.*)(\s|│)*/g, "\n$1");
14
- module.exports = {
15
- replace,
16
- replaceStack
17
- };
@@ -1,7 +0,0 @@
1
- import type { Compiler, RspackOptionsNormalized, RspackPluginInstance } from "@rspack/core";
2
- export declare class RspackDiffConfigPlugin implements RspackPluginInstance {
3
- private modifier?;
4
- name: string;
5
- constructor(modifier?: ((options: RspackOptionsNormalized) => RspackOptionsNormalized) | undefined);
6
- apply(compiler: Compiler): void;
7
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RspackDiffConfigPlugin = void 0;
4
- const PLUGIN_NAME = "RspackDiffConfigPlugin";
5
- class RspackDiffConfigPlugin {
6
- constructor(modifier) {
7
- this.modifier = modifier;
8
- this.name = PLUGIN_NAME;
9
- process.env.RSPACK_DIFF = "true"; // enable rspack diff
10
- }
11
- apply(compiler) {
12
- const { options } = compiler;
13
- options.mode = "development";
14
- options.devtool = false;
15
- options.optimization ??= {};
16
- options.optimization.minimize = false;
17
- options.optimization.chunkIds = "named";
18
- options.optimization.moduleIds = "named";
19
- options.optimization.mangleExports ??= false;
20
- options.optimization.concatenateModules ??= false;
21
- options.output ??= {};
22
- options.output.pathinfo ??= false;
23
- options.output.environment ??= {};
24
- options.output.environment.arrowFunction ??= false;
25
- options.output.environment.bigIntLiteral ??= false;
26
- options.output.environment.const ??= false;
27
- options.output.environment.destructuring ??= false;
28
- options.output.environment.dynamicImport ??= false;
29
- options.output.environment.dynamicImportInWorker ??= false;
30
- options.output.environment.forOf ??= false;
31
- options.output.environment.globalThis ??= false;
32
- options.output.environment.module ??= false;
33
- options.output.environment.optionalChaining ??= false;
34
- options.output.environment.templateLiteral ??= false;
35
- options.experiments ??= {};
36
- options.experiments.rspackFuture ??= {};
37
- if (typeof this.modifier === "function") {
38
- this.modifier(compiler.options);
39
- }
40
- }
41
- }
42
- exports.RspackDiffConfigPlugin = RspackDiffConfigPlugin;
@@ -1,7 +0,0 @@
1
- import type { Compiler, WebpackOptionsNormalized } from "webpack";
2
- export declare class WebpackDiffConfigPlugin {
3
- private modifier?;
4
- name: string;
5
- constructor(modifier?: ((options: WebpackOptionsNormalized) => WebpackOptionsNormalized) | undefined);
6
- apply(compiler: Compiler): void;
7
- }