@rspack/test-tools 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,62 +1,98 @@
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.createConfigProcessor = createConfigProcessor;
7
- exports.createConfigCase = createConfigCase;
8
- exports.defaultOptions = defaultOptions;
9
- exports.enableEsmLibraryPlugin = enableEsmLibraryPlugin;
10
- exports.overrideOptions = overrideOptions;
11
- exports.findBundle = findBundle;
12
- const node_path_1 = __importDefault(require("node:path"));
13
- const fs_extra_1 = __importDefault(require("fs-extra"));
14
- const parseResource_1 = require("../helper/legacy/parseResource");
15
- const creator_1 = require("../test/creator");
16
- const common_1 = require("./common");
17
- const runner_1 = 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
+ createConfigCase: ()=>createConfigCase,
37
+ createConfigProcessor: ()=>createConfigProcessor,
38
+ defaultOptions: ()=>defaultOptions,
39
+ enableEsmLibraryPlugin: ()=>enableEsmLibraryPlugin,
40
+ findBundle: ()=>findBundle,
41
+ overrideOptions: ()=>overrideOptions
42
+ });
43
+ const external_node_path_namespaceObject = require("node:path");
44
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
45
+ const external_fs_extra_namespaceObject = require("fs-extra");
46
+ var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
47
+ const parseResource_js_namespaceObject = require("../helper/legacy/parseResource.js");
48
+ const creator_js_namespaceObject = require("../test/creator.js");
49
+ const external_common_js_namespaceObject = require("./common.js");
50
+ const external_runner_js_namespaceObject = require("./runner.js");
18
51
  function createConfigProcessor(name) {
19
52
  return {
20
- config: async (context) => {
21
- (0, common_1.configMultiCompiler)(context, name, ['rspack.config.cjs', 'rspack.config.js', 'webpack.config.js'], defaultOptions, overrideOptions);
22
- },
23
- compiler: async (context) => {
24
- await (0, common_1.compiler)(context, name);
53
+ config: (context)=>{
54
+ (0, external_common_js_namespaceObject.configMultiCompiler)(context, name, [
55
+ 'rspack.config.cjs',
56
+ 'rspack.config.js',
57
+ 'webpack.config.js'
58
+ ], defaultOptions, overrideOptions);
25
59
  },
26
- build: async (context) => {
27
- await (0, common_1.build)(context, name);
60
+ compiler: async (context)=>{
61
+ await (0, external_common_js_namespaceObject.compiler)(context, name);
28
62
  },
29
- run: async (env, context) => {
30
- await (0, common_1.run)(env, context, name, (context) => (0, common_1.findMultiCompilerBundle)(context, name, findBundle));
63
+ build: async (context)=>{
64
+ await (0, external_common_js_namespaceObject.build)(context, name);
31
65
  },
32
- check: async (env, context) => {
33
- await (0, common_1.check)(env, context, name);
66
+ run: async (env, context)=>{
67
+ await (0, external_common_js_namespaceObject.run)(env, context, name, (context)=>(0, external_common_js_namespaceObject.findMultiCompilerBundle)(context, name, findBundle));
34
68
  },
35
- after: async (context) => {
36
- await (0, common_1.afterExecute)(context, name);
69
+ check: async (env, context)=>{
70
+ await (0, external_common_js_namespaceObject.check)(env, context, name);
37
71
  },
72
+ after: async (context)=>{
73
+ await (0, external_common_js_namespaceObject.afterExecute)(context, name);
74
+ }
38
75
  };
39
76
  }
40
- const creator = new creator_1.BasicCaseCreator({
77
+ const creator = new creator_js_namespaceObject.BasicCaseCreator({
41
78
  clean: true,
42
79
  describe: false,
43
- testConfig: (testConfig) => {
80
+ testConfig: (testConfig)=>{
44
81
  const oldModuleScope = testConfig.moduleScope;
45
- testConfig.moduleScope = (ms, stats, compilerOptions) => {
82
+ testConfig.moduleScope = (ms, stats, compilerOptions)=>{
46
83
  let res = ms;
47
- // TODO: modify runner module scope based on stats here
48
- if (typeof oldModuleScope === 'function') {
49
- res = oldModuleScope(ms, stats, compilerOptions);
50
- }
84
+ if ('function' == typeof oldModuleScope) res = oldModuleScope(ms, stats, compilerOptions);
51
85
  return res;
52
86
  };
53
87
  },
54
- steps: ({ name }) => [createConfigProcessor(name)],
88
+ steps: ({ name })=>[
89
+ createConfigProcessor(name)
90
+ ],
55
91
  runner: {
56
- key: runner_1.getMultiCompilerRunnerKey,
57
- runner: runner_1.createMultiCompilerRunner,
92
+ key: external_runner_js_namespaceObject.getMultiCompilerRunnerKey,
93
+ runner: external_runner_js_namespaceObject.createMultiCompilerRunner
58
94
  },
59
- concurrent: true,
95
+ concurrent: true
60
96
  });
61
97
  function createConfigCase(name, src, dist) {
62
98
  creator.create(name, src, dist);
@@ -71,61 +107,63 @@ function defaultOptions(index, context) {
71
107
  output: {
72
108
  path: context.getDist(),
73
109
  bundlerInfo: {
74
- force: false,
75
- },
110
+ force: false
111
+ }
76
112
  },
77
113
  optimization: {
78
- minimize: false,
79
- },
114
+ minimize: false
115
+ }
80
116
  };
81
117
  }
82
118
  function enableEsmLibraryPlugin(options) {
83
- return (options.output?.library === 'modern-module' ||
84
- (typeof options.output?.library === 'object' &&
85
- (options.output?.library).type === 'modern-module'));
119
+ return options.output?.library === 'modern-module' || 'object' == typeof options.output?.library && 'modern-module' === (options.output?.library).type;
86
120
  }
87
121
  function overrideOptions(index, context, options) {
88
- if (!options.entry) {
89
- options.entry = './index.js';
90
- }
91
- if (options.amd === undefined) {
92
- options.amd = {};
93
- }
122
+ if (!options.entry) options.entry = './index.js';
123
+ if (void 0 === options.amd) options.amd = {};
94
124
  if (!options.output?.filename) {
95
- const runtimeChunkForModernModule = options.optimization?.runtimeChunk === undefined &&
96
- enableEsmLibraryPlugin(options);
125
+ const runtimeChunkForModernModule = options.optimization?.runtimeChunk === void 0 && enableEsmLibraryPlugin(options);
97
126
  const outputModule = options.output?.module || enableEsmLibraryPlugin(options);
98
127
  options.output ??= {};
99
128
  options.output.filename = `${runtimeChunkForModernModule ? `[name]${outputModule ? '.mjs' : '.js'}` : `bundle${index}${outputModule ? '.mjs' : '.js'}`}`;
100
129
  }
101
130
  if (enableEsmLibraryPlugin(options)) {
102
131
  options.optimization ??= {};
103
- options.optimization.runtimeChunk ??= { name: `runtime~${index}` };
104
- }
105
- if (options.cache === undefined)
106
- options.cache = false;
107
- if (!global.printLogger) {
108
- options.infrastructureLogging = {
109
- level: 'error',
132
+ options.optimization.runtimeChunk ??= {
133
+ name: `runtime~${index}`
110
134
  };
111
135
  }
136
+ if (void 0 === options.cache) options.cache = false;
137
+ if (!global.printLogger) options.infrastructureLogging = {
138
+ level: 'error'
139
+ };
112
140
  }
113
141
  function findBundle(index, context, options) {
114
142
  const testConfig = context.getTestConfig();
115
- if (typeof testConfig.findBundle === 'function') {
116
- return testConfig.findBundle(index, options);
117
- }
118
- const ext = node_path_1.default.extname((0, parseResource_1.parseResource)(options.output?.filename).path);
143
+ if ('function' == typeof testConfig.findBundle) return testConfig.findBundle(index, options);
144
+ const ext = external_node_path_default().extname((0, parseResource_js_namespaceObject.parseResource)(options.output?.filename).path);
119
145
  const bundlePath = [];
120
- if (options.output?.path &&
121
- fs_extra_1.default.existsSync(node_path_1.default.join(options.output.path, `bundle${index}${ext}`))) {
122
- const cssOutputPath = node_path_1.default.join(options.output.path, (typeof options.output?.cssFilename === 'string' &&
123
- options.output?.cssFilename) ||
124
- `bundle${index}.css`);
125
- if (fs_extra_1.default.existsSync(cssOutputPath)) {
126
- bundlePath.push(node_path_1.default.relative(options.output.path, cssOutputPath));
127
- }
146
+ if (options.output?.path && external_fs_extra_default().existsSync(external_node_path_default().join(options.output.path, `bundle${index}${ext}`))) {
147
+ const cssOutputPath = external_node_path_default().join(options.output.path, 'string' == typeof options.output?.cssFilename && options.output?.cssFilename || `bundle${index}.css`);
148
+ if (external_fs_extra_default().existsSync(cssOutputPath)) bundlePath.push(external_node_path_default().relative(options.output.path, cssOutputPath));
128
149
  bundlePath.push(`./bundle${index}${ext}`);
129
150
  }
130
151
  return bundlePath;
131
152
  }
153
+ exports.createConfigCase = __webpack_exports__.createConfigCase;
154
+ exports.createConfigProcessor = __webpack_exports__.createConfigProcessor;
155
+ exports.defaultOptions = __webpack_exports__.defaultOptions;
156
+ exports.enableEsmLibraryPlugin = __webpack_exports__.enableEsmLibraryPlugin;
157
+ exports.findBundle = __webpack_exports__.findBundle;
158
+ exports.overrideOptions = __webpack_exports__.overrideOptions;
159
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
160
+ "createConfigCase",
161
+ "createConfigProcessor",
162
+ "defaultOptions",
163
+ "enableEsmLibraryPlugin",
164
+ "findBundle",
165
+ "overrideOptions"
166
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
167
+ Object.defineProperty(exports, '__esModule', {
168
+ value: true
169
+ });
@@ -1,93 +1,146 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __webpack_modules__ = {
3
+ "@rspack/core" (module) {
4
+ module.exports = require("@rspack/core");
5
+ }
4
6
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createDefaultsCase = createDefaultsCase;
7
- exports.getRspackDefaultConfig = getRspackDefaultConfig;
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const node_util_1 = require("node:util");
10
- const jest_diff_1 = require("jest-diff");
11
- const context_1 = require("../test/context");
12
- const CURRENT_CWD = process.cwd();
13
- function createDefaultsCase(name, src) {
14
- const caseConfig = require(src);
15
- it(`should generate the correct defaults from ${caseConfig.description}`, async () => {
16
- await run(name, {
17
- config: async (context) => {
18
- const compiler = context.getCompiler();
19
- compiler.setOptions(options(context, caseConfig.options));
20
- },
21
- compiler: async (context) => {
22
- const compiler = context.getCompiler();
23
- compiler.createCompiler();
24
- },
25
- build: async (context) => {
26
- // no need to build, just check the snapshot of compiler options
27
- },
28
- run: async (env, context) => {
29
- // no need to run, just check the snapshot of compiler options
30
- },
31
- check: async (env, context) => {
32
- await check(env, context, name, caseConfig);
33
- },
7
+ var __webpack_module_cache__ = {};
8
+ function __webpack_require__(moduleId) {
9
+ var cachedModule = __webpack_module_cache__[moduleId];
10
+ if (void 0 !== cachedModule) return cachedModule.exports;
11
+ var module = __webpack_module_cache__[moduleId] = {
12
+ exports: {}
13
+ };
14
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
+ return module.exports;
16
+ }
17
+ (()=>{
18
+ __webpack_require__.n = (module)=>{
19
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
20
+ __webpack_require__.d(getter, {
21
+ a: getter
22
+ });
23
+ return getter;
24
+ };
25
+ })();
26
+ (()=>{
27
+ __webpack_require__.d = (exports1, definition)=>{
28
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
+ enumerable: true,
30
+ get: definition[key]
31
+ });
32
+ };
33
+ })();
34
+ (()=>{
35
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
36
+ })();
37
+ (()=>{
38
+ __webpack_require__.r = (exports1)=>{
39
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
40
+ value: 'Module'
41
+ });
42
+ Object.defineProperty(exports1, '__esModule', {
43
+ value: true
34
44
  });
45
+ };
46
+ })();
47
+ var __webpack_exports__ = {};
48
+ (()=>{
49
+ __webpack_require__.r(__webpack_exports__);
50
+ __webpack_require__.d(__webpack_exports__, {
51
+ createDefaultsCase: ()=>createDefaultsCase,
52
+ getRspackDefaultConfig: ()=>getRspackDefaultConfig
35
53
  });
36
- }
37
- function getRspackDefaultConfig(cwd, config) {
38
- process.chdir(cwd);
39
- const { applyWebpackOptionsDefaults, getNormalizedWebpackOptions } = require('@rspack/core').config;
40
- const normalizedConfig = getNormalizedWebpackOptions(config);
41
- applyWebpackOptionsDefaults(normalizedConfig);
42
- // make snapshot stable
43
- normalizedConfig.output.bundlerInfo.version = '$version$';
44
- process.chdir(CURRENT_CWD);
45
- return normalizedConfig;
46
- }
47
- const srcDir = node_path_1.default.resolve(__dirname, '../../tests/fixtures');
48
- const distDir = node_path_1.default.resolve(__dirname, '../../tests/js/defaults');
49
- function options(context, custom) {
50
- let res;
51
- if (typeof custom === 'function') {
52
- res = custom(context);
54
+ const external_node_path_namespaceObject = require("node:path");
55
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
56
+ const external_node_util_namespaceObject = require("node:util");
57
+ const external_jest_diff_namespaceObject = require("jest-diff");
58
+ const context_js_namespaceObject = require("../test/context.js");
59
+ const CURRENT_CWD = process.cwd();
60
+ function createDefaultsCase(name, src) {
61
+ const caseConfig = require(src);
62
+ it(`should generate the correct defaults from ${caseConfig.description}`, async ()=>{
63
+ await run(name, {
64
+ config: (context)=>{
65
+ const compiler = context.getCompiler();
66
+ compiler.setOptions(defaults_options(context, caseConfig.options));
67
+ },
68
+ compiler: (context)=>{
69
+ const compiler = context.getCompiler();
70
+ compiler.createCompiler();
71
+ },
72
+ build: async (context)=>{},
73
+ run: async (env, context)=>{},
74
+ check: async (env, context)=>{
75
+ await check(env, context, name, caseConfig);
76
+ }
77
+ });
78
+ });
53
79
  }
54
- else {
55
- res = {};
80
+ function getRspackDefaultConfig(cwd, config) {
81
+ process.chdir(cwd);
82
+ const { applyWebpackOptionsDefaults, getNormalizedWebpackOptions } = __webpack_require__("@rspack/core").config;
83
+ const normalizedConfig = getNormalizedWebpackOptions(config);
84
+ applyWebpackOptionsDefaults(normalizedConfig);
85
+ normalizedConfig.output.bundlerInfo.version = '$version$';
86
+ process.chdir(CURRENT_CWD);
87
+ return normalizedConfig;
56
88
  }
57
- if (!('mode' in res)) {
58
- res.mode = 'none';
89
+ const srcDir = external_node_path_default().resolve(__dirname, '../../tests/fixtures');
90
+ const distDir = external_node_path_default().resolve(__dirname, '../../tests/js/defaults');
91
+ function defaults_options(context, custom) {
92
+ let res;
93
+ res = 'function' == typeof custom ? custom(context) : {};
94
+ if (!('mode' in res)) res.mode = 'none';
95
+ return res;
59
96
  }
60
- return res;
61
- }
62
- class RspackTestDiff {
63
- constructor(value) {
64
- this.value = value;
97
+ class RspackTestDiff {
98
+ value;
99
+ constructor(value){
100
+ this.value = value;
101
+ }
65
102
  }
66
- }
67
- async function check(env, context, name, options) {
68
- const compiler = context.getCompiler();
69
- const config = getRspackDefaultConfig(options.cwd || CURRENT_CWD, compiler.getOptions());
70
- const defaultConfig = getRspackDefaultConfig(options.cwd || CURRENT_CWD, {
71
- mode: 'none',
72
- });
73
- const diff = (0, node_util_1.stripVTControlCharacters)((0, jest_diff_1.diff)(defaultConfig, config, { expand: false, contextLines: 0 }));
74
- await options.diff(env.expect(new RspackTestDiff(diff)), env.expect(defaultConfig));
75
- }
76
- async function run(name, processor) {
77
- const context = new context_1.TestContext({
78
- name: name,
79
- src: srcDir,
80
- dist: distDir,
81
- });
82
- try {
83
- await processor.before?.(context);
84
- await processor.config?.(context);
85
- }
86
- catch (e) {
87
- context.emitError(e);
103
+ async function check(env, context, name, options) {
104
+ const compiler = context.getCompiler();
105
+ const config = getRspackDefaultConfig(options.cwd || CURRENT_CWD, compiler.getOptions());
106
+ const defaultConfig = getRspackDefaultConfig(options.cwd || CURRENT_CWD, {
107
+ mode: 'none'
108
+ });
109
+ const diff = (0, external_node_util_namespaceObject.stripVTControlCharacters)((0, external_jest_diff_namespaceObject.diff)(defaultConfig, config, {
110
+ expand: false,
111
+ contextLines: 0
112
+ }));
113
+ await options.diff(env.expect(new RspackTestDiff(diff)), env.expect(defaultConfig));
88
114
  }
89
- finally {
90
- await processor.check?.({ expect, it, beforeEach, afterEach, rstest }, context);
91
- await processor.after?.(context);
115
+ async function run(name, processor) {
116
+ const context = new context_js_namespaceObject.TestContext({
117
+ name: name,
118
+ src: srcDir,
119
+ dist: distDir
120
+ });
121
+ try {
122
+ await processor.before?.(context);
123
+ await processor.config?.(context);
124
+ } catch (e) {
125
+ context.emitError(e);
126
+ } finally{
127
+ await processor.check?.({
128
+ expect,
129
+ it,
130
+ beforeEach,
131
+ afterEach,
132
+ rstest
133
+ }, context);
134
+ await processor.after?.(context);
135
+ }
92
136
  }
93
- }
137
+ })();
138
+ exports.createDefaultsCase = __webpack_exports__.createDefaultsCase;
139
+ exports.getRspackDefaultConfig = __webpack_exports__.getRspackDefaultConfig;
140
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
141
+ "createDefaultsCase",
142
+ "getRspackDefaultConfig"
143
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
144
+ Object.defineProperty(exports, '__esModule', {
145
+ value: true
146
+ });