@rspack-canary/test-tools 1.5.9-canary-bddc650e-20251012024608 → 1.5.9-canary-e259bc79-20251014173821
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/case/builtin.js +0 -22
- package/dist/case/common.js +5 -1
- package/dist/case/error.js +1 -1
- package/dist/case/hook.js +2 -2
- package/dist/case/hot-step.d.ts +1 -1
- package/dist/case/hot-step.js +12 -10
- package/dist/case/hot.d.ts +5 -4
- package/dist/case/hot.js +32 -41
- package/dist/case/incremental.d.ts +1 -1
- package/dist/case/incremental.js +8 -6
- package/dist/case/normal.js +1 -5
- package/dist/case/watch.js +0 -7
- package/dist/compare/compare.js +6 -3
- package/dist/helper/expect/placeholder.js +7 -7
- package/dist/helper/expect/to-match-file-snapshot.d.ts +0 -1
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +4 -4
- package/dist/helper/legacy/update.d.ts +2 -0
- package/dist/helper/legacy/update.esm.d.ts +1 -0
- package/dist/helper/legacy/update.esm.js +23 -0
- package/dist/helper/legacy/update.js +19 -0
- package/dist/helper/util/checkStats.d.ts +0 -1
- package/dist/helper/util/checkStats.js +0 -18
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/jest/ignore-snapshot-default-reporter.d.ts +2 -0
- package/dist/jest/ignore-snapshot-default-reporter.js +57 -0
- package/dist/jest/ignore-snapshot-summary-reporter.d.ts +2 -0
- package/dist/jest/ignore-snapshot-summary-reporter.js +24 -0
- package/dist/jest/patch-node-env.d.ts +5 -0
- package/dist/jest/patch-node-env.js +18 -0
- package/dist/jest/slash.d.ts +2 -0
- package/dist/jest/slash.js +16 -0
- package/dist/runner/node/index.js +4 -0
- package/dist/runner/web/fake.js +6 -3
- package/dist/runner/web/jsdom.js +0 -4
- package/dist/type.d.ts +8 -0
- package/package.json +8 -5
- package/dist/helper/legacy/createLogger.d.ts +0 -23
- package/dist/helper/legacy/createLogger.js +0 -20
- package/dist/helper/legacy/diffStats.d.ts +0 -2
- package/dist/helper/legacy/diffStats.js +0 -13
- package/dist/helper/legacy/supportsBlob.d.ts +0 -2
- package/dist/helper/legacy/supportsBlob.js +0 -10
- package/dist/helper/legacy/supportsClassFields.d.ts +0 -2
- package/dist/helper/legacy/supportsClassFields.js +0 -11
- package/dist/helper/legacy/supportsES6.d.ts +0 -2
- package/dist/helper/legacy/supportsES6.js +0 -11
- package/dist/helper/legacy/supportsForOf.d.ts +0 -2
- package/dist/helper/legacy/supportsForOf.js +0 -11
- package/dist/helper/legacy/supportsIteratorDestructuring.d.ts +0 -2
- package/dist/helper/legacy/supportsIteratorDestructuring.js +0 -11
- package/dist/helper/legacy/supportsLogicalAssignment.d.ts +0 -2
- package/dist/helper/legacy/supportsLogicalAssignment.js +0 -11
- package/dist/helper/legacy/supportsObjectDestructuring.d.ts +0 -2
- package/dist/helper/legacy/supportsObjectDestructuring.js +0 -11
- package/dist/helper/legacy/supportsOptionalCatchBinding.d.ts +0 -2
- package/dist/helper/legacy/supportsOptionalCatchBinding.js +0 -11
- package/dist/helper/legacy/supportsOptionalChaining.d.ts +0 -2
- package/dist/helper/legacy/supportsOptionalChaining.js +0 -11
- package/dist/helper/legacy/supportsRequireInModule.d.ts +0 -2
- package/dist/helper/legacy/supportsRequireInModule.js +0 -5
- package/dist/helper/legacy/supportsResponse.d.ts +0 -2
- package/dist/helper/legacy/supportsResponse.js +0 -10
- package/dist/helper/legacy/supportsSpread.d.ts +0 -2
- package/dist/helper/legacy/supportsSpread.js +0 -12
- package/dist/helper/legacy/supportsTemplateStrings.d.ts +0 -2
- package/dist/helper/legacy/supportsTemplateStrings.js +0 -11
- package/dist/helper/legacy/supportsWebAssembly.d.ts +0 -2
- package/dist/helper/legacy/supportsWebAssembly.js +0 -10
- package/dist/helper/legacy/supportsWorker.d.ts +0 -2
- package/dist/helper/legacy/supportsWorker.js +0 -17
- package/dist/helper/legacy/warmup-webpack.d.ts +0 -1
- package/dist/helper/legacy/warmup-webpack.js +0 -26
- package/dist/helper/loaders/hot-update.d.ts +0 -1
- package/dist/helper/loaders/hot-update.js +0 -43
- package/dist/helper/plugins/hot-update.d.ts +0 -7
- package/dist/helper/plugins/hot-update.js +0 -40
- package/dist/helper/plugins/index.d.ts +0 -1
- package/dist/helper/plugins/index.js +0 -17
- package/dist/helper/util/currentWatchStep.d.ts +0 -1
- package/dist/helper/util/currentWatchStep.js +0 -2
- package/dist/helper/util/identifier.d.ts +0 -76
- package/dist/helper/util/identifier.js +0 -339
- package/dist/helper/util/replaceMitteDiagnostic.d.ts +0 -2
- package/dist/helper/util/replaceMitteDiagnostic.js +0 -17
- package/dist/reporter/diff-html.d.ts +0 -15
- package/dist/reporter/diff-html.js +0 -69
- package/dist/reporter/diff-stats.d.ts +0 -24
- package/dist/reporter/diff-stats.js +0 -131
- package/dist/reporter/index.d.ts +0 -2
- package/dist/reporter/index.js +0 -18
|
@@ -1,43 +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
|
-
if (options.updateIndex >= items.length) {
|
|
40
|
-
return items[items.length - 1];
|
|
41
|
-
}
|
|
42
|
-
return items[options.updateIndex];
|
|
43
|
-
}
|
|
@@ -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,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,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,15 +0,0 @@
|
|
|
1
|
-
import type { ITestReporter, TModuleCompareResult } from "../type";
|
|
2
|
-
export interface IDiffHtmlReporterOptions {
|
|
3
|
-
dist: string;
|
|
4
|
-
ignore?: RegExp;
|
|
5
|
-
}
|
|
6
|
-
export declare class DiffHtmlReporter implements ITestReporter<TModuleCompareResult[]> {
|
|
7
|
-
private options;
|
|
8
|
-
private failed;
|
|
9
|
-
private results;
|
|
10
|
-
constructor(options: IDiffHtmlReporterOptions);
|
|
11
|
-
init(data?: TModuleCompareResult[]): Promise<void>;
|
|
12
|
-
failure(id: string): Promise<void>;
|
|
13
|
-
increment(id: string, data: TModuleCompareResult[]): Promise<void>;
|
|
14
|
-
output(): Promise<void>;
|
|
15
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
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.DiffHtmlReporter = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
-
const VIEWER_DIR = node_path_1.default.join(__dirname, "../../template");
|
|
10
|
-
const DIFF_STATS_PLACEHOLDER = "$$RSPACK_DIFF_STATS_PLACEHOLDER$$";
|
|
11
|
-
const DEFAULT_IGNORE = /node_modules/;
|
|
12
|
-
class DiffHtmlReporter {
|
|
13
|
-
constructor(options) {
|
|
14
|
-
this.options = options;
|
|
15
|
-
this.failed = new Set();
|
|
16
|
-
this.results = new Map();
|
|
17
|
-
}
|
|
18
|
-
async init(data = []) { }
|
|
19
|
-
async failure(id) {
|
|
20
|
-
this.failed.add(id);
|
|
21
|
-
this.results.delete(id);
|
|
22
|
-
}
|
|
23
|
-
async increment(id, data) {
|
|
24
|
-
if (this.failed.has(id))
|
|
25
|
-
return;
|
|
26
|
-
if (!this.results.has(id)) {
|
|
27
|
-
this.results.set(id, []);
|
|
28
|
-
}
|
|
29
|
-
const ignore = this.options.ignore || DEFAULT_IGNORE;
|
|
30
|
-
const current = this.results.get(id);
|
|
31
|
-
for (const i of data) {
|
|
32
|
-
if (!ignore.test(i.name)) {
|
|
33
|
-
current.push({
|
|
34
|
-
name: i.name,
|
|
35
|
-
source: i.source || "",
|
|
36
|
-
dist: i.dist || "",
|
|
37
|
-
type: i.type
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async output() {
|
|
43
|
-
fs_extra_1.default.ensureDirSync(this.options.dist);
|
|
44
|
-
for (const viewerFile of fs_extra_1.default
|
|
45
|
-
.readdirSync(VIEWER_DIR)
|
|
46
|
-
.filter(file => file.startsWith("diff"))) {
|
|
47
|
-
const sourceFile = node_path_1.default.join(VIEWER_DIR, viewerFile);
|
|
48
|
-
if (node_path_1.default.extname(viewerFile) === ".html") {
|
|
49
|
-
const template = fs_extra_1.default.readFileSync(sourceFile, "utf-8");
|
|
50
|
-
for (const [id, items] of this.results.entries()) {
|
|
51
|
-
const data = {
|
|
52
|
-
root: id,
|
|
53
|
-
data: items
|
|
54
|
-
};
|
|
55
|
-
const casename = node_path_1.default.basename(id);
|
|
56
|
-
const extname = node_path_1.default.extname(viewerFile);
|
|
57
|
-
const filename = node_path_1.default.basename(viewerFile, extname);
|
|
58
|
-
const content = template.replace(`<script id="${DIFF_STATS_PLACEHOLDER}"></script>`, `<script src="${filename}_${casename}.js"></script>`);
|
|
59
|
-
fs_extra_1.default.writeFileSync(node_path_1.default.join(this.options.dist, `${filename}_${casename}${extname}`), content, "utf-8");
|
|
60
|
-
fs_extra_1.default.writeFileSync(node_path_1.default.join(this.options.dist, `${filename}_${casename}.js`), `window.$$diff_detail$$ = ${JSON.stringify(data)}`, "utf-8");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
fs_extra_1.default.copyFileSync(sourceFile, node_path_1.default.join(this.options.dist, viewerFile));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.DiffHtmlReporter = DiffHtmlReporter;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ECompilerType, type ITestReporter, type TModuleCompareResult } from "../type";
|
|
2
|
-
export interface IDiffStatsReporterOptions {
|
|
3
|
-
header?: string[];
|
|
4
|
-
footer?: string[];
|
|
5
|
-
file: string;
|
|
6
|
-
report?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export type TCompilerTypeId = ECompilerType.Rspack | ECompilerType.Webpack | "common";
|
|
9
|
-
export type TModuleTypeId = "normal" | "runtime";
|
|
10
|
-
export type TDimenTypeId = "modules" | "lines" | "lines-in-common";
|
|
11
|
-
export type TCaseSummaryId = `${TCompilerTypeId}|${TModuleTypeId}|${TDimenTypeId}`;
|
|
12
|
-
export type TCaseSummary = Record<TCaseSummaryId, number>;
|
|
13
|
-
export declare class DiffStatsReporter implements ITestReporter<TModuleCompareResult[]> {
|
|
14
|
-
private options;
|
|
15
|
-
private summary;
|
|
16
|
-
private failed;
|
|
17
|
-
constructor(options: IDiffStatsReporterOptions);
|
|
18
|
-
init(data?: TModuleCompareResult[]): Promise<void>;
|
|
19
|
-
failure(id: string): Promise<void>;
|
|
20
|
-
increment(id: string, data: TModuleCompareResult[]): Promise<void>;
|
|
21
|
-
output(): Promise<void>;
|
|
22
|
-
private stringifySummary;
|
|
23
|
-
private createSummary;
|
|
24
|
-
}
|