@rspack/test-tools 2.0.1 → 2.0.3

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 (118) hide show
  1. package/dist/case/builtin.js +106 -66
  2. package/dist/case/cache.js +152 -132
  3. package/dist/case/common.d.ts +4 -4
  4. package/dist/case/common.js +162 -157
  5. package/dist/case/compiler.d.ts +4 -4
  6. package/dist/case/compiler.js +75 -64
  7. package/dist/case/config.js +112 -74
  8. package/dist/case/defaults.js +136 -83
  9. package/dist/case/diagnostic.js +112 -84
  10. package/dist/case/error.d.ts +4 -4
  11. package/dist/case/error.js +105 -89
  12. package/dist/case/esm-output.js +118 -87
  13. package/dist/case/example.js +73 -35
  14. package/dist/case/hash.js +74 -59
  15. package/dist/case/hook.js +151 -138
  16. package/dist/case/hot-step.js +130 -161
  17. package/dist/case/hot.js +148 -134
  18. package/dist/case/incremental.js +91 -58
  19. package/dist/case/index.js +134 -51
  20. package/dist/case/multi-compiler.d.ts +4 -4
  21. package/dist/case/multi-compiler.js +81 -56
  22. package/dist/case/native-watcher.js +62 -30
  23. package/dist/case/normal.js +253 -185
  24. package/dist/case/runner.js +80 -51
  25. package/dist/case/serial.js +47 -16
  26. package/dist/case/stats-api.d.ts +4 -4
  27. package/dist/case/stats-api.js +63 -43
  28. package/dist/case/stats-output.d.ts +3 -3
  29. package/dist/case/stats-output.js +147 -152
  30. package/dist/case/treeshaking.js +66 -35
  31. package/dist/case/watch.d.ts +3 -19
  32. package/dist/case/watch.js +204 -224
  33. package/dist/compiler.js +222 -195
  34. package/dist/helper/directory.js +83 -71
  35. package/dist/helper/disable-iconv-lite-warning.js +35 -9
  36. package/dist/helper/expect/diff.js +39 -10
  37. package/dist/helper/expect/error.js +62 -30
  38. package/dist/helper/expect/placeholder.js +47 -21
  39. package/dist/helper/expect/rspack.js +35 -13
  40. package/dist/helper/expect/to-be-typeof.js +39 -7
  41. package/dist/helper/expect/to-end-with.js +40 -8
  42. package/dist/helper/expect/to-match-file-snapshot.js +103 -80
  43. package/dist/helper/hot-update/index.js +35 -4
  44. package/dist/helper/hot-update/loader.d.ts +1 -0
  45. package/dist/helper/hot-update/loader.js +39 -4
  46. package/dist/helper/hot-update/plugin.d.ts +1 -1
  47. package/dist/helper/hot-update/plugin.js +87 -74
  48. package/dist/helper/index.js +138 -24
  49. package/dist/helper/is.js +51 -10
  50. package/dist/helper/legacy/EventSourceForNode.d.ts +11 -3
  51. package/dist/helper/legacy/EventSourceForNode.js +83 -37
  52. package/dist/helper/legacy/LogTestPlugin.d.ts +2 -3
  53. package/dist/helper/legacy/LogTestPlugin.js +39 -6
  54. package/dist/helper/legacy/asModule.d.ts +3 -3
  55. package/dist/helper/legacy/asModule.js +68 -19
  56. package/dist/helper/legacy/captureStdio.d.ts +1 -2
  57. package/dist/helper/legacy/captureStdio.js +69 -29
  58. package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -2
  59. package/dist/helper/legacy/checkArrayExpectation.js +132 -121
  60. package/dist/helper/legacy/copyDiff.d.ts +1 -2
  61. package/dist/helper/legacy/copyDiff.js +86 -42
  62. package/dist/helper/legacy/createFakeWorker.d.ts +2 -3
  63. package/dist/helper/legacy/createFakeWorker.js +90 -47
  64. package/dist/helper/legacy/createLazyTestEnv.d.ts +2 -3
  65. package/dist/helper/legacy/createLazyTestEnv.js +70 -59
  66. package/dist/helper/legacy/currentScript.d.ts +2 -2
  67. package/dist/helper/legacy/currentScript.js +35 -2
  68. package/dist/helper/legacy/deprecationTracking.d.ts +1 -1
  69. package/dist/helper/legacy/deprecationTracking.js +53 -28
  70. package/dist/helper/legacy/expectSource.d.ts +3 -2
  71. package/dist/helper/legacy/expectSource.js +42 -18
  72. package/dist/helper/legacy/fakeSystem.d.ts +12 -9
  73. package/dist/helper/legacy/fakeSystem.js +68 -58
  74. package/dist/helper/legacy/findOutputFiles.d.ts +7 -2
  75. package/dist/helper/legacy/findOutputFiles.js +60 -13
  76. package/dist/helper/legacy/parseResource.d.ts +1 -1
  77. package/dist/helper/legacy/parseResource.js +36 -6
  78. package/dist/helper/legacy/regexEscape.d.ts +1 -2
  79. package/dist/helper/legacy/regexEscape.js +39 -5
  80. package/dist/helper/legacy/supportDefaultAssignment.d.ts +1 -2
  81. package/dist/helper/legacy/supportDefaultAssignment.js +40 -7
  82. package/dist/helper/legacy/supportsTextDecoder.d.ts +1 -2
  83. package/dist/helper/legacy/supportsTextDecoder.js +40 -6
  84. package/dist/helper/legacy/supportsUsing.d.ts +1 -2
  85. package/dist/helper/legacy/supportsUsing.js +40 -7
  86. package/dist/helper/legacy/urlToRelativePath.d.ts +2 -2
  87. package/dist/helper/legacy/urlToRelativePath.js +56 -7
  88. package/dist/helper/parse-modules.js +52 -42
  89. package/dist/helper/read-config-file.js +60 -18
  90. package/dist/helper/serializers.js +62 -33
  91. package/dist/helper/setup-env.js +81 -91
  92. package/dist/helper/setup-expect.js +13 -13
  93. package/dist/helper/setup-wasm.js +18 -9
  94. package/dist/helper/stringify-config.js +44 -26
  95. package/dist/helper/update-snapshot.js +35 -3
  96. package/dist/helper/util/checkSourceMap.js +119 -80
  97. package/dist/helper/util/checkStats.d.ts +1 -1
  98. package/dist/helper/util/checkStats.js +42 -17
  99. package/dist/helper/util/expectWarningFactory.d.ts +1 -2
  100. package/dist/helper/util/expectWarningFactory.js +41 -8
  101. package/dist/helper/util/filterUtil.d.ts +9 -8
  102. package/dist/helper/util/filterUtil.js +63 -23
  103. package/dist/helper/win.js +46 -7
  104. package/dist/index.js +115 -23
  105. package/dist/plugin/index.js +55 -14
  106. package/dist/plugin/lazy-compilation-test-plugin.js +55 -41
  107. package/dist/reporter/index.js +55 -14
  108. package/dist/reporter/streamed-events-reporter.js +51 -77
  109. package/dist/runner/index.js +62 -15
  110. package/dist/runner/node/index.js +365 -431
  111. package/dist/runner/web/index.js +278 -263
  112. package/dist/test/context.js +67 -41
  113. package/dist/test/creator.js +135 -167
  114. package/dist/test/debug.js +89 -58
  115. package/dist/test/tester.js +94 -74
  116. package/dist/type.d.ts +10 -9
  117. package/dist/type.js +43 -9
  118. package/package.json +24 -23
@@ -1,50 +1,81 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTreeShakingCase = createTreeShakingCase;
4
- const creator_1 = require("../test/creator");
5
- const builtin_1 = require("./builtin");
6
- const common_1 = require("./common");
7
- const creator = new creator_1.BasicCaseCreator({
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ createTreeShakingCase: ()=>createTreeShakingCase
28
+ });
29
+ const creator_js_namespaceObject = require("../test/creator.js");
30
+ const external_builtin_js_namespaceObject = require("./builtin.js");
31
+ const external_common_js_namespaceObject = require("./common.js");
32
+ const creator = new creator_js_namespaceObject.BasicCaseCreator({
8
33
  clean: true,
9
34
  describe: false,
10
- description(name, step) {
35
+ description (name, step) {
11
36
  return `${name} with newTreeshaking should match snapshot`;
12
37
  },
13
- steps: ({ name }) => [
14
- {
15
- config: async (context) => {
16
- const compiler = context.getCompiler();
17
- const options = (0, builtin_1.defaultOptions)(context);
18
- overrideOptions(context, options);
19
- compiler.setOptions(options);
20
- },
21
- compiler: async (context) => {
22
- await (0, common_1.compiler)(context, name);
23
- },
24
- build: async (context) => {
25
- await (0, common_1.build)(context, name);
26
- },
27
- run: async (env, context) => {
28
- // no need to run, just check snapshot
29
- },
30
- check: async (env, context) => {
31
- await (0, common_1.checkSnapshot)(env, context, name, 'treeshaking.snap.txt');
32
- },
33
- },
34
- ],
38
+ steps: ({ name })=>[
39
+ {
40
+ config: (context)=>{
41
+ const compiler = context.getCompiler();
42
+ const options = (0, external_builtin_js_namespaceObject.defaultOptions)(context);
43
+ overrideOptions(context, options);
44
+ compiler.setOptions(options);
45
+ },
46
+ compiler: async (context)=>{
47
+ await (0, external_common_js_namespaceObject.compiler)(context, name);
48
+ },
49
+ build: async (context)=>{
50
+ await (0, external_common_js_namespaceObject.build)(context, name);
51
+ },
52
+ run: async (env, context)=>{},
53
+ check: async (env, context)=>{
54
+ await (0, external_common_js_namespaceObject.checkSnapshot)(env, context, name, 'treeshaking.snap.txt');
55
+ }
56
+ }
57
+ ]
35
58
  });
36
59
  function createTreeShakingCase(name, src, dist) {
37
60
  creator.create(name, src, dist);
38
61
  }
39
62
  function overrideOptions(context, options) {
40
- options.target = options.target || ['web', 'es2022'];
63
+ options.target = options.target || [
64
+ 'web',
65
+ 'es2022'
66
+ ];
41
67
  options.optimization ??= {};
42
68
  options.optimization.providedExports = true;
43
69
  options.optimization.innerGraph = true;
44
70
  options.optimization.usedExports = true;
45
- if (!global.printLogger) {
46
- options.infrastructureLogging = {
47
- level: 'error',
48
- };
49
- }
71
+ if (!global.printLogger) options.infrastructureLogging = {
72
+ level: 'error'
73
+ };
50
74
  }
75
+ exports.createTreeShakingCase = __webpack_exports__.createTreeShakingCase;
76
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
77
+ "createTreeShakingCase"
78
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
79
+ Object.defineProperty(exports, '__esModule', {
80
+ value: true
81
+ });
@@ -1,28 +1,12 @@
1
- import type { ITestContext, ITestEnv, ITestRunner } from '../type';
1
+ import type { ITestContext, ITestEnv, ITestProcessor, 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
- }): {
6
- before: (context: ITestContext) => Promise<void>;
7
- config: (context: ITestContext) => Promise<void>;
8
- compiler: (context: ITestContext) => Promise<void>;
9
- build: (context: ITestContext) => Promise<void>;
10
- run: (env: ITestEnv, context: ITestContext) => Promise<void>;
11
- check: (env: ITestEnv, context: ITestContext) => Promise<void>;
12
- after: (context: ITestContext) => Promise<void>;
13
- };
5
+ }): ITestProcessor;
14
6
  export declare function createWatchStepProcessor(name: string, tempDir: string, step: string, watchState: Record<string, any>, { incremental, nativeWatcher }?: {
15
7
  incremental?: boolean | undefined;
16
8
  nativeWatcher?: boolean | undefined;
17
- }): {
18
- before: (context: ITestContext) => Promise<void>;
19
- config: (context: ITestContext) => Promise<void>;
20
- compiler: (context: ITestContext) => Promise<void>;
21
- build: (context: ITestContext) => Promise<void>;
22
- run: (env: ITestEnv, context: ITestContext) => Promise<void>;
23
- check: (env: ITestEnv, context: ITestContext) => Promise<void>;
24
- after: (context: ITestContext) => Promise<void>;
25
- };
9
+ }): ITestProcessor;
26
10
  export declare function createWatchCase(name: string, src: string, dist: string, temp: string): void;
27
11
  export declare function getWatchRunnerKey(context: ITestContext, name: string, file: string): string;
28
12
  export declare function createWatchRunner(context: ITestContext, name: string, file: string, env: ITestEnv): ITestRunner;