@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
package/dist/case/hot.js CHANGED
@@ -1,84 +1,112 @@
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.createHotProcessor = createHotProcessor;
7
- exports.createHotCase = createHotCase;
8
- exports.createHotRunner = createHotRunner;
9
- const node_path_1 = __importDefault(require("node:path"));
10
- const core_1 = __importDefault(require("@rspack/core"));
11
- const helper_1 = require("../helper");
12
- const plugin_1 = require("../helper/hot-update/plugin");
13
- const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
14
- const plugin_2 = require("../plugin");
15
- const runner_1 = require("../runner");
16
- const creator_1 = require("../test/creator");
17
- const common_1 = require("./common");
18
- 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
+ createHotCase: ()=>createHotCase,
37
+ createHotProcessor: ()=>createHotProcessor,
38
+ createHotRunner: ()=>createHotRunner
39
+ });
40
+ const external_node_path_namespaceObject = require("node:path");
41
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
42
+ const core_namespaceObject = require("@rspack/core");
43
+ var core_default = /*#__PURE__*/ __webpack_require__.n(core_namespaceObject);
44
+ const index_js_namespaceObject = require("../helper/index.js");
45
+ const plugin_js_namespaceObject = require("../helper/hot-update/plugin.js");
46
+ const checkArrayExpectation_js_namespaceObject = require("../helper/legacy/checkArrayExpectation.js");
47
+ const external_plugin_index_js_namespaceObject = require("../plugin/index.js");
48
+ const external_runner_index_js_namespaceObject = require("../runner/index.js");
49
+ const creator_js_namespaceObject = require("../test/creator.js");
50
+ const external_common_js_namespaceObject = require("./common.js");
51
+ const external_runner_js_namespaceObject = require("./runner.js");
19
52
  const creators = new Map();
20
53
  function createHotProcessor(name, src, temp, target, incremental = false) {
21
- const updatePlugin = new plugin_1.HotUpdatePlugin(src, temp);
54
+ const updatePlugin = new plugin_js_namespaceObject.HotUpdatePlugin(src, temp);
22
55
  const processor = {
23
- before: async (context) => {
56
+ before: async (context)=>{
24
57
  await updatePlugin.initialize();
25
58
  context.setValue('hotUpdatePlugin', updatePlugin);
26
59
  },
27
- config: async (context) => {
60
+ config: async (context)=>{
28
61
  const compiler = context.getCompiler();
29
62
  let options = defaultOptions(context, target);
30
- options = await (0, common_1.config)(context, name, ['rspack.config.js', 'webpack.config.js'], options);
63
+ options = await (0, external_common_js_namespaceObject.config)(context, name, [
64
+ 'rspack.config.js',
65
+ 'webpack.config.js'
66
+ ], options);
31
67
  overrideOptions(context, options, target, updatePlugin);
32
- if (incremental) {
33
- options.incremental ??= 'advance-silent';
34
- }
68
+ if (incremental) options.incremental ??= 'advance-silent';
35
69
  compiler.setOptions(options);
36
70
  },
37
- compiler: async (context) => {
38
- await (0, common_1.compiler)(context, name);
71
+ compiler: async (context)=>{
72
+ await (0, external_common_js_namespaceObject.compiler)(context, name);
39
73
  },
40
- build: async (context) => {
41
- await (0, common_1.build)(context, name);
74
+ build: async (context)=>{
75
+ await (0, external_common_js_namespaceObject.build)(context, name);
42
76
  },
43
- run: async (env, context) => {
44
- await (0, common_1.run)(env, context, name, (context) => findBundle(context, name, target, updatePlugin));
77
+ run: async (env, context)=>{
78
+ await (0, external_common_js_namespaceObject.run)(env, context, name, (context)=>findBundle(context, name, target, updatePlugin));
45
79
  },
46
- check: async (env, context) => {
47
- await (0, common_1.check)(env, context, name);
80
+ check: async (env, context)=>{
81
+ await (0, external_common_js_namespaceObject.check)(env, context, name);
48
82
  },
49
- after: async (context) => {
50
- await (0, common_1.afterExecute)(context, name);
83
+ after: async (context)=>{
84
+ await (0, external_common_js_namespaceObject.afterExecute)(context, name);
51
85
  },
52
- afterAll: async (context) => {
53
- if (context.getTestConfig().checkSteps === false) {
54
- return;
55
- }
86
+ afterAll: (context)=>{
87
+ if (false === context.getTestConfig().checkSteps) return;
56
88
  const updateIndex = updatePlugin.getUpdateIndex();
57
89
  const totalUpdates = updatePlugin.getTotalUpdates();
58
- if (updateIndex + 1 !== totalUpdates) {
59
- throw new Error(`Should run all hot steps (${updateIndex + 1} / ${totalUpdates}): ${name}`);
60
- }
61
- },
90
+ if (updateIndex + 1 !== totalUpdates) throw new Error(`Should run all hot steps (${updateIndex + 1} / ${totalUpdates}): ${name}`);
91
+ }
62
92
  };
63
93
  processor.updatePlugin = updatePlugin;
64
94
  return processor;
65
95
  }
66
96
  function getCreator(target) {
67
- if (!creators.has(target)) {
68
- creators.set(target, new creator_1.BasicCaseCreator({
69
- clean: true,
70
- describe: true,
71
- target,
72
- steps: ({ name, target, src, dist, temp }) => [
73
- createHotProcessor(name, src, temp || node_path_1.default.resolve(dist, 'temp'), target),
97
+ if (!creators.has(target)) creators.set(target, new creator_js_namespaceObject.BasicCaseCreator({
98
+ clean: true,
99
+ describe: true,
100
+ target,
101
+ steps: ({ name, target, src, dist, temp })=>[
102
+ createHotProcessor(name, src, temp || external_node_path_default().resolve(dist, 'temp'), target)
74
103
  ],
75
- runner: {
76
- key: (context, name, file) => name,
77
- runner: createHotRunner,
78
- },
79
- concurrent: true,
80
- }));
81
- }
104
+ runner: {
105
+ key: (context, name, file)=>name,
106
+ runner: createHotRunner
107
+ },
108
+ concurrent: true
109
+ }));
82
110
  return creators.get(target);
83
111
  }
84
112
  function createHotCase(name, src, dist, temp, target) {
@@ -95,82 +123,74 @@ function defaultOptions(context, target) {
95
123
  filename: 'bundle.js',
96
124
  chunkFilename: '[name].chunk.[fullhash].js',
97
125
  publicPath: 'https://test.cases/path/',
98
- library: { type: 'commonjs2' },
99
- bundlerInfo: {
100
- force: false,
126
+ library: {
127
+ type: 'commonjs2'
101
128
  },
129
+ bundlerInfo: {
130
+ force: false
131
+ }
102
132
  },
103
133
  module: {
104
134
  defaultRules: [
105
135
  '...',
106
136
  {
107
137
  test: /\.css$/i,
108
- type: 'css/auto',
109
- },
110
- ],
138
+ type: 'css/auto'
139
+ }
140
+ ]
111
141
  },
112
142
  optimization: {
113
- moduleIds: 'named',
143
+ moduleIds: 'named'
114
144
  },
115
145
  target,
116
- // test incremental: "safe" here, we test default incremental in Incremental-*.test.js
117
- incremental: 'safe',
146
+ incremental: 'safe'
118
147
  };
119
148
  options.plugins ??= [];
120
- options.plugins.push(new core_1.default.HotModuleReplacementPlugin());
149
+ options.plugins.push(new (core_default()).HotModuleReplacementPlugin());
121
150
  return options;
122
151
  }
123
152
  function overrideOptions(context, options, target, updatePlugin) {
124
- if (!options.entry) {
125
- options.entry = './index.js';
126
- }
153
+ if (!options.entry) options.entry = './index.js';
127
154
  options.module ??= {};
128
- for (const cssModuleType of ['css/auto', 'css/module', 'css']) {
155
+ for (const cssModuleType of [
156
+ 'css/auto',
157
+ 'css/module',
158
+ 'css'
159
+ ]){
129
160
  options.module.generator ??= {};
130
161
  options.module.generator[cssModuleType] ??= {};
131
- options.module.generator[cssModuleType].exportsOnly ??=
132
- target === 'async-node';
162
+ options.module.generator[cssModuleType].exportsOnly ??= 'async-node' === target;
133
163
  }
134
164
  options.plugins ??= [];
135
165
  options.plugins.push(updatePlugin);
136
- if (!global.printLogger) {
137
- options.infrastructureLogging = {
138
- level: 'error',
139
- };
140
- }
141
- if (options.lazyCompilation) {
142
- options.plugins.push(new plugin_2.LazyCompilationTestPlugin());
143
- }
166
+ if (!global.printLogger) options.infrastructureLogging = {
167
+ level: 'error'
168
+ };
169
+ if (options.lazyCompilation) options.plugins.push(new external_plugin_index_js_namespaceObject.LazyCompilationTestPlugin());
144
170
  }
145
171
  function findBundle(context, name, target, updatePlugin) {
146
172
  const compiler = context.getCompiler();
147
- if (!compiler)
148
- throw new Error('Compiler should exists when find bundle');
173
+ if (!compiler) throw new Error('Compiler should exists when find bundle');
149
174
  const testConfig = context.getTestConfig();
150
- if (typeof testConfig.findBundle === 'function') {
151
- return testConfig.findBundle(updatePlugin.getUpdateIndex(), compiler.getOptions());
152
- }
175
+ if ('function' == typeof testConfig.findBundle) return testConfig.findBundle(updatePlugin.getUpdateIndex(), compiler.getOptions());
153
176
  const files = [];
154
177
  const prefiles = [];
155
178
  const stats = compiler.getStats();
156
- if (!stats)
157
- throw new Error('Stats should exists when find bundle');
158
- const info = stats.toJson({ all: false, entrypoints: true });
159
- if (target === 'web' || target === 'webworker') {
160
- for (const file of info.entrypoints.main.assets) {
161
- if ((0, helper_1.isJavaScript)(file.name)) {
162
- files.push(file.name);
163
- }
164
- else {
165
- prefiles.push(file.name);
166
- }
167
- }
168
- }
179
+ if (!stats) throw new Error('Stats should exists when find bundle');
180
+ const info = stats.toJson({
181
+ all: false,
182
+ entrypoints: true
183
+ });
184
+ 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);
185
+ else prefiles.push(file.name);
169
186
  else {
170
- const assets = info.entrypoints.main.assets.filter((s) => (0, helper_1.isJavaScript)(s.name));
187
+ const assets = info.entrypoints.main.assets.filter((s)=>(0, index_js_namespaceObject.isJavaScript)(s.name));
171
188
  files.push(assets[assets.length - 1].name);
172
189
  }
173
- return [...prefiles, ...files];
190
+ return [
191
+ ...prefiles,
192
+ ...files
193
+ ];
174
194
  }
175
195
  function createHotRunner(context, name, file, env) {
176
196
  const compiler = context.getCompiler();
@@ -179,67 +199,61 @@ function createHotRunner(context, name, file, env) {
179
199
  const source = context.getSource();
180
200
  const dist = context.getDist();
181
201
  const updatePlugin = context.getValue('hotUpdatePlugin');
182
- const nextHMR = async (m, options) => {
202
+ const nextHMR = async (m, options)=>{
183
203
  await updatePlugin.goNext();
184
204
  const stats = await compiler.build();
185
- if (!stats) {
186
- throw new Error('Should generate stats during build');
187
- }
205
+ if (!stats) throw new Error('Should generate stats during build');
188
206
  const jsonStats = stats.toJson({
189
207
  assets: true,
190
208
  chunks: true,
191
209
  chunkModules: true,
192
210
  modules: true,
193
211
  entrypoints: true,
194
- chunkGroups: true,
195
- // errorDetails: true
212
+ chunkGroups: true
196
213
  });
197
214
  const compilerOptions = compiler.getOptions();
198
- const checker = context.getValue(jsonStats.errors?.length
199
- ? 'hotUpdateStepErrorChecker'
200
- : 'hotUpdateStepChecker');
201
- if (checker) {
202
- checker(updatePlugin.getUpdateIndex(), stats, runner.getGlobal('__HMR_UPDATED_RUNTIME__'));
203
- }
204
- await (0, checkArrayExpectation_1.default)(source, jsonStats, 'error', `errors${updatePlugin.getUpdateIndex()}`, 'Error', compilerOptions);
205
- await (0, checkArrayExpectation_1.default)(source, jsonStats, 'warning', `warnings${updatePlugin.getUpdateIndex()}`, 'Warning', compilerOptions);
215
+ const checker = context.getValue(jsonStats.errors?.length ? 'hotUpdateStepErrorChecker' : 'hotUpdateStepChecker');
216
+ if (checker) checker(updatePlugin.getUpdateIndex(), stats, runner.getGlobal('__HMR_UPDATED_RUNTIME__'));
217
+ await (0, checkArrayExpectation_js_namespaceObject.checkArrayExpectation)(source, jsonStats, 'error', `errors${updatePlugin.getUpdateIndex()}`, 'Error', compilerOptions);
218
+ await (0, checkArrayExpectation_js_namespaceObject.checkArrayExpectation)(source, jsonStats, 'warning', `warnings${updatePlugin.getUpdateIndex()}`, 'Warning', compilerOptions);
206
219
  const updatedModules = await m.hot.check(options || true);
207
- if (!updatedModules) {
208
- throw new Error('No update available');
209
- }
220
+ if (!updatedModules) throw new Error('No update available');
210
221
  return jsonStats;
211
222
  };
212
223
  const commonOptions = {
213
224
  env,
214
- stats: (0, runner_2.cachedStats)(context, name),
225
+ stats: (0, external_runner_js_namespaceObject.cachedStats)(context, name),
215
226
  name: name,
216
227
  runInNewContext: false,
217
228
  testConfig: {
218
229
  ...testConfig,
219
- moduleScope(ms, stats, options) {
230
+ moduleScope (ms, stats, options) {
220
231
  const moduleScope = ms;
221
- if (typeof testConfig.moduleScope === 'function') {
222
- testConfig.moduleScope(moduleScope, stats, compilerOptions);
223
- }
232
+ if ('function' == typeof testConfig.moduleScope) testConfig.moduleScope(moduleScope, stats, compilerOptions);
224
233
  moduleScope.NEXT_HMR = nextHMR;
225
234
  return moduleScope;
226
- },
235
+ }
227
236
  },
228
237
  cachable: true,
229
238
  source,
230
239
  dist,
231
- compilerOptions,
240
+ compilerOptions
232
241
  };
233
242
  let runner;
234
- if (compilerOptions.target === 'web' ||
235
- compilerOptions.target === 'webworker') {
236
- runner = new runner_1.WebRunner({
237
- location: testConfig.location || 'https://test.cases/path/index.html',
238
- ...commonOptions,
239
- });
240
- }
241
- else {
242
- runner = new runner_1.NodeRunner(commonOptions);
243
- }
243
+ runner = 'web' === compilerOptions.target || 'webworker' === compilerOptions.target ? new external_runner_index_js_namespaceObject.WebRunner({
244
+ location: testConfig.location || 'https://test.cases/path/index.html',
245
+ ...commonOptions
246
+ }) : new external_runner_index_js_namespaceObject.NodeRunner(commonOptions);
244
247
  return runner;
245
248
  }
249
+ exports.createHotCase = __webpack_exports__.createHotCase;
250
+ exports.createHotProcessor = __webpack_exports__.createHotProcessor;
251
+ exports.createHotRunner = __webpack_exports__.createHotRunner;
252
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
253
+ "createHotCase",
254
+ "createHotProcessor",
255
+ "createHotRunner"
256
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
257
+ Object.defineProperty(exports, '__esModule', {
258
+ value: true
259
+ });
@@ -1,36 +1,70 @@
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.createHotIncrementalCase = createHotIncrementalCase;
7
- exports.createWatchIncrementalCase = createWatchIncrementalCase;
8
- const node_fs_1 = __importDefault(require("node:fs"));
9
- const node_path_1 = __importDefault(require("node:path"));
10
- const creator_1 = require("../test/creator");
11
- const hot_1 = require("./hot");
12
- const watch_1 = require("./watch");
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
+ createHotIncrementalCase: ()=>createHotIncrementalCase,
37
+ createWatchIncrementalCase: ()=>createWatchIncrementalCase
38
+ });
39
+ const external_node_fs_namespaceObject = require("node:fs");
40
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
41
+ const external_node_path_namespaceObject = require("node:path");
42
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
43
+ const creator_js_namespaceObject = require("../test/creator.js");
44
+ const external_hot_js_namespaceObject = require("./hot.js");
45
+ const external_watch_js_namespaceObject = require("./watch.js");
13
46
  const hotCreators = new Map();
14
47
  function createHotIncrementalProcessor(name, src, temp, target, webpackCases) {
15
- return (0, hot_1.createHotProcessor)(name, src, temp, target, true);
48
+ return (0, external_hot_js_namespaceObject.createHotProcessor)(name, src, temp, target, true);
16
49
  }
17
50
  function getHotCreator(target, webpackCases) {
18
- const key = JSON.stringify({ target, webpackCases });
19
- if (!hotCreators.has(key)) {
20
- hotCreators.set(key, new creator_1.BasicCaseCreator({
21
- clean: true,
22
- describe: true,
23
- target,
24
- steps: ({ name, target, src, temp, dist }) => [
25
- createHotIncrementalProcessor(name, src, temp || node_path_1.default.resolve(dist, 'temp'), target, webpackCases),
51
+ const key = JSON.stringify({
52
+ target,
53
+ webpackCases
54
+ });
55
+ if (!hotCreators.has(key)) hotCreators.set(key, new creator_js_namespaceObject.BasicCaseCreator({
56
+ clean: true,
57
+ describe: true,
58
+ target,
59
+ steps: ({ name, target, src, temp, dist })=>[
60
+ createHotIncrementalProcessor(name, src, temp || external_node_path_default().resolve(dist, 'temp'), target, webpackCases)
26
61
  ],
27
- runner: {
28
- key: (context, name, file) => name,
29
- runner: hot_1.createHotRunner,
30
- },
31
- concurrent: true,
32
- }));
33
- }
62
+ runner: {
63
+ key: (context, name, file)=>name,
64
+ runner: external_hot_js_namespaceObject.createHotRunner
65
+ },
66
+ concurrent: true
67
+ }));
34
68
  return hotCreators.get(key);
35
69
  }
36
70
  function createHotIncrementalCase(name, src, dist, temp, target, webpackCases) {
@@ -40,40 +74,39 @@ function createHotIncrementalCase(name, src, dist, temp, target, webpackCases) {
40
74
  const watchCreators = new Map();
41
75
  function getWatchCreator(options) {
42
76
  const key = JSON.stringify(options);
43
- if (!watchCreators.has(key)) {
44
- watchCreators.set(key, new creator_1.BasicCaseCreator({
45
- clean: true,
46
- runner: {
47
- key: watch_1.getWatchRunnerKey,
48
- runner: watch_1.createWatchRunner,
49
- },
50
- description: (name, index) => {
51
- return index === 0
52
- ? `${name} should compile`
53
- : `should compile step ${index}`;
54
- },
55
- describe: false,
56
- steps: ({ name, src, temp }) => {
57
- const watchState = {};
58
- const runs = node_fs_1.default
59
- .readdirSync(src)
60
- .sort()
61
- .filter((name) => node_fs_1.default.statSync(node_path_1.default.join(src, name)).isDirectory())
62
- .map((name) => ({ name }));
63
- return runs.map((run, index) => index === 0
64
- ? (0, watch_1.createWatchInitialProcessor)(name, temp, run.name, watchState, {
65
- incremental: true,
66
- })
67
- : (0, watch_1.createWatchStepProcessor)(name, temp, run.name, watchState, {
68
- incremental: true,
69
- }));
70
- },
71
- concurrent: true,
72
- }));
73
- }
77
+ if (!watchCreators.has(key)) watchCreators.set(key, new creator_js_namespaceObject.BasicCaseCreator({
78
+ clean: true,
79
+ runner: {
80
+ key: external_watch_js_namespaceObject.getWatchRunnerKey,
81
+ runner: external_watch_js_namespaceObject.createWatchRunner
82
+ },
83
+ description: (name, index)=>0 === index ? `${name} should compile` : `should compile step ${index}`,
84
+ describe: false,
85
+ steps: ({ name, src, temp })=>{
86
+ const watchState = {};
87
+ const runs = external_node_fs_default().readdirSync(src).sort().filter((name)=>external_node_fs_default().statSync(external_node_path_default().join(src, name)).isDirectory()).map((name)=>({
88
+ name
89
+ }));
90
+ return runs.map((run, index)=>0 === index ? (0, external_watch_js_namespaceObject.createWatchInitialProcessor)(name, temp, run.name, watchState, {
91
+ incremental: true
92
+ }) : (0, external_watch_js_namespaceObject.createWatchStepProcessor)(name, temp, run.name, watchState, {
93
+ incremental: true
94
+ }));
95
+ },
96
+ concurrent: true
97
+ }));
74
98
  return watchCreators.get(key);
75
99
  }
76
100
  function createWatchIncrementalCase(name, src, dist, temp, options = {}) {
77
101
  const creator = getWatchCreator(options);
78
102
  creator.create(name, src, dist, temp);
79
103
  }
104
+ exports.createHotIncrementalCase = __webpack_exports__.createHotIncrementalCase;
105
+ exports.createWatchIncrementalCase = __webpack_exports__.createWatchIncrementalCase;
106
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
107
+ "createHotIncrementalCase",
108
+ "createWatchIncrementalCase"
109
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
110
+ Object.defineProperty(exports, '__esModule', {
111
+ value: true
112
+ });