@rspack-canary/test-tools 1.6.0-canary-6cd722f4-20251022123039 → 1.6.0-canary-e28e40e9-20251022173516

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 (68) hide show
  1. package/dist/case/builtin.d.ts +3 -2
  2. package/dist/case/cache.d.ts +2 -2
  3. package/dist/case/cache.js +4 -1
  4. package/dist/case/common.d.ts +11 -10
  5. package/dist/case/common.js +2 -5
  6. package/dist/case/compiler.d.ts +9 -8
  7. package/dist/case/config.d.ts +6 -5
  8. package/dist/case/defaults.d.ts +5 -4
  9. package/dist/case/defaults.js +1 -1
  10. package/dist/case/error.d.ts +5 -5
  11. package/dist/case/hash.d.ts +2 -2
  12. package/dist/case/hook.d.ts +4 -3
  13. package/dist/case/hot-step.d.ts +2 -2
  14. package/dist/case/hot-step.js +1 -2
  15. package/dist/case/hot.d.ts +5 -4
  16. package/dist/case/incremental.d.ts +2 -2
  17. package/dist/case/index.d.ts +0 -1
  18. package/dist/case/index.js +1 -3
  19. package/dist/case/multi-compiler.d.ts +9 -8
  20. package/dist/case/runner.d.ts +5 -4
  21. package/dist/case/serial.d.ts +2 -2
  22. package/dist/case/stats-api.d.ts +6 -5
  23. package/dist/case/stats-api.js +1 -2
  24. package/dist/case/stats-output.d.ts +3 -2
  25. package/dist/case/watch.d.ts +6 -6
  26. package/dist/case/watch.js +2 -1
  27. package/dist/compiler.d.ts +15 -17
  28. package/dist/compiler.js +4 -11
  29. package/dist/helper/legacy/checkArrayExpectation.js +1 -1
  30. package/dist/helper/read-config-file.d.ts +3 -2
  31. package/dist/index.d.ts +0 -1
  32. package/dist/index.js +0 -1
  33. package/dist/plugin/index.d.ts +0 -3
  34. package/dist/plugin/index.js +0 -3
  35. package/dist/runner/node/index.d.ts +9 -8
  36. package/dist/runner/node/index.js +3 -1
  37. package/dist/runner/web/index.d.ts +5 -5
  38. package/dist/test/context.d.ts +4 -4
  39. package/dist/test/context.js +5 -13
  40. package/dist/test/creator.d.ts +14 -14
  41. package/dist/test/creator.js +3 -4
  42. package/dist/type.d.ts +27 -40
  43. package/dist/type.js +1 -6
  44. package/package.json +4 -9
  45. package/dist/case/diff.d.ts +0 -19
  46. package/dist/case/diff.js +0 -274
  47. package/dist/compare/comparator.d.ts +0 -17
  48. package/dist/compare/comparator.js +0 -52
  49. package/dist/compare/compare.d.ts +0 -17
  50. package/dist/compare/compare.js +0 -178
  51. package/dist/compare/format-code.d.ts +0 -16
  52. package/dist/compare/format-code.js +0 -244
  53. package/dist/compare/index.d.ts +0 -5
  54. package/dist/compare/index.js +0 -21
  55. package/dist/compare/replace-module-argument.d.ts +0 -1
  56. package/dist/compare/replace-module-argument.js +0 -8
  57. package/dist/compare/replace-runtime-module-name.d.ts +0 -1
  58. package/dist/compare/replace-runtime-module-name.js +0 -71
  59. package/dist/plugin/rspack-diff-config-plugin.d.ts +0 -7
  60. package/dist/plugin/rspack-diff-config-plugin.js +0 -42
  61. package/dist/plugin/webpack-diff-config-plugin.d.ts +0 -7
  62. package/dist/plugin/webpack-diff-config-plugin.js +0 -41
  63. package/dist/plugin/webpack-module-placeholder-plugin.d.ts +0 -3
  64. package/dist/plugin/webpack-module-placeholder-plugin.js +0 -106
  65. package/template/diff.bundle.css +0 -1
  66. package/template/diff.bundle.js +0 -144
  67. package/template/diff.html +0 -14
  68. package/template/editor.worker.js +0 -1
@@ -1,3 +1,4 @@
1
- import type { ECompilerType, ITestContext, TCompilerOptions } from "../type";
1
+ import type { RspackOptions } from "@rspack/core";
2
+ import type { ITestContext } from "../type";
2
3
  export declare function createBuiltinCase(name: string, src: string, dist: string): void;
3
- export declare function defaultOptions<T extends ECompilerType.Rspack>(context: ITestContext): TCompilerOptions<T>;
4
+ export declare function defaultOptions(context: ITestContext): RspackOptions;
@@ -1,2 +1,2 @@
1
- import type { ECompilerType, TCompilerOptions } from "../type";
2
- export declare function createCacheCase(name: string, src: string, dist: string, target: TCompilerOptions<ECompilerType.Rspack>["target"], temp: string): void;
1
+ import { type RspackOptions } from "@rspack/core";
2
+ export declare function createCacheCase(name: string, src: string, dist: string, target: RspackOptions["target"], temp: string): void;
@@ -137,7 +137,10 @@ function findBundle(name, target, context) {
137
137
  const stats = compiler.getStats();
138
138
  if (!stats)
139
139
  throw new Error("Stats should exists when find bundle");
140
- const info = stats.toJson({ all: false, entrypoints: true });
140
+ const info = stats.toJson({
141
+ all: false,
142
+ entrypoints: true
143
+ });
141
144
  if (target === "web" || target === "webworker") {
142
145
  for (const file of info.entrypoints.main.assets) {
143
146
  if ((0, helper_1.isJavaScript)(file.name)) {
@@ -1,11 +1,12 @@
1
- import { ECompilerType, type ITestCompilerManager, type ITestContext, type ITestEnv, type TCompiler, type TCompilerOptions } from "../type";
2
- export declare function getCompiler<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string): ITestCompilerManager<T>;
3
- export declare function config<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string, configFiles: string[], defaultOptions?: TCompilerOptions<T>): Promise<TCompilerOptions<T>>;
4
- export declare function compiler<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string): Promise<TCompiler<T>>;
5
- export declare function build<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string): Promise<TCompiler<T>>;
6
- export declare function run<T extends ECompilerType = ECompilerType.Rspack>(env: ITestEnv, context: ITestContext, name: string, findBundle: (context: ITestContext, options: TCompilerOptions<T>) => string[] | string | void): Promise<void>;
7
- export declare function check<T extends ECompilerType = ECompilerType.Rspack>(env: ITestEnv, context: ITestContext, name: string): Promise<void>;
8
- export declare function checkSnapshot<T extends ECompilerType = ECompilerType.Rspack>(env: ITestEnv, context: ITestContext, name: string, snapshot: string, filter?: (file: string) => boolean): Promise<void>;
1
+ import type { Compiler, RspackOptions } from "@rspack/core";
2
+ import type { ITestCompilerManager, ITestContext, ITestEnv } from "../type";
3
+ export declare function getCompiler(context: ITestContext, name: string): ITestCompilerManager;
4
+ export declare function config(context: ITestContext, name: string, configFiles: string[], defaultOptions?: RspackOptions): Promise<RspackOptions>;
5
+ export declare function compiler(context: ITestContext, name: string): Promise<Compiler>;
6
+ export declare function build(context: ITestContext, name: string): Promise<Compiler>;
7
+ export declare function run(env: ITestEnv, context: ITestContext, name: string, findBundle: (context: ITestContext, options: RspackOptions) => string[] | string | void): Promise<void>;
8
+ export declare function check(env: ITestEnv, context: ITestContext, name: string): Promise<void>;
9
+ export declare function checkSnapshot(env: ITestEnv, context: ITestContext, name: string, snapshot: string, filter?: (file: string) => boolean): Promise<void>;
9
10
  export declare function afterExecute(context: ITestContext, name: string): Promise<void>;
10
- export declare function findMultiCompilerBundle<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string, multiFindBundle: (index: number, context: ITestContext, options: TCompilerOptions<T>) => string[] | string | void): string[];
11
- export declare function configMultiCompiler<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string, configFiles: string[], defaultOptions: (index: number, context: ITestContext) => TCompilerOptions<T>, overrideOptions: (index: number, context: ITestContext, options: TCompilerOptions<T>) => void): void;
11
+ export declare function findMultiCompilerBundle(context: ITestContext, name: string, multiFindBundle: (index: number, context: ITestContext, options: RspackOptions) => string[] | string | void): string[];
12
+ export declare function configMultiCompiler(context: ITestContext, name: string, configFiles: string[], defaultOptions: (index: number, context: ITestContext) => RspackOptions, overrideOptions: (index: number, context: ITestContext, options: RspackOptions) => void): void;
@@ -19,9 +19,8 @@ const webpack_merge_1 = __importDefault(require("webpack-merge"));
19
19
  const helper_1 = require("../helper");
20
20
  const placeholder_1 = require("../helper/expect/placeholder");
21
21
  const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
22
- const type_1 = require("../type");
23
22
  function getCompiler(context, name) {
24
- return context.getCompiler(name, type_1.ECompilerType.Rspack);
23
+ return context.getCompiler(name);
25
24
  }
26
25
  async function config(context, name, configFiles, defaultOptions = {}) {
27
26
  const compiler = getCompiler(context, name);
@@ -138,9 +137,7 @@ async function checkSnapshot(env, context, name, snapshot, filter) {
138
137
  const compilers = "compilers" in compiler
139
138
  ? compiler.compilers
140
139
  : [compiler];
141
- const totalStats = "stats" in stats
142
- ? stats.stats
143
- : [stats];
140
+ const totalStats = "stats" in stats ? stats.stats : [stats];
144
141
  const total = compilers.length;
145
142
  for (let i = 0; i < compilers.length; i++) {
146
143
  const c = compilers[i];
@@ -1,18 +1,19 @@
1
- import type { ECompilerType, ITestContext, TCompilation, TCompiler, TCompilerOptions, TCompilerStats, TCompilerStatsCompilation } from "../type";
1
+ import type { Compilation, Compiler, RspackOptions, Stats, StatsCompilation } from "@rspack/core";
2
+ import type { ITestContext } from "../type";
2
3
  export declare function createCompilerCase(name: string, src: string, dist: string, testConfig: string): void;
3
4
  export type TCompilerCaseConfig = {
4
5
  description: string;
5
6
  error?: boolean;
6
7
  skip?: boolean;
7
- options?: (context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>;
8
- compiler?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
9
- build?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
8
+ options?: (context: ITestContext) => RspackOptions;
9
+ compiler?: (context: ITestContext, compiler: Compiler) => Promise<void>;
10
+ build?: (context: ITestContext, compiler: Compiler) => Promise<void>;
10
11
  check?: ({ context, stats, files, compiler, compilation }: {
11
12
  context: ITestContext;
12
- stats?: TCompilerStatsCompilation<ECompilerType.Rspack>;
13
+ stats?: StatsCompilation;
13
14
  files?: Record<string, string>;
14
- compiler: TCompiler<ECompilerType.Rspack>;
15
- compilation?: TCompilation<ECompilerType.Rspack>;
15
+ compiler: Compiler;
16
+ compilation?: Compilation;
16
17
  }) => Promise<void>;
17
- compilerCallback?: (error: Error | null, stats: TCompilerStats<ECompilerType.Rspack> | null) => void;
18
+ compilerCallback?: (error: Error | null, stats: Stats | null) => void;
18
19
  };
@@ -1,7 +1,8 @@
1
- import type { ECompilerType, ITestContext, ITestProcessor, TCompilerOptions, TTestConfig } from "../type";
2
- export type TConfigCaseConfig = Omit<TTestConfig<ECompilerType.Rspack>, "validate">;
1
+ import type { RspackOptions } from "@rspack/core";
2
+ import type { ITestContext, ITestProcessor, TTestConfig } from "../type";
3
+ export type TConfigCaseConfig = Omit<TTestConfig, "validate">;
3
4
  export declare function createConfigProcessor(name: string): ITestProcessor;
4
5
  export declare function createConfigCase(name: string, src: string, dist: string): void;
5
- export declare function defaultOptions(index: number, context: ITestContext): TCompilerOptions<ECompilerType.Rspack>;
6
- export declare function overrideOptions(index: number, context: ITestContext, options: TCompilerOptions<ECompilerType.Rspack>): void;
7
- export declare function findBundle(index: number, context: ITestContext, options: TCompilerOptions<ECompilerType.Rspack>): string | string[];
6
+ export declare function defaultOptions(index: number, context: ITestContext): RspackOptions;
7
+ export declare function overrideOptions(index: number, context: ITestContext, options: RspackOptions): void;
8
+ export declare function findBundle(index: number, context: ITestContext, options: RspackOptions): string | string[];
@@ -1,10 +1,11 @@
1
- import type { ECompilerType, ITestContext, TCompilerOptions } from "../type";
1
+ import type { RspackOptions } from "@rspack/core";
2
+ import type { ITestContext } from "../type";
2
3
  export declare function createDefaultsCase(name: string, src: string): void;
3
- export declare function getRspackDefaultConfig(cwd: string, config: TCompilerOptions<ECompilerType>): TCompilerOptions<ECompilerType>;
4
+ export declare function getRspackDefaultConfig(cwd: string, config: RspackOptions): RspackOptions;
4
5
  export type TDefaultsCaseConfig = {
5
- options?: (context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>;
6
+ options?: (context: ITestContext) => RspackOptions;
6
7
  cwd?: string;
7
- diff: (diff: jest.JestMatchers<RspackTestDiff>, defaults: jest.JestMatchers<TCompilerOptions<ECompilerType.Rspack>>) => Promise<void>;
8
+ diff: (diff: jest.JestMatchers<RspackTestDiff>, defaults: jest.JestMatchers<RspackOptions>) => Promise<void>;
8
9
  description: string;
9
10
  };
10
11
  declare class RspackTestDiff {
@@ -88,7 +88,7 @@ async function run(name, processor) {
88
88
  context.emitError(name, e);
89
89
  }
90
90
  finally {
91
- await processor.check?.({ expect, it, beforeEach, afterEach, jest }, context);
91
+ await processor.check?.({ expect, it, beforeEach, afterEach, jest: global.jest || global.rstest }, context);
92
92
  await processor.after?.(context);
93
93
  }
94
94
  }
@@ -1,5 +1,5 @@
1
- import type { StatsError } from "@rspack/core";
2
- import type { ECompilerType, ITestContext, TCompiler, TCompilerOptions } from "../type";
1
+ import type { Compiler, RspackOptions, StatsError } from "@rspack/core";
2
+ import type { ITestContext } from "../type";
3
3
  export declare function createErrorCase(name: string, src: string, dist: string, testConfig: string): void;
4
4
  declare class RspackStatsDiagnostics {
5
5
  errors: StatsError[];
@@ -9,9 +9,9 @@ declare class RspackStatsDiagnostics {
9
9
  export type TErrorCaseConfig = {
10
10
  description: string;
11
11
  skip?: boolean;
12
- options?: (context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>;
13
- compiler?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
14
- build?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
12
+ options?: (context: ITestContext) => RspackOptions;
13
+ compiler?: (context: ITestContext, compiler: Compiler) => Promise<void>;
14
+ build?: (context: ITestContext, compiler: Compiler) => Promise<void>;
15
15
  check?: (stats: RspackStatsDiagnostics) => Promise<void>;
16
16
  };
17
17
  export {};
@@ -1,3 +1,3 @@
1
- import type { ECompilerType, TTestConfig } from "../type";
2
- export type THashCaseConfig = Pick<TTestConfig<ECompilerType.Rspack>, "validate">;
1
+ import type { TTestConfig } from "../type";
2
+ export type THashCaseConfig = Pick<TTestConfig, "validate">;
3
3
  export declare function createHashCase(name: string, src: string, dist: string): void;
@@ -1,5 +1,6 @@
1
+ import { Compiler, type RspackOptions } from "@rspack/core";
1
2
  import { TestContext, type TTestContextOptions } from "../test/context";
2
- import type { ECompilerType, ITestContext, ITestEnv, TCompiler, TCompilerOptions } from "../type";
3
+ import type { ITestContext, ITestEnv } from "../type";
3
4
  export declare function createHookCase(name: string, src: string, dist: string, source: string): void;
4
5
  export declare class HookCasesContext extends TestContext {
5
6
  protected src: string;
@@ -29,8 +30,8 @@ export declare class HookCasesContext extends TestContext {
29
30
  }): Promise<void>;
30
31
  }
31
32
  export type THookCaseConfig = {
32
- options?: (context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>;
33
- compiler?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
33
+ options?: (context: ITestContext) => RspackOptions;
34
+ compiler?: (context: ITestContext, compiler: Compiler) => Promise<void>;
34
35
  check?: (context: ITestContext) => Promise<void>;
35
36
  snapshotFileFilter?: (file: string) => boolean;
36
37
  description: string;
@@ -1,2 +1,2 @@
1
- import { ECompilerType, type TCompilerOptions } from "../type";
2
- export declare function createHotStepCase(name: string, src: string, dist: string, temp: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
1
+ import type { RspackOptions } from "@rspack/core";
2
+ export declare function createHotStepCase(name: string, src: string, dist: string, temp: string, target: RspackOptions["target"]): void;
@@ -9,7 +9,6 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const helper_1 = require("../helper");
10
10
  const placeholder_1 = require("../helper/expect/placeholder");
11
11
  const creator_1 = require("../test/creator");
12
- const type_1 = require("../type");
13
12
  const common_1 = require("./common");
14
13
  const hot_1 = require("./hot");
15
14
  const NOOP_SET = new Set();
@@ -261,7 +260,7 @@ ${runtime.javascript.disposedModules.map(i => `- ${i}`).join("\n")}
261
260
  : Array.from(entry.runtime);
262
261
  }
263
262
  }
264
- const compiler = context.getCompiler(name, type_1.ECompilerType.Rspack);
263
+ const compiler = context.getCompiler(name);
265
264
  const compilerOptions = compiler.getOptions();
266
265
  matchStepSnapshot(env, context, updateIndex, compilerOptions, statsJson, runtime);
267
266
  hashes.push(stats.hash);
@@ -1,10 +1,11 @@
1
+ import { type RspackOptions } from "@rspack/core";
1
2
  import { HotUpdatePlugin } from "../helper/hot-update/plugin";
2
- import type { ECompilerType, ITestContext, ITestEnv, ITestProcessor, ITestRunner, TCompilerOptions } from "../type";
3
- type TTarget = TCompilerOptions<ECompilerType.Rspack>["target"];
3
+ import type { ITestContext, ITestEnv, ITestProcessor, ITestRunner } from "../type";
4
+ type TTarget = RspackOptions["target"];
4
5
  export declare function createHotProcessor(name: string, src: string, temp: string, target: TTarget, incremental?: boolean): THotProcessor;
5
- export declare function createHotCase(name: string, src: string, dist: string, temp: string, target: TCompilerOptions<ECompilerType.Rspack>["target"]): void;
6
+ export declare function createHotCase(name: string, src: string, dist: string, temp: string, target: RspackOptions["target"]): void;
6
7
  type THotProcessor = ITestProcessor & {
7
8
  updatePlugin: HotUpdatePlugin;
8
9
  };
9
- export declare function createHotRunner<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string, file: string, env: ITestEnv): ITestRunner;
10
+ export declare function createHotRunner(context: ITestContext, name: string, file: string, env: ITestEnv): ITestRunner;
10
11
  export {};
@@ -1,5 +1,5 @@
1
- import type { ECompilerType, TCompilerOptions } from "../type";
2
- export declare function createHotIncrementalCase(name: string, src: string, dist: string, temp: string, target: TCompilerOptions<ECompilerType.Rspack>["target"], webpackCases: boolean): void;
1
+ import type { RspackOptions } from "@rspack/core";
2
+ export declare function createHotIncrementalCase(name: string, src: string, dist: string, temp: string, target: RspackOptions["target"], webpackCases: boolean): void;
3
3
  export type WatchIncrementalOptions = {
4
4
  ignoreNotFriendlyForIncrementalWarnings?: boolean;
5
5
  };
@@ -8,7 +8,6 @@ export type { TDefaultsCaseConfig } from "./defaults";
8
8
  export { createDefaultsCase, getRspackDefaultConfig } from "./defaults";
9
9
  export type { TDiagnosticOptions } from "./diagnostic";
10
10
  export { createDiagnosticCase } from "./diagnostic";
11
- export { createDiffCase } from "./diff";
12
11
  export type { TErrorCaseConfig } from "./error";
13
12
  export { createErrorCase } from "./error";
14
13
  export { createEsmOutputCase } from "./esm-output";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createWatchCase = exports.createTreeShakingCase = exports.createStatsOutputCase = exports.createStatsAPICase = exports.createSerialCase = exports.createProdNormalCase = exports.createNormalCase = exports.createHotNormalCase = exports.createDevNormalCase = exports.createNativeWatcher = exports.createMultiCompilerCase = exports.createWatchIncrementalCase = exports.createHotIncrementalCase = exports.createHotStepCase = exports.createHotCase = exports.createHookCase = exports.createHashCase = exports.createExampleCase = exports.createEsmOutputCase = exports.createErrorCase = exports.createDiffCase = exports.createDiagnosticCase = exports.getRspackDefaultConfig = exports.createDefaultsCase = exports.createConfigCase = exports.createCompilerCase = exports.createCacheCase = exports.createBuiltinCase = void 0;
3
+ exports.createWatchCase = exports.createTreeShakingCase = exports.createStatsOutputCase = exports.createStatsAPICase = exports.createSerialCase = exports.createProdNormalCase = exports.createNormalCase = exports.createHotNormalCase = exports.createDevNormalCase = exports.createNativeWatcher = exports.createMultiCompilerCase = exports.createWatchIncrementalCase = exports.createHotIncrementalCase = exports.createHotStepCase = exports.createHotCase = exports.createHookCase = exports.createHashCase = exports.createExampleCase = exports.createEsmOutputCase = exports.createErrorCase = exports.createDiagnosticCase = exports.getRspackDefaultConfig = exports.createDefaultsCase = exports.createConfigCase = exports.createCompilerCase = exports.createCacheCase = exports.createBuiltinCase = void 0;
4
4
  var builtin_1 = require("./builtin");
5
5
  Object.defineProperty(exports, "createBuiltinCase", { enumerable: true, get: function () { return builtin_1.createBuiltinCase; } });
6
6
  var cache_1 = require("./cache");
@@ -14,8 +14,6 @@ Object.defineProperty(exports, "createDefaultsCase", { enumerable: true, get: fu
14
14
  Object.defineProperty(exports, "getRspackDefaultConfig", { enumerable: true, get: function () { return defaults_1.getRspackDefaultConfig; } });
15
15
  var diagnostic_1 = require("./diagnostic");
16
16
  Object.defineProperty(exports, "createDiagnosticCase", { enumerable: true, get: function () { return diagnostic_1.createDiagnosticCase; } });
17
- var diff_1 = require("./diff");
18
- Object.defineProperty(exports, "createDiffCase", { enumerable: true, get: function () { return diff_1.createDiffCase; } });
19
17
  var error_1 = require("./error");
20
18
  Object.defineProperty(exports, "createErrorCase", { enumerable: true, get: function () { return error_1.createErrorCase; } });
21
19
  var esm_output_1 = require("./esm-output");
@@ -1,18 +1,19 @@
1
- import type { ECompilerType, ITestContext, TCompilation, TCompiler, TCompilerOptions, TCompilerStats, TCompilerStatsCompilation } from "../type";
1
+ import type { Compilation, Compiler, RspackOptions, Stats, StatsCompilation } from "@rspack/core";
2
+ import type { ITestContext } from "../type";
2
3
  export declare function createMultiCompilerCase(name: string, src: string, dist: string, testConfig: string): void;
3
4
  export type TMultiCompilerCaseConfig = {
4
5
  description: string;
5
6
  error?: boolean;
6
7
  skip?: boolean;
7
- options?: (context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>;
8
- compiler?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
9
- build?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
8
+ options?: (context: ITestContext) => RspackOptions;
9
+ compiler?: (context: ITestContext, compiler: Compiler) => Promise<void>;
10
+ build?: (context: ITestContext, compiler: Compiler) => Promise<void>;
10
11
  check?: ({ context, stats, files, compiler, compilation }: {
11
12
  context: ITestContext;
12
- stats?: TCompilerStatsCompilation<ECompilerType.Rspack>;
13
+ stats?: StatsCompilation;
13
14
  files?: Record<string, string>;
14
- compiler: TCompiler<ECompilerType.Rspack>;
15
- compilation?: TCompilation<ECompilerType.Rspack>;
15
+ compiler: Compiler;
16
+ compilation?: Compilation;
16
17
  }) => Promise<void>;
17
- compilerCallback?: (error: Error | null, stats: TCompilerStats<ECompilerType.Rspack> | null) => void;
18
+ compilerCallback?: (error: Error | null, stats: Stats | null) => void;
18
19
  };
@@ -1,4 +1,5 @@
1
- import type { ECompilerType, ITestContext, ITestEnv, ITestRunner, TCompilerStatsCompilation } from "../type";
1
+ import type { StatsCompilation } from "@rspack/core";
2
+ import type { ITestContext, ITestEnv, ITestRunner } from "../type";
2
3
  export type THotStepRuntimeLangData = {
3
4
  outdatedModules: string[];
4
5
  outdatedDependencies: Record<string, string[]>;
@@ -12,7 +13,7 @@ export type THotStepRuntimeData = {
12
13
  css: THotStepRuntimeLangData;
13
14
  statusPath: string[];
14
15
  };
15
- export declare function cachedStats<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string): () => TCompilerStatsCompilation<T>;
16
- export declare function createRunner<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string, file: string, env: ITestEnv): ITestRunner;
16
+ export declare function cachedStats(context: ITestContext, name: string): () => StatsCompilation;
17
+ export declare function createRunner(context: ITestContext, name: string, file: string, env: ITestEnv): ITestRunner;
17
18
  export declare function getMultiCompilerRunnerKey(context: ITestContext, name: string, file: string): string;
18
- export declare function createMultiCompilerRunner<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string, file: string, env: ITestEnv): ITestRunner;
19
+ export declare function createMultiCompilerRunner(context: ITestContext, name: string, file: string, env: ITestEnv): ITestRunner;
@@ -1,3 +1,3 @@
1
- import type { ECompilerType, TTestConfig } from "../type";
2
- export type TSerialCaseConfig = Omit<TTestConfig<ECompilerType.Rspack>, "validate">;
1
+ import type { TTestConfig } from "../type";
2
+ export type TSerialCaseConfig = Omit<TTestConfig, "validate">;
3
3
  export declare function createSerialCase(name: string, src: string, dist: string): void;
@@ -1,10 +1,11 @@
1
- import type { ECompilerType, ITestContext, TCompiler, TCompilerOptions, TCompilerStats } from "../type";
1
+ import type { Compiler, RspackOptions, Stats } from "@rspack/core";
2
+ import type { ITestContext } from "../type";
2
3
  export type TStatsAPICaseConfig = {
3
4
  description: string;
4
- options?: (context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>;
5
+ options?: (context: ITestContext) => RspackOptions;
5
6
  snapshotName?: string;
6
- compiler?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
7
- build?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
8
- check?: (stats: TCompilerStats<ECompilerType.Rspack>, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
7
+ compiler?: (context: ITestContext, compiler: Compiler) => Promise<void>;
8
+ build?: (context: ITestContext, compiler: Compiler) => Promise<void>;
9
+ check?: (stats: Stats, compiler: Compiler) => Promise<void>;
9
10
  };
10
11
  export declare function createStatsAPICase(name: string, src: string, dist: string, testConfig: string): void;
@@ -52,8 +52,7 @@ function createStatsAPICase(name, src, dist, testConfig) {
52
52
  });
53
53
  }
54
54
  function options(context, custom) {
55
- const res = (custom?.(context) ||
56
- {});
55
+ const res = (custom?.(context) || {});
57
56
  res.experiments ??= {};
58
57
  res.experiments.css ??= true;
59
58
  res.experiments.rspackFuture ??= {};
@@ -1,5 +1,6 @@
1
- import type { ECompilerType, ITestContext, ITestEnv, TCompilerOptions } from "../type";
2
- export declare function createStatsProcessor(name: string, defaultOptions: (index: number, context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>, overrideOptions: (index: number, context: ITestContext, options: TCompilerOptions<ECompilerType.Rspack>) => void): {
1
+ import type { RspackOptions } from "@rspack/core";
2
+ import type { ITestContext, ITestEnv } from "../type";
3
+ export declare function createStatsProcessor(name: string, defaultOptions: (index: number, context: ITestContext) => RspackOptions, overrideOptions: (index: number, context: ITestContext, options: RspackOptions) => void): {
3
4
  before: (context: ITestContext) => Promise<void>;
4
5
  config: (context: ITestContext) => Promise<void>;
5
6
  compiler: (context: ITestContext) => Promise<void>;
@@ -1,14 +1,14 @@
1
- import type { ECompilerType, ITestContext, ITestEnv, ITestRunner } from "../type";
1
+ import type { ITestContext, ITestEnv, ITestRunner } from "../type";
2
2
  export declare function createWatchInitialProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher }?: {
3
3
  incremental?: boolean | undefined;
4
4
  nativeWatcher?: boolean | undefined;
5
5
  }): {
6
6
  before: (context: ITestContext) => Promise<void>;
7
- config: <T extends ECompilerType.Rspack>(context: ITestContext) => Promise<void>;
7
+ config: (context: ITestContext) => Promise<void>;
8
8
  compiler: (context: ITestContext) => Promise<void>;
9
9
  build: (context: ITestContext) => Promise<void>;
10
10
  run: (env: ITestEnv, context: ITestContext) => Promise<void>;
11
- check: <T extends ECompilerType.Rspack>(env: ITestEnv, context: ITestContext) => Promise<void>;
11
+ check: (env: ITestEnv, context: ITestContext) => Promise<void>;
12
12
  after: (context: ITestContext) => Promise<void>;
13
13
  };
14
14
  export declare function createWatchStepProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher }?: {
@@ -16,13 +16,13 @@ export declare function createWatchStepProcessor(name: string, tempDir: string,
16
16
  nativeWatcher?: boolean | undefined;
17
17
  }): {
18
18
  before: (context: ITestContext) => Promise<void>;
19
- config: <T extends ECompilerType.Rspack>(context: ITestContext) => Promise<void>;
19
+ config: (context: ITestContext) => Promise<void>;
20
20
  compiler: (context: ITestContext) => Promise<void>;
21
21
  build: (context: ITestContext) => Promise<void>;
22
22
  run: (env: ITestEnv, context: ITestContext) => Promise<void>;
23
- check: <T extends ECompilerType.Rspack>(env: ITestEnv, context: ITestContext) => Promise<void>;
23
+ check: (env: ITestEnv, context: ITestContext) => Promise<void>;
24
24
  after: (context: ITestContext) => Promise<void>;
25
25
  };
26
26
  export declare function createWatchCase(name: string, src: string, dist: string, temp: string): void;
27
27
  export declare function getWatchRunnerKey(context: ITestContext, name: string, file: string): string;
28
- export declare function createWatchRunner<T extends ECompilerType = ECompilerType.Rspack>(context: ITestContext, name: string, file: string, env: ITestEnv): ITestRunner;
28
+ export declare function createWatchRunner(context: ITestContext, name: string, file: string, env: ITestEnv): ITestRunner;
@@ -252,7 +252,8 @@ function overrideOptions(index, context, options, tempDir, nativeWatcher) {
252
252
  }
253
253
  options.experiments.rspackFuture ??= {};
254
254
  options.experiments.rspackFuture.bundlerInfo ??= {};
255
- options.experiments.rspackFuture.bundlerInfo.force ??= false;
255
+ options.experiments.rspackFuture.bundlerInfo.force ??=
256
+ false;
256
257
  // test incremental: "safe" here, we test default incremental in Incremental-*.test.js
257
258
  options.experiments.incremental ??= "safe";
258
259
  if (!global.printLogger) {
@@ -1,29 +1,27 @@
1
1
  import EventEmitter from "node:events";
2
- import { ECompilerType, type ITestCompilerManager, type TCompiler, type TCompilerFactories, type TCompilerOptions, type TCompilerStats } from "./type";
2
+ import type { Compiler, RspackOptions, Stats } from "@rspack/core";
3
+ import type { ITestCompilerManager } from "./type";
3
4
  export declare enum ECompilerEvent {
4
5
  Build = "build",
5
6
  Option = "option",
6
7
  Create = "create",
7
8
  Close = "close"
8
9
  }
9
- export declare const COMPILER_FACTORIES: TCompilerFactories<ECompilerType>;
10
- export declare class TestCompilerManager<T extends ECompilerType> implements ITestCompilerManager<T> {
11
- protected type: T;
12
- protected factories: TCompilerFactories<T>;
13
- protected compilerOptions: TCompilerOptions<T>;
14
- protected compilerInstance: TCompiler<T> | null;
15
- protected compilerStats: TCompilerStats<T> | null;
10
+ export declare class TestCompilerManager implements ITestCompilerManager {
11
+ protected compilerOptions: RspackOptions;
12
+ protected compilerInstance: Compiler | null;
13
+ protected compilerStats: Stats | null;
16
14
  protected emitter: EventEmitter;
17
- constructor(type: T, factories?: TCompilerFactories<T>);
18
- getOptions(): TCompilerOptions<T>;
19
- setOptions(newOptions: TCompilerOptions<T>): TCompilerOptions<T>;
20
- mergeOptions(newOptions: TCompilerOptions<T>): TCompilerOptions<T>;
21
- getCompiler(): TCompiler<T> | null;
22
- createCompiler(): TCompiler<T>;
23
- createCompilerWithCallback(callback: (error: Error | null, stats: TCompilerStats<T> | null) => void): TCompiler<T>;
24
- build(): Promise<TCompilerStats<T>>;
15
+ constructor();
16
+ getOptions(): RspackOptions;
17
+ setOptions(newOptions: RspackOptions): RspackOptions;
18
+ mergeOptions(newOptions: RspackOptions): RspackOptions;
19
+ getCompiler(): Compiler | null;
20
+ createCompiler(): Compiler;
21
+ createCompilerWithCallback(callback: (error: Error | null, stats: Stats | null) => void): Compiler;
22
+ build(): Promise<Stats>;
25
23
  watch(timeout?: number): void;
26
- getStats(): TCompilerStats<T> | null;
24
+ getStats(): Stats | null;
27
25
  getEmitter(): EventEmitter<[never]>;
28
26
  close(): Promise<void>;
29
27
  }
package/dist/compiler.js CHANGED
@@ -3,10 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TestCompilerManager = exports.COMPILER_FACTORIES = exports.ECompilerEvent = void 0;
6
+ exports.TestCompilerManager = exports.ECompilerEvent = void 0;
7
7
  const node_events_1 = __importDefault(require("node:events"));
8
8
  const webpack_merge_1 = __importDefault(require("webpack-merge"));
9
- const type_1 = require("./type");
10
9
  var ECompilerEvent;
11
10
  (function (ECompilerEvent) {
12
11
  ECompilerEvent["Build"] = "build";
@@ -14,14 +13,8 @@ var ECompilerEvent;
14
13
  ECompilerEvent["Create"] = "create";
15
14
  ECompilerEvent["Close"] = "close";
16
15
  })(ECompilerEvent || (exports.ECompilerEvent = ECompilerEvent = {}));
17
- exports.COMPILER_FACTORIES = {
18
- [type_1.ECompilerType.Rspack]: ((options, callback) => require("@rspack/core")(options, callback)),
19
- [type_1.ECompilerType.Webpack]: ((options, callback) => require("webpack")(options, callback))
20
- };
21
16
  class TestCompilerManager {
22
- constructor(type, factories = exports.COMPILER_FACTORIES) {
23
- this.type = type;
24
- this.factories = factories;
17
+ constructor() {
25
18
  this.compilerOptions = {};
26
19
  this.compilerInstance = null;
27
20
  this.compilerStats = null;
@@ -44,12 +37,12 @@ class TestCompilerManager {
44
37
  return this.compilerInstance;
45
38
  }
46
39
  createCompiler() {
47
- this.compilerInstance = this.factories[this.type](this.compilerOptions);
40
+ this.compilerInstance = require("@rspack/core")(this.compilerOptions);
48
41
  this.emitter.emit(ECompilerEvent.Create, this.compilerInstance);
49
42
  return this.compilerInstance;
50
43
  }
51
44
  createCompilerWithCallback(callback) {
52
- this.compilerInstance = this.factories[this.type](this.compilerOptions, callback);
45
+ this.compilerInstance = require("@rspack/core")(this.compilerOptions, callback);
53
46
  this.emitter.emit(ECompilerEvent.Create, this.compilerInstance);
54
47
  return this.compilerInstance;
55
48
  }
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  "use strict";
3
- const fs = require("graceful-fs");
3
+ const fs = require("fs-extra");
4
4
  const path = require("node:path");
5
5
  const check = (expected, actual) => {
6
6
  if (expected instanceof RegExp) {
@@ -1,2 +1,3 @@
1
- import type { ECompilerType, ITestContext, TCompilerOptions } from "../type";
2
- export declare function readConfigFile<T extends ECompilerType>(files: string[], context: ITestContext, prevOption?: TCompilerOptions<T>, functionApply?: (config: (TCompilerOptions<T> | ((...args: unknown[]) => TCompilerOptions<T>))[]) => TCompilerOptions<T>[]): TCompilerOptions<T>[];
1
+ import type { RspackOptions } from "@rspack/core";
2
+ import type { ITestContext } from "../type";
3
+ export declare function readConfigFile(files: string[], context: ITestContext, prevOption?: RspackOptions, functionApply?: (config: (RspackOptions | ((...args: unknown[]) => RspackOptions))[]) => RspackOptions[]): RspackOptions[];
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from "./case";
2
- export * from "./compare";
3
2
  export * from "./helper";
4
3
  export * from "./plugin";
5
4
  export * from "./runner";
package/dist/index.js CHANGED
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./case"), exports);
18
- __exportStar(require("./compare"), exports);
19
18
  __exportStar(require("./helper"), exports);
20
19
  __exportStar(require("./plugin"), exports);
21
20
  __exportStar(require("./runner"), exports);
@@ -1,4 +1 @@
1
1
  export * from "./lazy-compilation-test-plugin";
2
- export * from "./rspack-diff-config-plugin";
3
- export * from "./webpack-diff-config-plugin";
4
- export * from "./webpack-module-placeholder-plugin";
@@ -15,6 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./lazy-compilation-test-plugin"), exports);
18
- __exportStar(require("./rspack-diff-config-plugin"), exports);
19
- __exportStar(require("./webpack-diff-config-plugin"), exports);
20
- __exportStar(require("./webpack-module-placeholder-plugin"), exports);
@@ -1,25 +1,26 @@
1
- import { type ECompilerType, type IGlobalContext, type IModuleScope, type ITestEnv, type ITestRunner, type TCompilerOptions, type TCompilerStatsCompilation, type TModuleObject, type TRunnerFile, type TRunnerRequirer, type TTestConfig } from "../../type";
1
+ import type { RspackOptions, StatsCompilation } from "@rspack/core";
2
+ import { type IGlobalContext, type IModuleScope, type ITestEnv, type ITestRunner, type TModuleObject, type TRunnerFile, type TRunnerRequirer, type TTestConfig } from "../../type";
2
3
  declare global {
3
4
  var printLogger: boolean;
4
5
  }
5
- export interface INodeRunnerOptions<T extends ECompilerType> {
6
+ export interface INodeRunnerOptions {
6
7
  env: ITestEnv;
7
- stats?: () => TCompilerStatsCompilation<T>;
8
+ stats?: () => StatsCompilation;
8
9
  name: string;
9
10
  runInNewContext?: boolean;
10
- testConfig: TTestConfig<T>;
11
+ testConfig: TTestConfig;
11
12
  source: string;
12
13
  dist: string;
13
- compilerOptions: TCompilerOptions<T>;
14
+ compilerOptions: RspackOptions;
14
15
  cachable?: boolean;
15
16
  }
16
- export declare class NodeRunner<T extends ECompilerType = ECompilerType.Rspack> implements ITestRunner {
17
- protected _options: INodeRunnerOptions<T>;
17
+ export declare class NodeRunner implements ITestRunner {
18
+ protected _options: INodeRunnerOptions;
18
19
  protected requireCache: any;
19
20
  protected globalContext: IGlobalContext | null;
20
21
  protected baseModuleScope: IModuleScope | null;
21
22
  protected requirers: Map<string, TRunnerRequirer>;
22
- constructor(_options: INodeRunnerOptions<T>);
23
+ constructor(_options: INodeRunnerOptions);
23
24
  run(file: string): Promise<unknown>;
24
25
  getRequire(): TRunnerRequirer;
25
26
  getGlobal(name: string): unknown;
@@ -81,7 +81,9 @@ class NodeRunner {
81
81
  this._options.testConfig.moduleScope(this.baseModuleScope, this._options.stats, this._options.compilerOptions);
82
82
  }
83
83
  this.createRunner();
84
- const res = this.getRequire()(this._options.dist, file.startsWith("./") || file.startsWith("https://test.cases/")
84
+ const res = this.getRequire()(node_path_1.default.isAbsolute(file) ? node_path_1.default.dirname(file) : this._options.dist, file.startsWith("./") ||
85
+ file.startsWith("https://test.cases/") ||
86
+ node_path_1.default.isAbsolute(file)
85
87
  ? file
86
88
  : `./${file}`);
87
89
  if (typeof res === "object" && "then" in res) {