@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.
- package/dist/case/builtin.js +106 -66
- package/dist/case/cache.js +136 -122
- package/dist/case/common.d.ts +4 -4
- package/dist/case/common.js +162 -157
- package/dist/case/compiler.d.ts +4 -4
- package/dist/case/compiler.js +75 -64
- package/dist/case/config.js +112 -74
- package/dist/case/defaults.js +136 -83
- package/dist/case/diagnostic.js +112 -84
- package/dist/case/error.d.ts +4 -4
- package/dist/case/error.js +105 -89
- package/dist/case/esm-output.js +118 -87
- package/dist/case/example.js +73 -35
- package/dist/case/hash.js +74 -59
- package/dist/case/hook.js +151 -138
- package/dist/case/hot-step.js +130 -161
- package/dist/case/hot.js +148 -134
- package/dist/case/incremental.js +91 -58
- package/dist/case/index.js +134 -51
- package/dist/case/multi-compiler.d.ts +4 -4
- package/dist/case/multi-compiler.js +81 -56
- package/dist/case/native-watcher.js +62 -30
- package/dist/case/normal.js +253 -185
- package/dist/case/runner.js +80 -51
- package/dist/case/serial.js +47 -16
- package/dist/case/stats-api.d.ts +4 -4
- package/dist/case/stats-api.js +63 -43
- package/dist/case/stats-output.d.ts +3 -3
- package/dist/case/stats-output.js +147 -152
- package/dist/case/treeshaking.js +66 -35
- package/dist/case/watch.d.ts +3 -19
- package/dist/case/watch.js +204 -224
- package/dist/compiler.js +222 -195
- package/dist/helper/directory.js +83 -71
- package/dist/helper/disable-iconv-lite-warning.js +35 -9
- package/dist/helper/expect/diff.js +39 -10
- package/dist/helper/expect/error.js +62 -30
- package/dist/helper/expect/placeholder.js +47 -21
- package/dist/helper/expect/rspack.js +35 -13
- package/dist/helper/expect/to-be-typeof.js +39 -7
- package/dist/helper/expect/to-end-with.js +40 -8
- package/dist/helper/expect/to-match-file-snapshot.js +103 -80
- package/dist/helper/hot-update/index.js +35 -4
- package/dist/helper/hot-update/loader.d.ts +1 -0
- package/dist/helper/hot-update/loader.js +39 -4
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +87 -74
- package/dist/helper/index.js +138 -24
- package/dist/helper/is.js +51 -10
- package/dist/helper/legacy/EventSourceForNode.d.ts +11 -3
- package/dist/helper/legacy/EventSourceForNode.js +83 -37
- package/dist/helper/legacy/LogTestPlugin.d.ts +2 -3
- package/dist/helper/legacy/LogTestPlugin.js +39 -6
- package/dist/helper/legacy/asModule.d.ts +3 -3
- package/dist/helper/legacy/asModule.js +68 -19
- package/dist/helper/legacy/captureStdio.d.ts +1 -2
- package/dist/helper/legacy/captureStdio.js +69 -29
- package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -2
- package/dist/helper/legacy/checkArrayExpectation.js +132 -121
- package/dist/helper/legacy/copyDiff.d.ts +1 -2
- package/dist/helper/legacy/copyDiff.js +86 -42
- package/dist/helper/legacy/createFakeWorker.d.ts +2 -3
- package/dist/helper/legacy/createFakeWorker.js +90 -47
- package/dist/helper/legacy/createLazyTestEnv.d.ts +2 -3
- package/dist/helper/legacy/createLazyTestEnv.js +70 -59
- package/dist/helper/legacy/currentScript.d.ts +2 -2
- package/dist/helper/legacy/currentScript.js +35 -2
- package/dist/helper/legacy/deprecationTracking.d.ts +1 -1
- package/dist/helper/legacy/deprecationTracking.js +53 -28
- package/dist/helper/legacy/expectSource.d.ts +3 -2
- package/dist/helper/legacy/expectSource.js +42 -18
- package/dist/helper/legacy/fakeSystem.d.ts +12 -9
- package/dist/helper/legacy/fakeSystem.js +68 -58
- package/dist/helper/legacy/findOutputFiles.d.ts +7 -2
- package/dist/helper/legacy/findOutputFiles.js +60 -13
- package/dist/helper/legacy/parseResource.d.ts +1 -1
- package/dist/helper/legacy/parseResource.js +36 -6
- package/dist/helper/legacy/regexEscape.d.ts +1 -2
- package/dist/helper/legacy/regexEscape.js +39 -5
- package/dist/helper/legacy/supportDefaultAssignment.d.ts +1 -2
- package/dist/helper/legacy/supportDefaultAssignment.js +40 -7
- package/dist/helper/legacy/supportsTextDecoder.d.ts +1 -2
- package/dist/helper/legacy/supportsTextDecoder.js +40 -6
- package/dist/helper/legacy/supportsUsing.d.ts +1 -2
- package/dist/helper/legacy/supportsUsing.js +40 -7
- package/dist/helper/legacy/urlToRelativePath.d.ts +2 -2
- package/dist/helper/legacy/urlToRelativePath.js +56 -7
- package/dist/helper/parse-modules.js +52 -42
- package/dist/helper/read-config-file.js +60 -18
- package/dist/helper/serializers.js +62 -33
- package/dist/helper/setup-env.js +81 -91
- package/dist/helper/setup-expect.js +13 -13
- package/dist/helper/setup-wasm.js +18 -9
- package/dist/helper/stringify-config.js +44 -26
- package/dist/helper/update-snapshot.js +35 -3
- package/dist/helper/util/checkSourceMap.js +119 -80
- package/dist/helper/util/checkStats.d.ts +1 -1
- package/dist/helper/util/checkStats.js +42 -17
- package/dist/helper/util/expectWarningFactory.d.ts +1 -2
- package/dist/helper/util/expectWarningFactory.js +41 -8
- package/dist/helper/util/filterUtil.d.ts +9 -8
- package/dist/helper/util/filterUtil.js +63 -23
- package/dist/helper/win.js +46 -7
- package/dist/index.js +115 -23
- package/dist/plugin/index.js +55 -14
- package/dist/plugin/lazy-compilation-test-plugin.js +55 -41
- package/dist/reporter/index.js +55 -14
- package/dist/reporter/streamed-events-reporter.js +51 -77
- package/dist/runner/index.js +62 -15
- package/dist/runner/node/index.js +365 -431
- package/dist/runner/web/index.js +278 -263
- package/dist/test/context.js +67 -41
- package/dist/test/creator.js +135 -167
- package/dist/test/debug.js +89 -58
- package/dist/test/tester.js +94 -74
- package/dist/type.d.ts +10 -9
- package/dist/type.js +43 -9
- package/package.json +21 -20
package/dist/case/diagnostic.js
CHANGED
|
@@ -1,60 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
createDiagnosticCase: ()=>createDiagnosticCase
|
|
37
|
+
});
|
|
38
|
+
const external_node_assert_namespaceObject = require("node:assert");
|
|
39
|
+
var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
|
|
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 external_rspack_merge_namespaceObject = require("rspack-merge");
|
|
43
|
+
var external_rspack_merge_default = /*#__PURE__*/ __webpack_require__.n(external_rspack_merge_namespaceObject);
|
|
44
|
+
const index_js_namespaceObject = require("../helper/index.js");
|
|
45
|
+
const placeholder_js_namespaceObject = require("../helper/expect/placeholder.js");
|
|
46
|
+
const creator_js_namespaceObject = require("../test/creator.js");
|
|
47
|
+
const creator = new creator_js_namespaceObject.BasicCaseCreator({
|
|
14
48
|
clean: true,
|
|
15
49
|
describe: false,
|
|
16
|
-
steps: ({ name })
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
options.infrastructureLogging = {
|
|
27
|
-
level: 'error'
|
|
50
|
+
steps: ({ name })=>[
|
|
51
|
+
{
|
|
52
|
+
config: (context)=>{
|
|
53
|
+
const compiler = context.getCompiler();
|
|
54
|
+
let options = defaultOptions(context);
|
|
55
|
+
const custom = (0, index_js_namespaceObject.readConfigFile)([
|
|
56
|
+
'rspack.config.js',
|
|
57
|
+
'webpack.config.js'
|
|
58
|
+
].map((i)=>context.getSource(i)), context, options)[0];
|
|
59
|
+
if (custom) options = external_rspack_merge_default()(options, custom);
|
|
60
|
+
if (!global.printLogger) options.infrastructureLogging = {
|
|
61
|
+
level: 'error'
|
|
28
62
|
};
|
|
63
|
+
compiler.setOptions(options);
|
|
64
|
+
},
|
|
65
|
+
compiler: (context)=>{
|
|
66
|
+
const compiler = context.getCompiler();
|
|
67
|
+
compiler.createCompiler();
|
|
68
|
+
},
|
|
69
|
+
build: async (context)=>{
|
|
70
|
+
const compiler = context.getCompiler();
|
|
71
|
+
await compiler.build();
|
|
72
|
+
},
|
|
73
|
+
run: async (env, context)=>{},
|
|
74
|
+
check: async (env, context)=>{
|
|
75
|
+
await check(env, context, name, {
|
|
76
|
+
snapshot: './stats.err',
|
|
77
|
+
snapshotErrors: './raw-error.err',
|
|
78
|
+
snapshotWarning: './raw-warning.err',
|
|
79
|
+
format: (output)=>output.replace(/(│.* at ).*/g, '$1xxx')
|
|
80
|
+
});
|
|
29
81
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const compiler = context.getCompiler();
|
|
34
|
-
compiler.createCompiler();
|
|
35
|
-
},
|
|
36
|
-
build: async (context) => {
|
|
37
|
-
const compiler = context.getCompiler();
|
|
38
|
-
await compiler.build();
|
|
39
|
-
},
|
|
40
|
-
run: async (env, context) => {
|
|
41
|
-
// no need to run, just check the snapshot of diagnostics
|
|
42
|
-
},
|
|
43
|
-
check: async (env, context) => {
|
|
44
|
-
await check(env, context, name, {
|
|
45
|
-
snapshot: './stats.err',
|
|
46
|
-
snapshotErrors: './raw-error.err',
|
|
47
|
-
snapshotWarning: './raw-warning.err',
|
|
48
|
-
format: (output) => {
|
|
49
|
-
// TODO: change to stats.errorStack
|
|
50
|
-
// TODO: add `errorStack: false`
|
|
51
|
-
return output.replace(/(│.* at ).*/g, '$1xxx');
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
concurrent: true,
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
concurrent: true
|
|
58
85
|
});
|
|
59
86
|
function createDiagnosticCase(name, src, dist) {
|
|
60
87
|
creator.create(name, src, dist);
|
|
@@ -64,76 +91,77 @@ function defaultOptions(context) {
|
|
|
64
91
|
target: 'node',
|
|
65
92
|
context: context.getSource(),
|
|
66
93
|
entry: {
|
|
67
|
-
main: './'
|
|
94
|
+
main: './'
|
|
68
95
|
},
|
|
69
96
|
module: {
|
|
70
97
|
defaultRules: [
|
|
71
98
|
'...',
|
|
72
99
|
{
|
|
73
100
|
test: /\.css/,
|
|
74
|
-
type: 'css/auto'
|
|
75
|
-
}
|
|
76
|
-
]
|
|
101
|
+
type: 'css/auto'
|
|
102
|
+
}
|
|
103
|
+
]
|
|
77
104
|
},
|
|
78
105
|
mode: 'development',
|
|
79
106
|
devServer: {
|
|
80
|
-
hot: false
|
|
107
|
+
hot: false
|
|
81
108
|
},
|
|
82
109
|
infrastructureLogging: {
|
|
83
|
-
debug: false
|
|
110
|
+
debug: false
|
|
84
111
|
},
|
|
85
112
|
output: {
|
|
86
113
|
path: context.getDist(),
|
|
87
114
|
bundlerInfo: {
|
|
88
|
-
force: false
|
|
89
|
-
}
|
|
90
|
-
}
|
|
115
|
+
force: false
|
|
116
|
+
}
|
|
117
|
+
}
|
|
91
118
|
};
|
|
92
119
|
}
|
|
93
|
-
|
|
120
|
+
function check(env, context, name, options) {
|
|
94
121
|
const compiler = context.getCompiler();
|
|
95
122
|
const stats = compiler.getStats();
|
|
96
|
-
if (!stats)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
(0, node_assert_1.default)(stats.hasErrors() || stats.hasWarnings());
|
|
100
|
-
let output = (0, placeholder_1.normalizePlaceholder)(stats.toString({
|
|
123
|
+
if (!stats) throw new Error('Stats should exists');
|
|
124
|
+
external_node_assert_default()(stats.hasErrors() || stats.hasWarnings());
|
|
125
|
+
let output = (0, placeholder_js_namespaceObject.normalizePlaceholder)(stats.toString({
|
|
101
126
|
all: false,
|
|
102
127
|
errors: true,
|
|
103
|
-
warnings: true
|
|
128
|
+
warnings: true
|
|
104
129
|
})).replaceAll('\\', '/');
|
|
105
130
|
const statsJson = stats.toJson({
|
|
106
131
|
all: false,
|
|
107
132
|
errors: true,
|
|
108
|
-
warnings: true
|
|
133
|
+
warnings: true
|
|
109
134
|
});
|
|
110
|
-
const errors = (statsJson.errors || []).map((e)
|
|
111
|
-
// @ts-expect-error error message is already serialized in `stats.err`
|
|
135
|
+
const errors = (statsJson.errors || []).map((e)=>{
|
|
112
136
|
delete e.message;
|
|
113
137
|
delete e.stack;
|
|
114
138
|
return e;
|
|
115
139
|
});
|
|
116
|
-
const warnings = (statsJson.warnings || []).map((e)
|
|
117
|
-
// @ts-expect-error error message is already serialized in `stats.err`
|
|
140
|
+
const warnings = (statsJson.warnings || []).map((e)=>{
|
|
118
141
|
delete e.message;
|
|
119
142
|
delete e.stack;
|
|
120
143
|
return e;
|
|
121
144
|
});
|
|
122
|
-
if (typeof options.format
|
|
123
|
-
output = options.format(output);
|
|
124
|
-
}
|
|
145
|
+
if ('function' == typeof options.format) output = options.format(output);
|
|
125
146
|
env.expect.addSnapshotSerializer({
|
|
126
|
-
test(received) {
|
|
127
|
-
return typeof received
|
|
128
|
-
},
|
|
129
|
-
serialize(received) {
|
|
130
|
-
return (0, placeholder_1.normalizePlaceholder)(received.trim());
|
|
147
|
+
test (received) {
|
|
148
|
+
return 'string' == typeof received;
|
|
131
149
|
},
|
|
150
|
+
serialize (received) {
|
|
151
|
+
return (0, placeholder_js_namespaceObject.normalizePlaceholder)(received.trim());
|
|
152
|
+
}
|
|
132
153
|
});
|
|
133
|
-
const errorOutputPath =
|
|
134
|
-
const errorStatsOutputPath =
|
|
135
|
-
const warningStatsOutputPath =
|
|
154
|
+
const errorOutputPath = external_node_path_default().resolve(context.getSource(options.snapshot));
|
|
155
|
+
const errorStatsOutputPath = external_node_path_default().resolve(context.getSource(options.snapshotErrors));
|
|
156
|
+
const warningStatsOutputPath = external_node_path_default().resolve(context.getSource(options.snapshotWarning));
|
|
136
157
|
env.expect(output).toMatchFileSnapshotSync(errorOutputPath);
|
|
137
158
|
env.expect(errors).toMatchFileSnapshotSync(errorStatsOutputPath);
|
|
138
159
|
env.expect(warnings).toMatchFileSnapshotSync(warningStatsOutputPath);
|
|
139
160
|
}
|
|
161
|
+
exports.createDiagnosticCase = __webpack_exports__.createDiagnosticCase;
|
|
162
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
163
|
+
"createDiagnosticCase"
|
|
164
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
165
|
+
Object.defineProperty(exports, '__esModule', {
|
|
166
|
+
value: true
|
|
167
|
+
});
|
package/dist/case/error.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Compiler, RspackOptions, StatsError } from '@rspack/core';
|
|
2
|
-
import type { ITestContext } from '../type';
|
|
2
|
+
import type { ITestContext, MaybePromise } from '../type';
|
|
3
3
|
export declare function createErrorCase(name: string, src: string, dist: string, testConfig: string): void;
|
|
4
4
|
declare class RspackStatsDiagnostics {
|
|
5
5
|
errors: StatsError[];
|
|
@@ -10,8 +10,8 @@ export type TErrorCaseConfig = {
|
|
|
10
10
|
description: string;
|
|
11
11
|
skip?: boolean;
|
|
12
12
|
options?: (context: ITestContext) => RspackOptions;
|
|
13
|
-
compiler?: (context: ITestContext, compiler: Compiler) =>
|
|
14
|
-
build?: (context: ITestContext, compiler: Compiler) =>
|
|
15
|
-
check?: (stats: RspackStatsDiagnostics) =>
|
|
13
|
+
compiler?: (context: ITestContext, compiler: Compiler) => MaybePromise<void>;
|
|
14
|
+
build?: (context: ITestContext, compiler: Compiler) => MaybePromise<void>;
|
|
15
|
+
check?: (stats: RspackStatsDiagnostics) => MaybePromise<void>;
|
|
16
16
|
};
|
|
17
17
|
export {};
|
package/dist/case/error.js
CHANGED
|
@@ -1,139 +1,146 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
createErrorCase: ()=>createErrorCase
|
|
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 external_rspack_merge_namespaceObject = require("rspack-merge");
|
|
41
|
+
var external_rspack_merge_default = /*#__PURE__*/ __webpack_require__.n(external_rspack_merge_namespaceObject);
|
|
42
|
+
const creator_js_namespaceObject = require("../test/creator.js");
|
|
10
43
|
let addedSerializer = false;
|
|
11
|
-
const creator = new
|
|
44
|
+
const creator = new creator_js_namespaceObject.BasicCaseCreator({
|
|
12
45
|
clean: true,
|
|
13
46
|
describe: true,
|
|
14
|
-
steps: ({ name, caseConfig })
|
|
47
|
+
steps: ({ name, caseConfig })=>{
|
|
15
48
|
const config = caseConfig;
|
|
16
49
|
return [
|
|
17
50
|
{
|
|
18
|
-
config:
|
|
51
|
+
config: (context)=>{
|
|
19
52
|
const compiler = context.getCompiler();
|
|
20
|
-
compiler.setOptions(
|
|
53
|
+
compiler.setOptions(error_options(context, config.options));
|
|
21
54
|
},
|
|
22
|
-
compiler: async (context)
|
|
55
|
+
compiler: async (context)=>{
|
|
23
56
|
const compilerManager = context.getCompiler();
|
|
24
57
|
compilerManager.createCompiler();
|
|
25
|
-
|
|
58
|
+
await error_compiler(context, compilerManager.getCompiler(), config.compiler);
|
|
26
59
|
},
|
|
27
|
-
build: async (context)
|
|
60
|
+
build: async (context)=>{
|
|
28
61
|
const compiler = context.getCompiler();
|
|
29
|
-
if (typeof config.build
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
await compiler.build();
|
|
34
|
-
}
|
|
62
|
+
if ('function' == typeof config.build) await config.build(context, compiler.getCompiler());
|
|
63
|
+
else await compiler.build();
|
|
35
64
|
},
|
|
36
|
-
run: async (env, context)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
},
|
|
65
|
+
run: async (env, context)=>{},
|
|
66
|
+
check: async (env, context)=>{
|
|
67
|
+
await error_check(env, context, name, config.check);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
43
70
|
];
|
|
44
71
|
},
|
|
45
|
-
concurrent: true
|
|
72
|
+
concurrent: true
|
|
46
73
|
});
|
|
47
74
|
function createErrorCase(name, src, dist, testConfig) {
|
|
48
|
-
if (!addedSerializer)
|
|
49
|
-
addedSerializer = true;
|
|
50
|
-
}
|
|
75
|
+
if (!addedSerializer) addedSerializer = true;
|
|
51
76
|
const caseConfigList = require(testConfig);
|
|
52
77
|
function createCase(caseConfig) {
|
|
53
|
-
if (caseConfig.skip) {
|
|
54
|
-
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
creator.create(name, src, dist, undefined, {
|
|
78
|
+
if (caseConfig.skip) return void it.skip(name, ()=>{});
|
|
79
|
+
creator.create(name, src, dist, void 0, {
|
|
58
80
|
caseConfig,
|
|
59
|
-
description: ()
|
|
81
|
+
description: ()=>caseConfig.description
|
|
60
82
|
});
|
|
61
83
|
}
|
|
62
|
-
if (Array.isArray(caseConfigList))
|
|
63
|
-
|
|
64
|
-
createCase(caseConfig);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
createCase(caseConfigList);
|
|
69
|
-
}
|
|
84
|
+
if (Array.isArray(caseConfigList)) for (const caseConfig of caseConfigList)createCase(caseConfig);
|
|
85
|
+
else createCase(caseConfigList);
|
|
70
86
|
}
|
|
71
|
-
function
|
|
87
|
+
function error_options(context, custom) {
|
|
72
88
|
let options = {
|
|
73
|
-
context:
|
|
89
|
+
context: external_node_path_default().resolve(__TEST_FIXTURES_PATH__, 'errors'),
|
|
74
90
|
mode: 'none',
|
|
75
91
|
devtool: false,
|
|
76
92
|
optimization: {
|
|
77
93
|
minimize: false,
|
|
78
94
|
moduleIds: 'named',
|
|
79
|
-
chunkIds: 'named'
|
|
95
|
+
chunkIds: 'named'
|
|
80
96
|
},
|
|
81
97
|
module: {
|
|
82
98
|
defaultRules: [
|
|
83
99
|
{
|
|
84
100
|
test: /\.css$/i,
|
|
85
|
-
type: 'css/auto'
|
|
86
|
-
}
|
|
87
|
-
]
|
|
101
|
+
type: 'css/auto'
|
|
102
|
+
}
|
|
103
|
+
]
|
|
88
104
|
},
|
|
89
105
|
otuput: {
|
|
90
106
|
bundlerInfo: {
|
|
91
|
-
force: false
|
|
92
|
-
}
|
|
93
|
-
}
|
|
107
|
+
force: false
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
if ('function' == typeof custom) options = external_rspack_merge_default()(options, custom(context, options));
|
|
112
|
+
if ('production' === options.mode) if (options.optimization) options.optimization.minimize = true;
|
|
113
|
+
else options.optimization = {
|
|
114
|
+
minimize: true
|
|
94
115
|
};
|
|
95
|
-
if (typeof custom === 'function') {
|
|
96
|
-
options = (0, rspack_merge_1.default)(options, custom(context, options));
|
|
97
|
-
}
|
|
98
|
-
if (options.mode === 'production') {
|
|
99
|
-
if (options.optimization)
|
|
100
|
-
options.optimization.minimize = true;
|
|
101
|
-
else
|
|
102
|
-
options.optimization = { minimize: true };
|
|
103
|
-
}
|
|
104
116
|
return options;
|
|
105
117
|
}
|
|
106
|
-
async function
|
|
107
|
-
if (compiler) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
stat(file, callback) {
|
|
122
|
-
callback(new Error('ENOENT'));
|
|
123
|
-
},
|
|
124
|
-
mkdirSync() { },
|
|
125
|
-
writeFileSync() { },
|
|
126
|
-
};
|
|
127
|
-
}
|
|
118
|
+
async function error_compiler(context, compiler, custom) {
|
|
119
|
+
if (compiler) compiler.outputFileSystem = {
|
|
120
|
+
mkdir (dir, maybeOptionOrCallback, maybeCallback) {
|
|
121
|
+
if ('function' == typeof maybeOptionOrCallback) maybeOptionOrCallback();
|
|
122
|
+
else if ('function' == typeof maybeCallback) maybeCallback();
|
|
123
|
+
},
|
|
124
|
+
writeFile (file, content, callback) {
|
|
125
|
+
callback();
|
|
126
|
+
},
|
|
127
|
+
stat (file, callback) {
|
|
128
|
+
callback(new Error('ENOENT'));
|
|
129
|
+
},
|
|
130
|
+
mkdirSync () {},
|
|
131
|
+
writeFileSync () {}
|
|
132
|
+
};
|
|
128
133
|
await custom?.(context, compiler);
|
|
129
134
|
}
|
|
130
135
|
class RspackStatsDiagnostics {
|
|
131
|
-
|
|
136
|
+
errors;
|
|
137
|
+
warnings;
|
|
138
|
+
constructor(errors, warnings){
|
|
132
139
|
this.errors = errors;
|
|
133
140
|
this.warnings = warnings;
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
|
-
async function
|
|
143
|
+
async function error_check(env, context, name, check) {
|
|
137
144
|
if (context.getError().length > 0) {
|
|
138
145
|
await check?.(new RspackStatsDiagnostics(context.getError(), []));
|
|
139
146
|
context.clearError();
|
|
@@ -142,10 +149,19 @@ async function check(env, context, name, check) {
|
|
|
142
149
|
const compiler = context.getCompiler();
|
|
143
150
|
const stats = compiler.getStats();
|
|
144
151
|
env.expect(typeof stats).toBe('object');
|
|
145
|
-
const statsResult = stats.toJson({
|
|
152
|
+
const statsResult = stats.toJson({
|
|
153
|
+
errorDetails: false
|
|
154
|
+
});
|
|
146
155
|
env.expect(typeof statsResult).toBe('object');
|
|
147
156
|
const { errors, warnings } = statsResult;
|
|
148
157
|
env.expect(Array.isArray(errors)).toBe(true);
|
|
149
158
|
env.expect(Array.isArray(warnings)).toBe(true);
|
|
150
159
|
await check?.(new RspackStatsDiagnostics(errors, warnings));
|
|
151
160
|
}
|
|
161
|
+
exports.createErrorCase = __webpack_exports__.createErrorCase;
|
|
162
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
163
|
+
"createErrorCase"
|
|
164
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
165
|
+
Object.defineProperty(exports, '__esModule', {
|
|
166
|
+
value: true
|
|
167
|
+
});
|