@rspack/test-tools 2.0.2 → 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 +136 -122
  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 +21 -20
@@ -1,57 +1,88 @@
1
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.createBuiltinCase = createBuiltinCase;
7
- exports.defaultOptions = defaultOptions;
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const fs_extra_1 = __importDefault(require("fs-extra"));
10
- const rspack_merge_1 = require("rspack-merge");
11
- const helper_1 = require("../helper");
12
- const creator_1 = require("../test/creator");
13
- const common_1 = require("./common");
14
- const creator = new creator_1.BasicCaseCreator({
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ createBuiltinCase: ()=>createBuiltinCase,
37
+ defaultOptions: ()=>builtin_defaultOptions
38
+ });
39
+ const external_node_path_namespaceObject = require("node:path");
40
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
41
+ const external_fs_extra_namespaceObject = require("fs-extra");
42
+ var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
43
+ const external_rspack_merge_namespaceObject = require("rspack-merge");
44
+ const index_js_namespaceObject = require("../helper/index.js");
45
+ const creator_js_namespaceObject = require("../test/creator.js");
46
+ const external_common_js_namespaceObject = require("./common.js");
47
+ const creator = new creator_js_namespaceObject.BasicCaseCreator({
15
48
  clean: true,
16
49
  describe: false,
17
- description(name) {
50
+ description (name) {
18
51
  return `${name} should match snapshot`;
19
52
  },
20
- steps: ({ name, src }) => {
21
- const cat = node_path_1.default.basename(node_path_1.default.dirname(src));
53
+ steps: ({ name, src })=>{
54
+ const cat = external_node_path_default().basename(external_node_path_default().dirname(src));
22
55
  const filter = FILTERS[cat];
23
56
  return [
24
57
  {
25
- config: async (context) => {
58
+ config: (context)=>{
26
59
  const compiler = context.getCompiler();
27
- compiler.setOptions(defaultOptions(context));
60
+ compiler.setOptions(builtin_defaultOptions(context));
28
61
  },
29
- compiler: async (context) => {
30
- await (0, common_1.compiler)(context, name);
62
+ compiler: async (context)=>{
63
+ await (0, external_common_js_namespaceObject.compiler)(context, name);
31
64
  },
32
- build: async (context) => {
33
- await (0, common_1.build)(context, name);
65
+ build: async (context)=>{
66
+ await (0, external_common_js_namespaceObject.build)(context, name);
34
67
  },
35
- run: async (env, context) => {
36
- // no need to run, just check snapshot
37
- },
38
- check: async (env, context) => {
39
- await (0, common_1.checkSnapshot)(env, context, name, 'output.snap.txt', filter);
40
- },
41
- },
68
+ run: async (env, context)=>{},
69
+ check: async (env, context)=>{
70
+ await (0, external_common_js_namespaceObject.checkSnapshot)(env, context, name, 'output.snap.txt', filter);
71
+ }
72
+ }
42
73
  ];
43
74
  },
44
- concurrent: true,
75
+ concurrent: true
45
76
  });
46
77
  function createBuiltinCase(name, src, dist) {
47
78
  creator.create(name, src, dist);
48
79
  }
49
- function defaultOptions(context) {
80
+ function builtin_defaultOptions(context) {
50
81
  let defaultOptions = {
51
82
  entry: {
52
83
  main: {
53
- import: './index',
54
- },
84
+ import: './index'
85
+ }
55
86
  },
56
87
  output: {
57
88
  publicPath: '/',
@@ -66,7 +97,9 @@ function defaultOptions(context) {
66
97
  chunkLoadingGlobal: 'rspackChunk',
67
98
  chunkLoading: 'jsonp',
68
99
  uniqueName: '__rspack_test__',
69
- enabledLibraryTypes: ['system'],
100
+ enabledLibraryTypes: [
101
+ 'system'
102
+ ],
70
103
  strictModuleErrorHandling: false,
71
104
  iife: true,
72
105
  module: false,
@@ -76,48 +109,48 @@ function defaultOptions(context) {
76
109
  importFunctionName: 'import',
77
110
  wasmLoading: 'fetch',
78
111
  webassemblyModuleFilename: '[hash].module.wasm',
79
- workerChunkLoading: 'import-scripts',
112
+ workerChunkLoading: "import-scripts",
80
113
  workerWasmLoading: 'fetch',
81
114
  bundlerInfo: {
82
- force: false,
83
- },
115
+ force: false
116
+ }
84
117
  },
85
118
  module: {
86
119
  rules: [
87
120
  {
88
121
  test: /\.json$/,
89
- type: 'json',
122
+ type: 'json'
90
123
  },
91
124
  {
92
125
  test: /\.mjs$/,
93
- type: 'javascript/esm',
126
+ type: "javascript/esm"
94
127
  },
95
128
  {
96
129
  test: /\.cjs$/,
97
- type: 'javascript/dynamic',
130
+ type: "javascript/dynamic"
98
131
  },
99
132
  {
100
133
  test: /\.js$/,
101
- type: 'javascript/auto',
134
+ type: "javascript/auto"
102
135
  },
103
136
  {
104
137
  test: /\.css$/,
105
- type: 'css',
138
+ type: 'css'
106
139
  },
107
140
  {
108
141
  test: /\.wasm$/,
109
- type: 'webassembly/async',
110
- },
111
- ],
142
+ type: 'webassembly/async'
143
+ }
144
+ ]
112
145
  },
113
146
  node: {
114
147
  __dirname: 'mock',
115
148
  __filename: 'mock',
116
- global: 'warn',
149
+ global: 'warn'
117
150
  },
118
151
  optimization: {
119
152
  runtimeChunk: {
120
- name: 'runtime',
153
+ name: 'runtime'
121
154
  },
122
155
  minimize: false,
123
156
  removeEmptyChunks: true,
@@ -128,7 +161,7 @@ function defaultOptions(context) {
128
161
  inlineExports: false,
129
162
  usedExports: false,
130
163
  concatenateModules: false,
131
- nodeEnv: false,
164
+ nodeEnv: false
132
165
  },
133
166
  resolve: {
134
167
  extensions: [
@@ -139,36 +172,43 @@ function defaultOptions(context) {
139
172
  '.json',
140
173
  '.d.ts',
141
174
  '.css',
142
- '.wasm',
143
- ],
175
+ '.wasm'
176
+ ]
144
177
  },
145
178
  resolveLoader: {
146
- extensions: ['.js'],
179
+ extensions: [
180
+ '.js'
181
+ ]
147
182
  },
148
183
  experiments: {
149
- futureDefaults: true,
184
+ futureDefaults: true
150
185
  },
151
186
  devtool: false,
152
187
  context: context.getSource(),
153
- plugins: [],
188
+ plugins: []
154
189
  };
155
190
  const testConfigFile = context.getSource('rspack.config.js');
156
- if (fs_extra_1.default.existsSync(testConfigFile)) {
191
+ if (external_fs_extra_default().existsSync(testConfigFile)) {
157
192
  const caseOptions = require(testConfigFile);
158
- if (caseOptions.entry) {
159
- delete defaultOptions.entry;
160
- }
161
- defaultOptions = (0, rspack_merge_1.merge)(defaultOptions, caseOptions);
162
- }
163
- if (!global.printLogger) {
164
- defaultOptions.infrastructureLogging = {
165
- level: 'error',
166
- };
193
+ if (caseOptions.entry) delete defaultOptions.entry;
194
+ defaultOptions = (0, external_rspack_merge_namespaceObject.merge)(defaultOptions, caseOptions);
167
195
  }
196
+ if (!global.printLogger) defaultOptions.infrastructureLogging = {
197
+ level: 'error'
198
+ };
168
199
  return defaultOptions;
169
200
  }
170
201
  const FILTERS = {
171
- 'plugin-css': (file) => file.endsWith('.css'),
172
- 'plugin-css-modules': (file) => file.endsWith('.css') || ((0, helper_1.isJavaScript)(file) && !file.includes('runtime')),
173
- 'plugin-html': (file) => file.endsWith('.html'),
202
+ 'plugin-css': (file)=>file.endsWith('.css'),
203
+ 'plugin-css-modules': (file)=>file.endsWith('.css') || (0, index_js_namespaceObject.isJavaScript)(file) && !file.includes('runtime'),
204
+ 'plugin-html': (file)=>file.endsWith('.html')
174
205
  };
206
+ exports.createBuiltinCase = __webpack_exports__.createBuiltinCase;
207
+ exports.defaultOptions = __webpack_exports__.defaultOptions;
208
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
209
+ "createBuiltinCase",
210
+ "defaultOptions"
211
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
212
+ Object.defineProperty(exports, '__esModule', {
213
+ value: true
214
+ });
@@ -1,75 +1,102 @@
1
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.createCacheCase = createCacheCase;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const core_1 = __importDefault(require("@rspack/core"));
9
- const helper_1 = require("../helper");
10
- const placeholder_1 = require("../helper/expect/placeholder");
11
- const hot_update_1 = require("../helper/hot-update");
12
- const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
13
- const runner_1 = require("../runner");
14
- const creator_1 = require("../test/creator");
15
- const common_1 = require("./common");
16
- const runner_2 = require("./runner");
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ createCacheCase: ()=>createCacheCase
37
+ });
38
+ const external_node_path_namespaceObject = require("node:path");
39
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
40
+ const core_namespaceObject = require("@rspack/core");
41
+ var core_default = /*#__PURE__*/ __webpack_require__.n(core_namespaceObject);
42
+ const index_js_namespaceObject = require("../helper/index.js");
43
+ const placeholder_js_namespaceObject = require("../helper/expect/placeholder.js");
44
+ const hot_update_index_js_namespaceObject = require("../helper/hot-update/index.js");
45
+ const checkArrayExpectation_js_namespaceObject = require("../helper/legacy/checkArrayExpectation.js");
46
+ const external_runner_index_js_namespaceObject = require("../runner/index.js");
47
+ const creator_js_namespaceObject = require("../test/creator.js");
48
+ const external_common_js_namespaceObject = require("./common.js");
49
+ const external_runner_js_namespaceObject = require("./runner.js");
17
50
  function createCacheProcessor(name, src, temp, target) {
18
- const updatePlugin = new hot_update_1.HotUpdatePlugin(src, temp);
51
+ const updatePlugin = new hot_update_index_js_namespaceObject.HotUpdatePlugin(src, temp);
19
52
  return {
20
- before: async (context) => {
53
+ before: async (context)=>{
21
54
  await updatePlugin.initialize();
22
55
  context.setValue('hotUpdateContext', updatePlugin);
23
56
  },
24
- config: async (context) => {
57
+ config: async (context)=>{
25
58
  const compiler = context.getCompiler();
26
59
  const options = await generateOptions(context, temp, target, updatePlugin);
27
60
  compiler.setOptions(options);
28
61
  },
29
- compiler: async (context) => {
30
- await (0, common_1.compiler)(context, name);
62
+ compiler: async (context)=>{
63
+ await (0, external_common_js_namespaceObject.compiler)(context, name);
31
64
  },
32
- build: async (context) => {
33
- await (0, common_1.build)(context, name);
65
+ build: async (context)=>{
66
+ await (0, external_common_js_namespaceObject.build)(context, name);
34
67
  },
35
- run: async (env, context) => {
36
- await (0, common_1.run)(env, context, name, (context) => findBundle(name, target, context));
68
+ run: async (env, context)=>{
69
+ await (0, external_common_js_namespaceObject.run)(env, context, name, (context)=>findBundle(name, target, context));
37
70
  },
38
- check: async (env, context) => {
39
- await (0, common_1.check)(env, context, name);
71
+ check: async (env, context)=>{
72
+ await (0, external_common_js_namespaceObject.check)(env, context, name);
40
73
  const stats = context.getCompiler().getStats();
41
- if (stats) {
42
- matchStatsSnapshot(env, context.getSource(), updatePlugin.getUpdateIndex(), stats);
43
- }
74
+ if (stats) matchStatsSnapshot(env, context.getSource(), updatePlugin.getUpdateIndex(), stats);
44
75
  },
45
- after: async (context) => {
46
- await (0, common_1.afterExecute)(context, name);
76
+ after: async (context)=>{
77
+ await (0, external_common_js_namespaceObject.afterExecute)(context, name);
47
78
  },
48
- afterAll: async (context) => {
79
+ afterAll: (context)=>{
49
80
  const updateIndex = updatePlugin.getUpdateIndex();
50
81
  const totalUpdates = updatePlugin.getTotalUpdates();
51
- if (updateIndex + 1 !== totalUpdates) {
52
- throw new Error(`Should run all hot steps (${updateIndex + 1} / ${totalUpdates}): ${name}`);
53
- }
54
- },
82
+ if (updateIndex + 1 !== totalUpdates) throw new Error(`Should run all hot steps (${updateIndex + 1} / ${totalUpdates}): ${name}`);
83
+ }
55
84
  };
56
85
  }
57
86
  function getCreator(target) {
58
- if (!creators.has(target)) {
59
- creators.set(target, new creator_1.BasicCaseCreator({
60
- clean: true,
61
- describe: true,
62
- target,
63
- steps: ({ name, src, target, temp }) => [
64
- createCacheProcessor(name, src, temp, target),
87
+ if (!creators.has(target)) creators.set(target, new creator_js_namespaceObject.BasicCaseCreator({
88
+ clean: true,
89
+ describe: true,
90
+ target,
91
+ steps: ({ name, src, target, temp })=>[
92
+ createCacheProcessor(name, src, temp, target)
65
93
  ],
66
- runner: {
67
- key: (context, name, file) => name,
68
- runner: createRunner,
69
- },
70
- concurrent: true,
71
- }));
72
- }
94
+ runner: {
95
+ key: (context, name, file)=>name,
96
+ runner: createRunner
97
+ },
98
+ concurrent: true
99
+ }));
73
100
  return creators.get(target);
74
101
  }
75
102
  function createCacheCase(name, src, dist, target, temp) {
@@ -78,17 +105,13 @@ function createCacheCase(name, src, dist, target, temp) {
78
105
  }
79
106
  const creators = new Map();
80
107
  function matchStatsSnapshot(env, source, updateIndex, stats) {
81
- const content = (0, placeholder_1.normalizePlaceholder)(stats.toString({
108
+ const content = (0, placeholder_js_namespaceObject.normalizePlaceholder)(stats.toString({
82
109
  all: false,
83
110
  logging: 'info',
84
- colors: false,
111
+ colors: false
85
112
  })).trim();
86
- if (!content.includes('rspack.persistentCache')) {
87
- return;
88
- }
89
- env
90
- .expect(content)
91
- .toMatchFileSnapshotSync(node_path_1.default.resolve(source, '__snapshots__', `stats-${updateIndex}.txt`));
113
+ if (!content.includes('rspack.persistentCache')) return;
114
+ env.expect(content).toMatchFileSnapshotSync(external_node_path_default().resolve(source, '__snapshots__', `stats-${updateIndex}.txt`));
92
115
  }
93
116
  async function generateOptions(context, temp, target, updatePlugin) {
94
117
  let options = {
@@ -100,70 +123,65 @@ async function generateOptions(context, temp, target, updatePlugin) {
100
123
  filename: 'bundle.js',
101
124
  chunkFilename: '[name].chunk.[fullhash].js',
102
125
  publicPath: 'https://test.cases/path/',
103
- library: { type: 'commonjs2' },
104
- bundlerInfo: {
105
- force: false,
126
+ library: {
127
+ type: 'commonjs2'
106
128
  },
129
+ bundlerInfo: {
130
+ force: false
131
+ }
107
132
  },
108
133
  optimization: {
109
134
  moduleIds: 'named',
110
- emitOnErrors: true,
135
+ emitOnErrors: true
111
136
  },
112
- target,
137
+ target
113
138
  };
114
139
  options.plugins ??= [];
115
- options.plugins.push(new core_1.default.HotModuleReplacementPlugin());
116
- options = await (0, common_1.config)(context, 'cacheCase', ['rspack.config.js', 'webpack.config.js'].map((i) => node_path_1.default.resolve(temp, i)), options);
117
- // overwrite
118
- if (!options.entry) {
119
- options.entry = './index.js';
120
- }
121
- // rewrite context to temp dir
140
+ options.plugins.push(new (core_default()).HotModuleReplacementPlugin());
141
+ options = await (0, external_common_js_namespaceObject.config)(context, 'cacheCase', [
142
+ 'rspack.config.js',
143
+ 'webpack.config.js'
144
+ ].map((i)=>external_node_path_default().resolve(temp, i)), options);
145
+ if (!options.entry) options.entry = './index.js';
122
146
  options.context = temp;
123
147
  options.module ??= {};
124
- for (const cssModuleType of ['css/auto', 'css/module', 'css']) {
148
+ for (const cssModuleType of [
149
+ 'css/auto',
150
+ 'css/module',
151
+ 'css'
152
+ ]){
125
153
  options.module.generator ??= {};
126
154
  options.module.generator[cssModuleType] ??= {};
127
- options.module.generator[cssModuleType].exportsOnly ??=
128
- target === 'async-node';
155
+ options.module.generator[cssModuleType].exportsOnly ??= 'async-node' === target;
129
156
  }
130
157
  options.plugins ??= [];
131
158
  options.plugins.push(updatePlugin);
132
- if (!global.printLogger) {
133
- options.infrastructureLogging = {
134
- level: 'error',
135
- };
136
- }
159
+ if (!global.printLogger) options.infrastructureLogging = {
160
+ level: 'error'
161
+ };
137
162
  return options;
138
163
  }
139
164
  function findBundle(name, target, context) {
140
165
  const files = [];
141
166
  const prefiles = [];
142
167
  const compiler = context.getCompiler();
143
- if (!compiler)
144
- throw new Error('Compiler should exists when find bundle');
168
+ if (!compiler) throw new Error('Compiler should exists when find bundle');
145
169
  const stats = compiler.getStats();
146
- if (!stats)
147
- throw new Error('Stats should exists when find bundle');
170
+ if (!stats) throw new Error('Stats should exists when find bundle');
148
171
  const info = stats.toJson({
149
172
  all: false,
150
- entrypoints: true,
173
+ entrypoints: true
151
174
  });
152
- if (target === 'web' || target === 'webworker') {
153
- for (const file of info.entrypoints.main.assets) {
154
- if ((0, helper_1.isJavaScript)(file.name)) {
155
- files.push(file.name);
156
- }
157
- else {
158
- prefiles.push(file.name);
159
- }
160
- }
161
- }
175
+ if ('web' === target || 'webworker' === target) for (const file of info.entrypoints.main.assets)if ((0, index_js_namespaceObject.isJavaScript)(file.name)) files.push(file.name);
176
+ else prefiles.push(file.name);
162
177
  else {
163
- const assets = info.entrypoints.main.assets.filter((s) => (0, helper_1.isJavaScript)(s.name));
178
+ const assets = info.entrypoints.main.assets.filter((s)=>(0, index_js_namespaceObject.isJavaScript)(s.name));
164
179
  files.push(assets[assets.length - 1].name);
165
180
  }
166
- return [...prefiles, ...files];
181
+ return [
182
+ ...prefiles,
183
+ ...files
184
+ ];
167
185
  }
168
186
  function createRunner(context, name, file, env) {
169
187
  const compiler = context.getCompiler();
@@ -173,32 +191,28 @@ function createRunner(context, name, file, env) {
173
191
  const source = context.getSource();
174
192
  const dist = context.getDist();
175
193
  const updatePlugin = context.getValue('hotUpdateContext');
176
- const getWebRunner = () => {
177
- return new runner_1.NodeRunner({
194
+ const getWebRunner = ()=>new external_runner_index_js_namespaceObject.NodeRunner({
178
195
  env,
179
- stats: (0, runner_2.cachedStats)(context, name),
196
+ stats: (0, external_runner_js_namespaceObject.cachedStats)(context, name),
180
197
  cachable: false,
181
198
  name: name,
182
199
  runInNewContext: false,
183
200
  testConfig: {
184
201
  ...testConfig,
185
- moduleScope(ms, stats, options) {
186
- const moduleScope = typeof testConfig.moduleScope === 'function'
187
- ? testConfig.moduleScope(ms, stats, options)
188
- : ms;
202
+ moduleScope (ms, stats, options) {
203
+ const moduleScope = 'function' == typeof testConfig.moduleScope ? testConfig.moduleScope(ms, stats, options) : ms;
189
204
  moduleScope.COMPILER_INDEX = compilerIndex;
190
205
  moduleScope.NEXT_HMR = nextHmr;
191
206
  moduleScope.NEXT_START = nextStart;
192
207
  moduleScope.NEXT_MOVE_DIR_START = nextMoveDirStart;
193
208
  return moduleScope;
194
- },
209
+ }
195
210
  },
196
211
  source,
197
212
  dist,
198
- compilerOptions: options,
213
+ compilerOptions: options
199
214
  });
200
- };
201
- const checkStats = async (stats) => {
215
+ const checkStats = async (stats)=>{
202
216
  matchStatsSnapshot(env, source, updatePlugin.getUpdateIndex(), stats);
203
217
  const jsonStats = stats.toJson({
204
218
  assets: true,
@@ -206,38 +220,33 @@ function createRunner(context, name, file, env) {
206
220
  chunkModules: true,
207
221
  modules: true,
208
222
  entrypoints: true,
209
- chunkGroups: true,
210
- // errorDetails: true
223
+ chunkGroups: true
211
224
  });
212
225
  const compilerOptions = compiler.getOptions();
213
226
  const updateIndex = updatePlugin.getUpdateIndex();
214
- await (0, checkArrayExpectation_1.default)(source, jsonStats, 'error', `errors${updateIndex}`, 'Error', compilerOptions);
215
- await (0, checkArrayExpectation_1.default)(source, jsonStats, 'warning', `warnings${updateIndex}`, 'Warning', compilerOptions);
227
+ await (0, checkArrayExpectation_js_namespaceObject.checkArrayExpectation)(source, jsonStats, 'error', `errors${updateIndex}`, 'Error', compilerOptions);
228
+ await (0, checkArrayExpectation_js_namespaceObject.checkArrayExpectation)(source, jsonStats, 'warning', `warnings${updateIndex}`, 'Warning', compilerOptions);
216
229
  return jsonStats;
217
230
  };
218
- const nextHmr = async (m, options) => {
231
+ const nextHmr = async (m, options)=>{
219
232
  await updatePlugin.goNext();
220
233
  const stats = await compiler.build();
221
234
  const jsonStats = await checkStats(stats);
222
235
  const updatedModules = await m.hot.check(options || true);
223
- if (!updatedModules) {
224
- throw new Error('No update available');
225
- }
236
+ if (!updatedModules) throw new Error('No update available');
226
237
  return jsonStats;
227
238
  };
228
- const nextStart = async () => {
239
+ const nextStart = async ()=>{
229
240
  await compiler.close();
230
241
  await updatePlugin.goNext();
231
242
  compilerIndex++;
232
243
  compiler.createCompiler();
233
244
  const stats = await compiler.build();
234
245
  const jsonStats = await checkStats(stats);
235
- env.it(`NEXT_START run with compilerIndex==${compilerIndex}`, async () => {
236
- return getWebRunner().run(file);
237
- });
246
+ env.it(`NEXT_START run with compilerIndex==${compilerIndex}`, async ()=>getWebRunner().run(file));
238
247
  return jsonStats;
239
248
  };
240
- const nextMoveDirStart = async () => {
249
+ const nextMoveDirStart = async ()=>{
241
250
  await compiler.close();
242
251
  const tempDir = await updatePlugin.moveTempDir();
243
252
  const options = await generateOptions(context, tempDir, compiler.getOptions().target, updatePlugin);
@@ -247,10 +256,15 @@ function createRunner(context, name, file, env) {
247
256
  compiler.createCompiler();
248
257
  const stats = await compiler.build();
249
258
  const jsonStats = await checkStats(stats);
250
- env.it(`NEXT_MOVE_DIR_START run with compilerIndex==${compilerIndex}`, async () => {
251
- return getWebRunner().run(file);
252
- });
259
+ env.it(`NEXT_MOVE_DIR_START run with compilerIndex==${compilerIndex}`, async ()=>getWebRunner().run(file));
253
260
  return jsonStats;
254
261
  };
255
262
  return getWebRunner();
256
263
  }
264
+ exports.createCacheCase = __webpack_exports__.createCacheCase;
265
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
266
+ "createCacheCase"
267
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
268
+ Object.defineProperty(exports, '__esModule', {
269
+ value: true
270
+ });
@@ -1,11 +1,11 @@
1
1
  import type { Compiler, RspackOptions } from '@rspack/core';
2
2
  import type { ITestContext, ITestEnv } from '../type';
3
- export declare function config(context: ITestContext, name: string, configFiles: string[], defaultOptions?: RspackOptions): Promise<RspackOptions>;
4
- export declare function compiler(context: ITestContext, name: string): Promise<Compiler>;
3
+ export declare function config(context: ITestContext, name: string, configFiles: string[], defaultOptions?: RspackOptions): RspackOptions;
4
+ export declare function compiler(context: ITestContext, name: string): Compiler;
5
5
  export declare function build(context: ITestContext, name: string): Promise<Compiler>;
6
6
  export declare function run(env: ITestEnv, context: ITestContext, name: string, findBundle: (context: ITestContext, options: RspackOptions) => string[] | string | void): Promise<void>;
7
7
  export declare function check(env: ITestEnv, context: ITestContext, name: string): Promise<void>;
8
- export declare function checkSnapshot(env: ITestEnv, context: ITestContext, name: string, snapshot: string, filter?: (file: string) => boolean): Promise<void>;
9
- export declare function afterExecute(context: ITestContext, name: string): Promise<void>;
8
+ export declare function checkSnapshot(env: ITestEnv, context: ITestContext, name: string, snapshot: string, filter?: (file: string) => boolean): void;
9
+ export declare function afterExecute(context: ITestContext, name: string): void;
10
10
  export declare function findMultiCompilerBundle(context: ITestContext, name: string, multiFindBundle: (index: number, context: ITestContext, options: RspackOptions) => string[] | string | void): string[];
11
11
  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;