@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.
- package/README.md +1 -1
- package/dist/case/builtin.d.ts +3 -0
- package/dist/case/builtin.js +152 -14
- package/dist/case/cache.d.ts +2 -2
- package/dist/case/cache.js +214 -12
- package/dist/case/common.d.ts +11 -0
- package/dist/case/common.js +249 -0
- package/dist/case/compiler.d.ts +17 -4
- package/dist/case/compiler.js +149 -12
- package/dist/case/config.d.ts +7 -2
- package/dist/case/config.js +106 -18
- package/dist/case/defaults.d.ts +13 -4
- package/dist/case/defaults.js +73 -18
- package/dist/case/diagnostic.d.ts +6 -0
- package/dist/case/diagnostic.js +121 -14
- package/dist/case/error.d.ts +15 -4
- package/dist/case/error.js +137 -12
- package/dist/case/esm-output.d.ts +1 -0
- package/dist/case/esm-output.js +117 -0
- package/dist/case/example.d.ts +1 -0
- package/dist/case/example.js +57 -0
- package/dist/case/hash.d.ts +2 -2
- package/dist/case/hash.js +72 -9
- package/dist/case/hook.d.ts +36 -4
- package/dist/case/hook.js +209 -20
- package/dist/case/hot-step.d.ts +2 -2
- package/dist/case/hot-step.js +309 -13
- package/dist/case/hot.d.ts +11 -2
- package/dist/case/hot.js +217 -12
- package/dist/case/incremental.d.ts +2 -2
- package/dist/case/incremental.js +24 -45
- package/dist/case/index.d.ts +31 -20
- package/dist/case/index.js +50 -34
- package/dist/case/multi-compiler.d.ts +19 -0
- package/dist/case/multi-compiler.js +97 -0
- package/dist/case/{nativeWatcher.js → native-watcher.js} +11 -23
- package/dist/case/normal.d.ts +3 -0
- package/dist/case/normal.js +202 -18
- package/dist/case/runner.d.ts +19 -0
- package/dist/case/runner.js +113 -0
- package/dist/case/serial.d.ts +2 -2
- package/dist/case/serial.js +10 -14
- package/dist/case/stats-api.d.ts +8 -3
- package/dist/case/stats-api.js +69 -10
- package/dist/case/stats-output.d.ts +11 -0
- package/dist/case/stats-output.js +199 -8
- package/dist/case/treeshaking.js +34 -7
- package/dist/case/watch.d.ts +27 -0
- package/dist/case/watch.js +318 -22
- package/dist/compiler.d.ts +16 -16
- package/dist/compiler.js +120 -15
- package/dist/helper/directory.d.ts +1 -1
- package/dist/helper/directory.js +6 -2
- package/dist/helper/disable-iconv-lite-warning.d.ts +1 -0
- package/dist/helper/disable-iconv-lite-warning.js +12 -0
- package/dist/helper/expect/error.js +1 -1
- package/dist/helper/expect/placeholder.js +7 -7
- package/dist/helper/expect/to-match-file-snapshot.d.ts +1 -2
- package/dist/helper/expect/to-match-file-snapshot.js +3 -3
- package/dist/helper/hot-update/loader.d.ts +2 -1
- package/dist/helper/hot-update/loader.js +5 -30
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +14 -13
- package/dist/helper/index.d.ts +2 -1
- package/dist/helper/index.js +2 -1
- package/dist/helper/is.d.ts +2 -0
- package/dist/helper/is.js +15 -0
- package/dist/helper/legacy/LogTestPlugin.d.ts +6 -0
- package/dist/helper/legacy/LogTestPlugin.js +35 -0
- package/dist/helper/legacy/asModule.js +0 -2
- package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -1
- package/dist/helper/legacy/checkArrayExpectation.js +8 -8
- package/dist/helper/legacy/createFakeWorker.d.ts +2 -2
- package/dist/helper/legacy/createFakeWorker.js +44 -20
- package/dist/helper/legacy/createLazyTestEnv.d.ts +3 -2
- package/dist/helper/legacy/createLazyTestEnv.js +3 -3
- package/dist/helper/legacy/deprecationTracking.d.ts +1 -0
- package/dist/helper/legacy/deprecationTracking.js +41 -0
- package/dist/helper/legacy/expectSource.d.ts +10 -0
- package/dist/helper/legacy/expectSource.js +23 -0
- package/dist/helper/legacy/findOutputFiles.d.ts +6 -0
- package/dist/helper/legacy/findOutputFiles.js +14 -0
- package/dist/helper/legacy/regexEscape.d.ts +2 -0
- package/dist/helper/legacy/regexEscape.js +5 -0
- package/dist/helper/legacy/supportDefaultAssignment.js +13 -0
- package/dist/helper/legacy/supportsTextDecoder.d.ts +2 -0
- package/dist/helper/legacy/supportsTextDecoder.js +9 -0
- package/dist/helper/legacy/supportsUsing.d.ts +2 -0
- package/dist/helper/legacy/supportsUsing.js +26 -0
- package/dist/helper/legacy/urlToRelativePath.js +5 -2
- package/dist/helper/read-config-file.d.ts +3 -2
- package/dist/helper/read-config-file.js +12 -2
- package/dist/helper/setup-env.js +26 -4
- package/dist/helper/setup-expect.js +2 -2
- package/dist/helper/setup-wasm.js +2 -2
- package/dist/helper/stringify-config.d.ts +2 -0
- package/dist/helper/stringify-config.js +43 -0
- package/dist/helper/util/checkStats.d.ts +0 -1
- package/dist/helper/util/checkStats.js +0 -18
- package/dist/helper/util/expectWarningFactory.js +2 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.js +1 -4
- package/dist/plugin/index.d.ts +0 -3
- package/dist/plugin/index.js +0 -3
- package/dist/plugin/lazy-compilation-test-plugin.js +4 -4
- package/dist/runner/index.d.ts +2 -9
- package/dist/runner/index.js +2 -9
- package/dist/runner/node/index.d.ts +41 -0
- package/dist/runner/node/index.js +450 -0
- package/dist/runner/web/index.d.ts +30 -0
- package/dist/runner/web/index.js +343 -0
- package/dist/test/context.d.ts +15 -18
- package/dist/test/context.js +52 -57
- package/dist/test/creator.d.ts +20 -19
- package/dist/test/creator.js +69 -57
- package/dist/test/debug.d.ts +15 -0
- package/dist/test/debug.js +205 -0
- package/dist/test/tester.d.ts +1 -0
- package/dist/test/tester.js +44 -6
- package/dist/type.d.ts +94 -64
- package/dist/type.js +8 -12
- package/package.json +22 -61
- package/rstest.d.ts +24 -0
- package/dist/case/diff.d.ts +0 -3
- package/dist/case/diff.js +0 -126
- package/dist/compare/comparator.d.ts +0 -17
- package/dist/compare/comparator.js +0 -52
- package/dist/compare/compare.d.ts +0 -17
- package/dist/compare/compare.js +0 -175
- package/dist/compare/format-code.d.ts +0 -16
- package/dist/compare/format-code.js +0 -239
- package/dist/compare/index.d.ts +0 -5
- package/dist/compare/index.js +0 -21
- package/dist/compare/replace-module-argument.d.ts +0 -1
- package/dist/compare/replace-module-argument.js +0 -8
- package/dist/compare/replace-runtime-module-name.d.ts +0 -1
- package/dist/compare/replace-runtime-module-name.js +0 -71
- package/dist/helper/legacy/FakeDocument.d.ts +0 -54
- package/dist/helper/legacy/FakeDocument.js +0 -278
- package/dist/helper/legacy/createLogger.d.ts +0 -23
- package/dist/helper/legacy/createLogger.js +0 -20
- package/dist/helper/legacy/supportsImportFn.d.ts +0 -1
- package/dist/helper/legacy/supportsImportFn.js +0 -15
- package/dist/helper/legacy/supportsWorker.js +0 -17
- package/dist/helper/legacy/walkCssTokens.d.ts +0 -40
- package/dist/helper/legacy/walkCssTokens.js +0 -761
- 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 -40
- 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/plugin/rspack-diff-config-plugin.d.ts +0 -7
- package/dist/plugin/rspack-diff-config-plugin.js +0 -42
- package/dist/plugin/webpack-diff-config-plugin.d.ts +0 -7
- package/dist/plugin/webpack-diff-config-plugin.js +0 -41
- package/dist/plugin/webpack-module-placeholder-plugin.d.ts +0 -3
- package/dist/plugin/webpack-module-placeholder-plugin.js +0 -106
- package/dist/processor/basic.d.ts +0 -24
- package/dist/processor/basic.js +0 -146
- package/dist/processor/builtin.d.ts +0 -9
- package/dist/processor/builtin.js +0 -171
- package/dist/processor/cache.d.ts +0 -20
- package/dist/processor/cache.js +0 -128
- package/dist/processor/config.d.ts +0 -11
- package/dist/processor/config.js +0 -81
- package/dist/processor/defaults.d.ts +0 -30
- package/dist/processor/defaults.js +0 -72
- package/dist/processor/diagnostic.d.ts +0 -15
- package/dist/processor/diagnostic.js +0 -102
- package/dist/processor/diff.d.ts +0 -30
- package/dist/processor/diff.js +0 -140
- package/dist/processor/error.d.ts +0 -23
- package/dist/processor/error.js +0 -95
- package/dist/processor/hash.d.ts +0 -10
- package/dist/processor/hash.js +0 -63
- package/dist/processor/hook.d.ts +0 -44
- package/dist/processor/hook.js +0 -204
- package/dist/processor/hot-incremental.d.ts +0 -14
- package/dist/processor/hot-incremental.js +0 -43
- package/dist/processor/hot-step.d.ts +0 -18
- package/dist/processor/hot-step.js +0 -304
- package/dist/processor/hot.d.ts +0 -17
- package/dist/processor/hot.js +0 -140
- package/dist/processor/index.d.ts +0 -20
- package/dist/processor/index.js +0 -36
- package/dist/processor/multi.d.ts +0 -17
- package/dist/processor/multi.js +0 -73
- package/dist/processor/normal.d.ts +0 -12
- package/dist/processor/normal.js +0 -150
- package/dist/processor/simple.d.ts +0 -23
- package/dist/processor/simple.js +0 -49
- package/dist/processor/snapshot.d.ts +0 -12
- package/dist/processor/snapshot.js +0 -66
- package/dist/processor/stats-api.d.ts +0 -18
- package/dist/processor/stats-api.js +0 -48
- package/dist/processor/stats.d.ts +0 -18
- package/dist/processor/stats.js +0 -206
- package/dist/processor/treeshaking.d.ts +0 -10
- package/dist/processor/treeshaking.js +0 -33
- package/dist/processor/watch.d.ts +0 -30
- package/dist/processor/watch.js +0 -241
- 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
- package/dist/runner/basic.d.ts +0 -10
- package/dist/runner/basic.js +0 -63
- package/dist/runner/cache.d.ts +0 -5
- package/dist/runner/cache.js +0 -90
- package/dist/runner/hot-step.d.ts +0 -5
- package/dist/runner/hot-step.js +0 -87
- package/dist/runner/hot.d.ts +0 -5
- package/dist/runner/hot.js +0 -83
- package/dist/runner/multiple.d.ts +0 -11
- package/dist/runner/multiple.js +0 -38
- package/dist/runner/normal.d.ts +0 -5
- package/dist/runner/normal.js +0 -20
- package/dist/runner/runner/basic.d.ts +0 -30
- package/dist/runner/runner/basic.js +0 -107
- package/dist/runner/runner/cjs.d.ts +0 -14
- package/dist/runner/runner/cjs.js +0 -151
- package/dist/runner/runner/esm.d.ts +0 -7
- package/dist/runner/runner/esm.js +0 -125
- package/dist/runner/runner/index.d.ts +0 -8
- package/dist/runner/runner/index.js +0 -24
- package/dist/runner/runner/normal.d.ts +0 -9
- package/dist/runner/runner/normal.js +0 -23
- package/dist/runner/runner/watch.d.ts +0 -16
- package/dist/runner/runner/watch.js +0 -27
- package/dist/runner/runner/web/fake.d.ts +0 -18
- package/dist/runner/runner/web/fake.js +0 -143
- package/dist/runner/runner/web/jsdom.d.ts +0 -26
- package/dist/runner/runner/web/jsdom.js +0 -219
- package/dist/runner/runner/web.d.ts +0 -15
- package/dist/runner/runner/web.js +0 -32
- package/dist/runner/type.d.ts +0 -42
- package/dist/runner/type.js +0 -9
- package/dist/runner/watch.d.ts +0 -7
- package/dist/runner/watch.js +0 -60
- package/dist/test/simple.d.ts +0 -5
- package/dist/test/simple.js +0 -43
- package/jest.d.ts +0 -25
- package/template/diff.bundle.css +0 -1
- package/template/diff.bundle.js +0 -144
- package/template/diff.html +0 -14
- package/template/editor.worker.js +0 -1
- /package/dist/case/{nativeWatcher.d.ts → native-watcher.d.ts} +0 -0
- /package/dist/helper/legacy/{supportsWorker.d.ts → supportDefaultAssignment.d.ts} +0 -0
package/dist/type.d.ts
CHANGED
|
@@ -1,42 +1,30 @@
|
|
|
1
1
|
import type EventEmitter from "node:events";
|
|
2
|
-
import type { Compiler
|
|
3
|
-
import type { Compiler as WebpackCompiler, MultiStats as WebpackMultiStats, Configuration as WebpackOptions, Stats as WebpackStats, StatsCompilation as WebpackStatsCompilation } from "webpack";
|
|
4
|
-
import type { IBasicModuleScope, TRunnerRequirer } from "./runner/type";
|
|
2
|
+
import type { Compiler, MultiStats, RspackOptions, Stats, StatsCompilation } from "@rspack/core";
|
|
5
3
|
export interface ITestContext {
|
|
6
4
|
getSource(sub?: string): string;
|
|
7
5
|
getDist(sub?: string): string;
|
|
8
6
|
getTemp(sub?: string): string | null;
|
|
9
|
-
getCompiler
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
getRunner(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
getError(name?: string): Error[];
|
|
20
|
-
clearError(name?: string): void;
|
|
7
|
+
getCompiler(): ITestCompilerManager;
|
|
8
|
+
closeCompiler(): Promise<void>;
|
|
9
|
+
getTestConfig(): TTestConfig;
|
|
10
|
+
getRunner(file: string, env: ITestEnv): ITestRunner;
|
|
11
|
+
setValue<T>(key: string, value: T): void;
|
|
12
|
+
getValue<T>(key: string): T | void;
|
|
13
|
+
hasError(): boolean;
|
|
14
|
+
emitError(err: Error | string): void;
|
|
15
|
+
getError(): Error[];
|
|
16
|
+
clearError(): void;
|
|
21
17
|
}
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export type TCompilerStatsCompilation<T> = T extends ECompilerType.Rspack ? RspackStatsCompilation : WebpackStatsCompilation;
|
|
31
|
-
export interface ITestCompilerManager<T extends ECompilerType> {
|
|
32
|
-
getOptions(): TCompilerOptions<T>;
|
|
33
|
-
setOptions(newOptions: TCompilerOptions<T>): TCompilerOptions<T>;
|
|
34
|
-
mergeOptions(newOptions: TCompilerOptions<T>): TCompilerOptions<T>;
|
|
35
|
-
getCompiler(): TCompiler<T> | null;
|
|
36
|
-
createCompiler(): TCompiler<T>;
|
|
37
|
-
build(): Promise<TCompilerStats<T>>;
|
|
18
|
+
export interface ITestCompilerManager {
|
|
19
|
+
getOptions(): RspackOptions;
|
|
20
|
+
setOptions(newOptions: RspackOptions): RspackOptions;
|
|
21
|
+
mergeOptions(newOptions: RspackOptions): RspackOptions;
|
|
22
|
+
getCompiler(): Compiler | null;
|
|
23
|
+
createCompiler(): Compiler;
|
|
24
|
+
createCompilerWithCallback(callback: (error: Error | null, stats: Stats | null) => void): Compiler;
|
|
25
|
+
build(): Promise<Stats>;
|
|
38
26
|
watch(timeout?: number): void;
|
|
39
|
-
getStats():
|
|
27
|
+
getStats(): Stats | MultiStats | null;
|
|
40
28
|
getEmitter(): EventEmitter;
|
|
41
29
|
close(): Promise<void>;
|
|
42
30
|
}
|
|
@@ -50,10 +38,10 @@ export interface ITesterConfig {
|
|
|
50
38
|
dist: string;
|
|
51
39
|
temp?: string;
|
|
52
40
|
steps?: ITestProcessor[];
|
|
53
|
-
testConfig?: TTestConfig
|
|
54
|
-
compilerFactories?: TCompilerFactories;
|
|
41
|
+
testConfig?: TTestConfig;
|
|
55
42
|
contextValue?: Record<string, unknown>;
|
|
56
|
-
|
|
43
|
+
runnerCreator?: TTestRunnerCreator;
|
|
44
|
+
createContext?: (config: ITesterConfig) => ITestContext;
|
|
57
45
|
}
|
|
58
46
|
export interface ITester {
|
|
59
47
|
step: number;
|
|
@@ -62,6 +50,7 @@ export interface ITester {
|
|
|
62
50
|
prepare(): Promise<void>;
|
|
63
51
|
compile(): Promise<void>;
|
|
64
52
|
check(env: ITestEnv): Promise<void>;
|
|
53
|
+
after(): Promise<void>;
|
|
65
54
|
next(): boolean;
|
|
66
55
|
resume(): Promise<void>;
|
|
67
56
|
}
|
|
@@ -70,15 +59,15 @@ export interface ITestProcessor {
|
|
|
70
59
|
afterAll?(context: ITestContext): Promise<void>;
|
|
71
60
|
before?(context: ITestContext): Promise<void>;
|
|
72
61
|
after?(context: ITestContext): Promise<void>;
|
|
73
|
-
config
|
|
74
|
-
compiler
|
|
75
|
-
build
|
|
76
|
-
run
|
|
77
|
-
check
|
|
62
|
+
config(context: ITestContext): Promise<void>;
|
|
63
|
+
compiler(context: ITestContext): Promise<void>;
|
|
64
|
+
build(context: ITestContext): Promise<void>;
|
|
65
|
+
run(env: ITestEnv, context: ITestContext): Promise<void>;
|
|
66
|
+
check(env: ITestEnv, context: ITestContext): Promise<unknown>;
|
|
78
67
|
}
|
|
79
|
-
export interface ITestReporter
|
|
80
|
-
init(data?: T): Promise<void>;
|
|
81
|
-
increment(id: string, data: T): Promise<void>;
|
|
68
|
+
export interface ITestReporter {
|
|
69
|
+
init<T>(data?: T): Promise<void>;
|
|
70
|
+
increment<T>(id: string, data: T): Promise<void>;
|
|
82
71
|
failure(id: string): Promise<void>;
|
|
83
72
|
output(): Promise<void>;
|
|
84
73
|
}
|
|
@@ -119,30 +108,26 @@ export type TDiffStatsItem = {
|
|
|
119
108
|
};
|
|
120
109
|
export type TDiffStats = {
|
|
121
110
|
root: string;
|
|
122
|
-
data:
|
|
111
|
+
data: TDiffStatsItem[];
|
|
123
112
|
};
|
|
124
113
|
export interface ITestEnv {
|
|
125
|
-
expect:
|
|
114
|
+
expect: Expect;
|
|
126
115
|
it: (...args: any[]) => void;
|
|
127
116
|
beforeEach: (...args: any[]) => void;
|
|
128
117
|
afterEach: (...args: any[]) => void;
|
|
129
118
|
[key: string]: unknown;
|
|
130
119
|
}
|
|
131
|
-
export
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
export type TTestConfig<T extends ECompilerType> = {
|
|
136
|
-
documentType?: EDocumentType;
|
|
137
|
-
validate?: (stats: TCompilerStats<T> | TCompilerMultiStats<T>, stderr?: string) => void;
|
|
138
|
-
noTest?: boolean;
|
|
120
|
+
export type TTestConfig = {
|
|
121
|
+
location?: string;
|
|
122
|
+
validate?: (stats: Stats | MultiStats, stderr?: string) => void;
|
|
123
|
+
noTests?: boolean;
|
|
139
124
|
writeStatsOuptut?: boolean;
|
|
140
125
|
writeStatsJson?: boolean;
|
|
141
|
-
beforeExecute?: () => void;
|
|
142
|
-
afterExecute?: () => void;
|
|
143
|
-
moduleScope?: (ms:
|
|
144
|
-
checkStats?: (stepName: string, jsonStats:
|
|
145
|
-
findBundle?: (index: number, options:
|
|
126
|
+
beforeExecute?: (options: RspackOptions) => void;
|
|
127
|
+
afterExecute?: (options: RspackOptions) => void;
|
|
128
|
+
moduleScope?: (ms: IModuleScope, stats?: StatsCompilation, options?: RspackOptions) => IModuleScope;
|
|
129
|
+
checkStats?: (stepName: string, jsonStats: StatsCompilation | undefined, stringStats: String) => boolean;
|
|
130
|
+
findBundle?: (index: number, options: RspackOptions, stepName?: string) => string | string[];
|
|
146
131
|
bundlePath?: string[];
|
|
147
132
|
nonEsmThis?: (p: string | string[]) => Object;
|
|
148
133
|
modules?: Record<string, Object>;
|
|
@@ -150,20 +135,65 @@ export type TTestConfig<T extends ECompilerType> = {
|
|
|
150
135
|
concurrent?: boolean;
|
|
151
136
|
snapshotContent?(content: string): string;
|
|
152
137
|
checkSteps?: boolean;
|
|
138
|
+
ignoreNotFriendlyForIncrementalWarnings?: boolean;
|
|
139
|
+
esmLibPluginOptions?: {
|
|
140
|
+
preserveModules?: string;
|
|
141
|
+
};
|
|
142
|
+
resourceLoader?: (url: string, element: HTMLScriptElement) => Buffer | null;
|
|
153
143
|
};
|
|
154
|
-
export type TTestFilter
|
|
144
|
+
export type TTestFilter = (creatorConfig: Record<string, unknown>, testConfig: TTestConfig) => boolean | string;
|
|
155
145
|
export interface ITestRunner {
|
|
156
146
|
run(file: string): Promise<unknown>;
|
|
157
147
|
getRequire(): TRunnerRequirer;
|
|
158
148
|
getGlobal(name: string): unknown;
|
|
159
149
|
}
|
|
160
|
-
export type TCompilerFactory
|
|
161
|
-
export interface TRunnerFactory
|
|
162
|
-
create(file: string, compilerOptions:
|
|
150
|
+
export type TCompilerFactory = (options: RspackOptions | RspackOptions[], callback?: (error: Error | null, stats: Stats | null) => void) => Compiler;
|
|
151
|
+
export interface TRunnerFactory {
|
|
152
|
+
create(file: string, compilerOptions: RspackOptions, env: ITestEnv): ITestRunner;
|
|
163
153
|
}
|
|
164
|
-
export type
|
|
154
|
+
export type THotUpdateContext = {
|
|
165
155
|
updateIndex: number;
|
|
166
156
|
totalUpdates: number;
|
|
167
157
|
changedFiles: string[];
|
|
168
158
|
};
|
|
169
|
-
export type
|
|
159
|
+
export type TRunnerRequirer = (currentDirectory: string, modulePath: string[] | string, context?: {
|
|
160
|
+
file?: TRunnerFile;
|
|
161
|
+
esmMode?: EEsmMode;
|
|
162
|
+
}) => Object | Promise<Object>;
|
|
163
|
+
export type TRunnerFile = {
|
|
164
|
+
path: string;
|
|
165
|
+
content: string;
|
|
166
|
+
subPath: string;
|
|
167
|
+
};
|
|
168
|
+
export declare enum EEsmMode {
|
|
169
|
+
Unknown = 0,
|
|
170
|
+
Evaluated = 1,
|
|
171
|
+
Unlinked = 2
|
|
172
|
+
}
|
|
173
|
+
export interface IModuleScope extends ITestEnv {
|
|
174
|
+
console: Record<string, (...args: any[]) => void>;
|
|
175
|
+
expect: Expect;
|
|
176
|
+
[key: string]: any;
|
|
177
|
+
}
|
|
178
|
+
export interface IGlobalContext {
|
|
179
|
+
console: Record<string, (...args: any[]) => void>;
|
|
180
|
+
setTimeout: typeof setTimeout;
|
|
181
|
+
clearTimeout: typeof clearTimeout;
|
|
182
|
+
[key: string]: any;
|
|
183
|
+
}
|
|
184
|
+
export type TModuleObject = {
|
|
185
|
+
exports: unknown;
|
|
186
|
+
};
|
|
187
|
+
export type TTestRunnerCreator = {
|
|
188
|
+
key: (context: ITestContext, name: string, file: string) => string;
|
|
189
|
+
runner: (context: ITestContext, name: string, file: string, env: ITestEnv) => ITestRunner;
|
|
190
|
+
};
|
|
191
|
+
declare global {
|
|
192
|
+
var __DEBUG__: boolean;
|
|
193
|
+
var __TEST_PATH__: string;
|
|
194
|
+
var __TEST_FIXTURES_PATH__: string;
|
|
195
|
+
var __TEST_DIST_PATH__: string;
|
|
196
|
+
var __ROOT_PATH__: string;
|
|
197
|
+
var __RSPACK_PATH__: string;
|
|
198
|
+
var __RSPACK_TEST_TOOLS_PATH__: string;
|
|
199
|
+
}
|
package/dist/type.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/// <reference types="../
|
|
2
|
+
/// <reference types="../rstest.d.ts" />
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
5
|
-
var ECompilerType;
|
|
6
|
-
(function (ECompilerType) {
|
|
7
|
-
ECompilerType["Rspack"] = "rspack";
|
|
8
|
-
ECompilerType["Webpack"] = "webpack";
|
|
9
|
-
})(ECompilerType || (exports.ECompilerType = ECompilerType = {}));
|
|
4
|
+
exports.EEsmMode = exports.ECompareResultType = void 0;
|
|
10
5
|
var ECompareResultType;
|
|
11
6
|
(function (ECompareResultType) {
|
|
12
7
|
ECompareResultType["Same"] = "same";
|
|
@@ -15,8 +10,9 @@ var ECompareResultType;
|
|
|
15
10
|
ECompareResultType["OnlySource"] = "only-source";
|
|
16
11
|
ECompareResultType["Different"] = "different";
|
|
17
12
|
})(ECompareResultType || (exports.ECompareResultType = ECompareResultType = {}));
|
|
18
|
-
var
|
|
19
|
-
(function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
var EEsmMode;
|
|
14
|
+
(function (EEsmMode) {
|
|
15
|
+
EEsmMode[EEsmMode["Unknown"] = 0] = "Unknown";
|
|
16
|
+
EEsmMode[EEsmMode["Evaluated"] = 1] = "Evaluated";
|
|
17
|
+
EEsmMode[EEsmMode["Unlinked"] = 2] = "Unlinked";
|
|
18
|
+
})(EEsmMode || (exports.EEsmMode = EEsmMode = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack-debug/test-tools",
|
|
3
|
-
"version": "1.4
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,13 +12,16 @@
|
|
|
12
12
|
"./setup-expect": "./dist/helper/setup-expect.js",
|
|
13
13
|
"./setup-env": "./dist/helper/setup-env.js",
|
|
14
14
|
"./setup-wasm": "./dist/helper/setup-wasm.js",
|
|
15
|
-
"./package.json": "./package.json"
|
|
15
|
+
"./package.json": "./package.json",
|
|
16
|
+
"./helper/*": "./dist/helper/*.js",
|
|
17
|
+
"./helper/legacy/*": "./dist/helper/legacy/*.js",
|
|
18
|
+
"./helper/util/*": "./dist/helper/util/*.js"
|
|
16
19
|
},
|
|
17
20
|
"files": [
|
|
18
21
|
"client",
|
|
19
22
|
"dist",
|
|
20
23
|
"template",
|
|
21
|
-
"
|
|
24
|
+
"rstest.d.ts"
|
|
22
25
|
],
|
|
23
26
|
"publishConfig": {
|
|
24
27
|
"access": "public",
|
|
@@ -32,74 +35,37 @@
|
|
|
32
35
|
"directory": "packages/rspack-test-tools"
|
|
33
36
|
},
|
|
34
37
|
"dependencies": {
|
|
35
|
-
"@babel/generator": "7.28.
|
|
36
|
-
"@babel/parser": "7.28.
|
|
37
|
-
"@babel/traverse": "7.28.
|
|
38
|
-
"@babel/types": "7.28.
|
|
39
|
-
"cross-env": "^
|
|
40
|
-
"csv-to-markdown-table": "^1.5.0",
|
|
41
|
-
"deepmerge": "^4.3.1",
|
|
38
|
+
"@babel/generator": "7.28.5",
|
|
39
|
+
"@babel/parser": "7.28.5",
|
|
40
|
+
"@babel/traverse": "7.28.5",
|
|
41
|
+
"@babel/types": "7.28.5",
|
|
42
|
+
"cross-env": "^10.1.0",
|
|
42
43
|
"filenamify": "4.3.0",
|
|
43
|
-
"fs-extra": "^11.3.
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"iconv-lite": "^0.6.3",
|
|
44
|
+
"fs-extra": "^11.3.2",
|
|
45
|
+
"iconv-lite": "^0.7.0",
|
|
46
|
+
"javascript-stringify": "^2.1.0",
|
|
47
47
|
"jest-diff": "^29.7.0",
|
|
48
48
|
"jest-snapshot": "29.7.0",
|
|
49
49
|
"jsdom": "^26.1.0",
|
|
50
|
-
"memfs": "4.
|
|
51
|
-
"
|
|
52
|
-
"path-serializer": "0.5.0",
|
|
50
|
+
"memfs": "4.48.1",
|
|
51
|
+
"path-serializer": "0.5.1",
|
|
53
52
|
"pretty-format": "29.7.0",
|
|
54
53
|
"rimraf": "^5.0.10",
|
|
55
54
|
"source-map": "^0.7.6",
|
|
56
55
|
"terser-webpack-plugin": "^5.3.14",
|
|
57
|
-
"webpack": "5.
|
|
56
|
+
"webpack": "5.102.1",
|
|
58
57
|
"webpack-merge": "6.0.1",
|
|
59
|
-
"webpack-sources": "3.3.3"
|
|
58
|
+
"webpack-sources": "3.3.3",
|
|
59
|
+
"chalk": "^4.1.2"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@rspack/plugin-preact-refresh": "1.1.2",
|
|
63
|
-
"@rspack/plugin-react-refresh": "^1.4.3",
|
|
64
|
-
"@swc/helpers": "0.5.17",
|
|
65
|
-
"@swc/plugin-remove-console": "^9.0.0",
|
|
66
62
|
"@types/babel__generator": "7.27.0",
|
|
67
|
-
"@types/babel__traverse": "7.
|
|
63
|
+
"@types/babel__traverse": "7.28.0",
|
|
68
64
|
"@types/fs-extra": "11.0.4",
|
|
69
65
|
"@types/jsdom": "^21.1.7",
|
|
70
|
-
"
|
|
71
|
-
"@types/react-dom": "^19.1.6",
|
|
72
|
-
"@webdiscus/pug-loader": "^2.11.1",
|
|
73
|
-
"acorn": "^8.15.0",
|
|
74
|
-
"babel-loader": "^10.0.0",
|
|
75
|
-
"babel-plugin-import": "^1.13.8",
|
|
76
|
-
"chalk": "^4.1.2",
|
|
77
|
-
"core-js": "3.44.0",
|
|
78
|
-
"css-loader": "^7.1.2",
|
|
79
|
-
"file-loader": "^6.2.0",
|
|
80
|
-
"graceful-fs": "^4.2.11",
|
|
81
|
-
"html-loader": "^5.1.0",
|
|
82
|
-
"html-webpack-plugin": "^5.6.3",
|
|
83
|
-
"less-loader": "^12.3.0",
|
|
84
|
-
"lodash": "^4.17.21",
|
|
85
|
-
"postcss-loader": "^8.1.1",
|
|
86
|
-
"postcss-pxtorem": "^6.1.0",
|
|
87
|
-
"raw-loader": "^4.0.2",
|
|
88
|
-
"react": "^19.1.0",
|
|
89
|
-
"react-dom": "^19.1.0",
|
|
90
|
-
"react-refresh": "^0.17.0",
|
|
91
|
-
"sass-loader": "^16.0.5",
|
|
92
|
-
"source-map": "^0.7.6",
|
|
93
|
-
"source-map-loader": "^5.0.0",
|
|
94
|
-
"style-loader": "^4.0.0",
|
|
95
|
-
"terser": "5.43.1",
|
|
96
|
-
"typescript": "^5.8.3",
|
|
66
|
+
"typescript": "^5.9.3",
|
|
97
67
|
"wast-loader": "^1.14.1",
|
|
98
|
-
"
|
|
99
|
-
"@rspack/cli": "npm:@rspack-debug/cli@1.4.11",
|
|
100
|
-
"@rspack/core": "npm:@rspack-debug/core@1.4.11",
|
|
101
|
-
"@rspack/binding-testing": "1.4.1",
|
|
102
|
-
"@rspack/test-tools": "npm:@rspack-debug/test-tools@1.4.11"
|
|
68
|
+
"@rspack/core": "npm:@rspack-debug/core@1.6.4"
|
|
103
69
|
},
|
|
104
70
|
"peerDependencies": {
|
|
105
71
|
"@rspack/core": ">=1.0.0"
|
|
@@ -107,11 +73,6 @@
|
|
|
107
73
|
"scripts": {
|
|
108
74
|
"build": "tsc -b ./tsconfig.build.json",
|
|
109
75
|
"dev": "tsc -b -w",
|
|
110
|
-
"test": "cross-env RUST_BACKTRACE=full pnpm run --stream /^test:.*/",
|
|
111
|
-
"testu": "pnpm run --stream /^test:.*/ -u",
|
|
112
|
-
"test:base": "cross-env node --no-warnings --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --logHeapUsage --colors --config ./jest.config.js --passWithNoTests",
|
|
113
|
-
"test:hot": "cross-env RSPACK_HOT_TEST=true node --no-warnings --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --logHeapUsage --colors --config ./jest.config.hot.js --passWithNoTests",
|
|
114
|
-
"test:diff": "cross-env RSPACK_DIFF=true node --no-warnings --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --logHeapUsage --colors --config ./jest.config.diff.js --passWithNoTests",
|
|
115
76
|
"api-extractor": "api-extractor run --verbose",
|
|
116
77
|
"api-extractor:ci": "api-extractor run --verbose || diff temp/test-tools.api.md etc/test-tools.api.md"
|
|
117
78
|
}
|
package/rstest.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="@rstest/core/globals" />
|
|
2
|
+
|
|
3
|
+
import type { DiffOptions } from "jest-diff";
|
|
4
|
+
|
|
5
|
+
declare interface FileMatcherOptions {
|
|
6
|
+
diff?: DiffOptions;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module "@rstest/core" {
|
|
10
|
+
interface Assertion {
|
|
11
|
+
toMatchFileSnapshotSync: (
|
|
12
|
+
filename?: string,
|
|
13
|
+
options?: FileMatcherOptions
|
|
14
|
+
) => void;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare global {
|
|
19
|
+
type Expect = import("@rstest/core").Expect;
|
|
20
|
+
type Describe = import("@rstest/core").Describe;
|
|
21
|
+
type Assertion<T> = import("@rstest/core").Assertion<T>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {};
|
package/dist/case/diff.d.ts
DELETED
package/dist/case/diff.js
DELETED
|
@@ -1,126 +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.createDiffCase = createDiffCase;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
-
const rimraf_1 = require("rimraf");
|
|
10
|
-
const createLazyTestEnv_1 = __importDefault(require("../helper/legacy/createLazyTestEnv"));
|
|
11
|
-
const processor_1 = require("../processor");
|
|
12
|
-
const tester_1 = require("../test/tester");
|
|
13
|
-
const type_1 = require("../type");
|
|
14
|
-
const DEFAULT_CASE_CONFIG = {
|
|
15
|
-
webpackPath: require.resolve("webpack"),
|
|
16
|
-
rspackPath: require.resolve("@rspack/core"),
|
|
17
|
-
files: ["bundle.js"],
|
|
18
|
-
bootstrap: true,
|
|
19
|
-
detail: true,
|
|
20
|
-
errors: false
|
|
21
|
-
};
|
|
22
|
-
function createDiffCase(name, src, dist) {
|
|
23
|
-
const caseConfigFile = node_path_1.default.join(src, "test.config.js");
|
|
24
|
-
if (!fs_extra_1.default.existsSync(caseConfigFile)) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const caseConfig = Object.assign({}, DEFAULT_CASE_CONFIG, require(caseConfigFile));
|
|
28
|
-
const [processor, compareMap] = createDiffProcessor(caseConfig);
|
|
29
|
-
const tester = new tester_1.Tester({
|
|
30
|
-
name,
|
|
31
|
-
src,
|
|
32
|
-
dist,
|
|
33
|
-
steps: [processor]
|
|
34
|
-
});
|
|
35
|
-
(0, rimraf_1.rimrafSync)(dist);
|
|
36
|
-
const prefix = node_path_1.default.basename(name);
|
|
37
|
-
describe(`${prefix}:check`, () => {
|
|
38
|
-
beforeAll(async () => {
|
|
39
|
-
await tester.compile();
|
|
40
|
-
compareMap.clear();
|
|
41
|
-
await tester.check(env);
|
|
42
|
-
});
|
|
43
|
-
for (const file of caseConfig.files) {
|
|
44
|
-
describe(`Comparing "${file}"`, () => {
|
|
45
|
-
let moduleResults = [];
|
|
46
|
-
let runtimeResults = [];
|
|
47
|
-
beforeAll(() => {
|
|
48
|
-
const fileResult = compareMap.get(file);
|
|
49
|
-
if (!fileResult) {
|
|
50
|
-
throw new Error(`File ${file} has no results`);
|
|
51
|
-
}
|
|
52
|
-
moduleResults = fileResult.modules;
|
|
53
|
-
runtimeResults = fileResult.runtimeModules;
|
|
54
|
-
});
|
|
55
|
-
if (caseConfig.modules) {
|
|
56
|
-
checkCompareResults("modules", () => moduleResults);
|
|
57
|
-
}
|
|
58
|
-
if (caseConfig.runtimeModules) {
|
|
59
|
-
checkCompareResults("runtime modules", () => runtimeResults);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
const env = (0, createLazyTestEnv_1.default)(1000);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function createDiffProcessor(config) {
|
|
67
|
-
const fileCompareMap = new Map();
|
|
68
|
-
const createCompareResultHandler = (type) => {
|
|
69
|
-
return (file, results) => {
|
|
70
|
-
const fileResult = fileCompareMap.get(file) || {
|
|
71
|
-
modules: [],
|
|
72
|
-
runtimeModules: []
|
|
73
|
-
};
|
|
74
|
-
fileResult[type] = results;
|
|
75
|
-
fileCompareMap.set(file, fileResult);
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
const processor = new processor_1.DiffProcessor({
|
|
79
|
-
webpackPath: config.webpackPath,
|
|
80
|
-
rspackPath: config.rspackPath,
|
|
81
|
-
files: config.files,
|
|
82
|
-
modules: config.modules,
|
|
83
|
-
runtimeModules: config.runtimeModules,
|
|
84
|
-
renameModule: config.renameModule,
|
|
85
|
-
ignoreModuleId: config.ignoreModuleId ?? true,
|
|
86
|
-
ignoreModuleArguments: config.ignoreModuleArguments ?? true,
|
|
87
|
-
ignorePropertyQuotationMark: config.ignorePropertyQuotationMark ?? true,
|
|
88
|
-
ignoreBlockOnlyStatement: config.ignoreBlockOnlyStatement ?? true,
|
|
89
|
-
ignoreIfCertainCondition: config.ignoreIfCertainCondition ?? true,
|
|
90
|
-
ignoreSwcHelpersPath: config.ignoreSwcHelpersPath ?? true,
|
|
91
|
-
ignoreObjectPropertySequence: config.ignoreObjectPropertySequence ?? true,
|
|
92
|
-
ignoreCssFilePath: config.ignoreCssFilePath ?? true,
|
|
93
|
-
onCompareModules: createCompareResultHandler("modules"),
|
|
94
|
-
onCompareRuntimeModules: createCompareResultHandler("runtimeModules"),
|
|
95
|
-
bootstrap: config.bootstrap ?? true,
|
|
96
|
-
detail: config.detail ?? true,
|
|
97
|
-
errors: config.errors ?? false,
|
|
98
|
-
replacements: config.replacements
|
|
99
|
-
});
|
|
100
|
-
return [processor, fileCompareMap];
|
|
101
|
-
}
|
|
102
|
-
function checkCompareResults(name, getResults) {
|
|
103
|
-
describe(`Comparing ${name}`, () => {
|
|
104
|
-
it("should not miss any module", () => {
|
|
105
|
-
expect(getResults()
|
|
106
|
-
.filter(i => i.type === type_1.ECompareResultType.Missing)
|
|
107
|
-
.map(i => i.name)).toEqual([]);
|
|
108
|
-
});
|
|
109
|
-
it("should not have any rspack-only module", () => {
|
|
110
|
-
expect(getResults()
|
|
111
|
-
.filter(i => i.type === type_1.ECompareResultType.OnlySource)
|
|
112
|
-
.map(i => i.name)).toEqual([]);
|
|
113
|
-
});
|
|
114
|
-
it("should not have any webpack-only module", () => {
|
|
115
|
-
expect(getResults()
|
|
116
|
-
.filter(i => i.type === type_1.ECompareResultType.OnlyDist)
|
|
117
|
-
.map(i => i.name)).toEqual([]);
|
|
118
|
-
});
|
|
119
|
-
it("all modules should be the same", () => {
|
|
120
|
-
for (const result of getResults().filter(i => i.type === type_1.ECompareResultType.Different)) {
|
|
121
|
-
console.log(`${result.name}:\n${result.detail}`);
|
|
122
|
-
}
|
|
123
|
-
expect(getResults().every(i => i.type === type_1.ECompareResultType.Same)).toEqual(true);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ITestReporter, TCompareModules } from "../type";
|
|
2
|
-
import type { IFormatCodeOptions } from "./format-code";
|
|
3
|
-
export interface IDiffComparatorOptions {
|
|
4
|
-
rspackDist: string;
|
|
5
|
-
webpackDist: string;
|
|
6
|
-
files: string[];
|
|
7
|
-
modules?: TCompareModules;
|
|
8
|
-
runtimeModules?: TCompareModules;
|
|
9
|
-
reporters: ITestReporter<unknown>[];
|
|
10
|
-
formatOptions?: IFormatCodeOptions;
|
|
11
|
-
bootstrap?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare class DiffComparator {
|
|
14
|
-
private options;
|
|
15
|
-
constructor(options: IDiffComparatorOptions);
|
|
16
|
-
compare(): Promise<void>;
|
|
17
|
-
}
|
|
@@ -1,52 +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.DiffComparator = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
9
|
-
const compare_1 = require("./compare");
|
|
10
|
-
const replace_runtime_module_name_1 = require("./replace-runtime-module-name");
|
|
11
|
-
class DiffComparator {
|
|
12
|
-
constructor(options) {
|
|
13
|
-
this.options = options;
|
|
14
|
-
}
|
|
15
|
-
async compare() {
|
|
16
|
-
for (const file of this.options.files) {
|
|
17
|
-
try {
|
|
18
|
-
const result = (0, compare_1.compareFile)(node_path_1.default.join(this.options.rspackDist, file), node_path_1.default.join(this.options.webpackDist, file), {
|
|
19
|
-
modules: this.options.modules,
|
|
20
|
-
runtimeModules: this.options.runtimeModules,
|
|
21
|
-
format: (0, deepmerge_1.default)({
|
|
22
|
-
replacements: {},
|
|
23
|
-
ignorePropertyQuotationMark: true,
|
|
24
|
-
ignoreModuleId: true,
|
|
25
|
-
ignoreModuleArguments: true,
|
|
26
|
-
ignoreBlockOnlyStatement: true,
|
|
27
|
-
ignoreIfCertainCondition: true,
|
|
28
|
-
ignoreSwcHelpersPath: true,
|
|
29
|
-
ignoreObjectPropertySequence: true,
|
|
30
|
-
ignoreCssFilePath: true
|
|
31
|
-
}, this.options.formatOptions || {}),
|
|
32
|
-
renameModule: replace_runtime_module_name_1.replaceRuntimeModuleName,
|
|
33
|
-
bootstrap: this.options.bootstrap
|
|
34
|
-
});
|
|
35
|
-
for (const reporter of this.options.reporters) {
|
|
36
|
-
reporter.increment(file, result.modules.modules || []);
|
|
37
|
-
}
|
|
38
|
-
for (const reporter of this.options.reporters) {
|
|
39
|
-
reporter.increment(file, result.modules.runtimeModules || []);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
console.error(e);
|
|
44
|
-
for (const reporter of this.options.reporters) {
|
|
45
|
-
reporter.failure(file);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
await Promise.all(this.options.reporters.map(r => r.output()));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.DiffComparator = DiffComparator;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type TCompareModules, type TCompareResult, type TFileCompareResult, type TModuleCompareResult } from "../type";
|
|
2
|
-
import { type IFormatCodeOptions } from "./format-code";
|
|
3
|
-
declare global {
|
|
4
|
-
var updateSnapshot: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface ICompareOptions {
|
|
7
|
-
modules?: TCompareModules;
|
|
8
|
-
runtimeModules?: TCompareModules;
|
|
9
|
-
format: IFormatCodeOptions;
|
|
10
|
-
renameModule?: (name: string) => string;
|
|
11
|
-
bootstrap?: boolean;
|
|
12
|
-
detail?: boolean;
|
|
13
|
-
snapshot?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function compareFile(sourceFile: string, distFile: string, compareOptions: ICompareOptions): TFileCompareResult;
|
|
16
|
-
export declare function compareModules(modules: string[], sourceModules: Record<string, string>, distModules: Record<string, string>, compareOptions: ICompareOptions): TModuleCompareResult[];
|
|
17
|
-
export declare function compareContent(sourceContent: string | false, distContent: string | false, compareOptions: ICompareOptions): TCompareResult;
|