@rspack-debug/test-tools 1.4.11 → 1.6.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/README.md +1 -1
- package/dist/case/builtin.d.ts +3 -0
- package/dist/case/builtin.js +152 -14
- package/dist/case/cache.d.ts +2 -2
- package/dist/case/cache.js +214 -12
- package/dist/case/common.d.ts +11 -0
- package/dist/case/common.js +249 -0
- package/dist/case/compiler.d.ts +17 -4
- package/dist/case/compiler.js +149 -12
- package/dist/case/config.d.ts +7 -2
- package/dist/case/config.js +106 -18
- package/dist/case/defaults.d.ts +13 -4
- package/dist/case/defaults.js +73 -18
- package/dist/case/diagnostic.d.ts +6 -0
- package/dist/case/diagnostic.js +121 -14
- package/dist/case/error.d.ts +15 -4
- package/dist/case/error.js +137 -12
- package/dist/case/esm-output.d.ts +1 -0
- package/dist/case/esm-output.js +117 -0
- package/dist/case/example.d.ts +1 -0
- package/dist/case/example.js +57 -0
- package/dist/case/hash.d.ts +2 -2
- package/dist/case/hash.js +72 -9
- package/dist/case/hook.d.ts +36 -4
- package/dist/case/hook.js +209 -20
- package/dist/case/hot-step.d.ts +2 -2
- package/dist/case/hot-step.js +309 -13
- package/dist/case/hot.d.ts +11 -2
- package/dist/case/hot.js +217 -12
- package/dist/case/incremental.d.ts +2 -2
- package/dist/case/incremental.js +24 -45
- package/dist/case/index.d.ts +31 -20
- package/dist/case/index.js +50 -34
- package/dist/case/multi-compiler.d.ts +19 -0
- package/dist/case/multi-compiler.js +97 -0
- package/dist/case/{nativeWatcher.js → native-watcher.js} +11 -23
- package/dist/case/normal.d.ts +3 -0
- package/dist/case/normal.js +202 -18
- package/dist/case/runner.d.ts +19 -0
- package/dist/case/runner.js +113 -0
- package/dist/case/serial.d.ts +2 -2
- package/dist/case/serial.js +10 -14
- package/dist/case/stats-api.d.ts +8 -3
- package/dist/case/stats-api.js +69 -10
- package/dist/case/stats-output.d.ts +11 -0
- package/dist/case/stats-output.js +199 -8
- package/dist/case/treeshaking.js +34 -7
- package/dist/case/watch.d.ts +27 -0
- package/dist/case/watch.js +318 -22
- package/dist/compiler.d.ts +16 -16
- package/dist/compiler.js +120 -15
- package/dist/helper/directory.d.ts +1 -1
- package/dist/helper/directory.js +6 -2
- package/dist/helper/disable-iconv-lite-warning.d.ts +1 -0
- package/dist/helper/disable-iconv-lite-warning.js +12 -0
- package/dist/helper/expect/error.js +1 -1
- package/dist/helper/expect/placeholder.js +7 -7
- package/dist/helper/expect/to-match-file-snapshot.d.ts +1 -2
- package/dist/helper/expect/to-match-file-snapshot.js +3 -3
- package/dist/helper/hot-update/loader.d.ts +2 -1
- package/dist/helper/hot-update/loader.js +5 -30
- package/dist/helper/hot-update/plugin.d.ts +1 -1
- package/dist/helper/hot-update/plugin.js +14 -13
- package/dist/helper/index.d.ts +2 -1
- package/dist/helper/index.js +2 -1
- package/dist/helper/is.d.ts +2 -0
- package/dist/helper/is.js +15 -0
- package/dist/helper/legacy/LogTestPlugin.d.ts +6 -0
- package/dist/helper/legacy/LogTestPlugin.js +35 -0
- package/dist/helper/legacy/asModule.js +0 -2
- package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -1
- package/dist/helper/legacy/checkArrayExpectation.js +8 -8
- package/dist/helper/legacy/createFakeWorker.d.ts +2 -2
- package/dist/helper/legacy/createFakeWorker.js +44 -20
- package/dist/helper/legacy/createLazyTestEnv.d.ts +3 -2
- package/dist/helper/legacy/createLazyTestEnv.js +3 -3
- package/dist/helper/legacy/deprecationTracking.d.ts +1 -0
- package/dist/helper/legacy/deprecationTracking.js +41 -0
- package/dist/helper/legacy/expectSource.d.ts +10 -0
- package/dist/helper/legacy/expectSource.js +23 -0
- package/dist/helper/legacy/findOutputFiles.d.ts +6 -0
- package/dist/helper/legacy/findOutputFiles.js +14 -0
- package/dist/helper/legacy/regexEscape.d.ts +2 -0
- package/dist/helper/legacy/regexEscape.js +5 -0
- package/dist/helper/legacy/supportDefaultAssignment.js +13 -0
- package/dist/helper/legacy/supportsTextDecoder.d.ts +2 -0
- package/dist/helper/legacy/supportsTextDecoder.js +9 -0
- package/dist/helper/legacy/supportsUsing.d.ts +2 -0
- package/dist/helper/legacy/supportsUsing.js +26 -0
- package/dist/helper/legacy/urlToRelativePath.js +5 -2
- package/dist/helper/read-config-file.d.ts +3 -2
- package/dist/helper/read-config-file.js +12 -2
- package/dist/helper/setup-env.js +26 -4
- package/dist/helper/setup-expect.js +2 -2
- package/dist/helper/setup-wasm.js +2 -2
- package/dist/helper/stringify-config.d.ts +2 -0
- package/dist/helper/stringify-config.js +43 -0
- package/dist/helper/util/checkStats.d.ts +0 -1
- package/dist/helper/util/checkStats.js +0 -18
- package/dist/helper/util/expectWarningFactory.js +2 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.js +1 -4
- package/dist/plugin/index.d.ts +0 -3
- package/dist/plugin/index.js +0 -3
- package/dist/plugin/lazy-compilation-test-plugin.js +4 -4
- package/dist/runner/index.d.ts +2 -9
- package/dist/runner/index.js +2 -9
- package/dist/runner/node/index.d.ts +41 -0
- package/dist/runner/node/index.js +450 -0
- package/dist/runner/web/index.d.ts +30 -0
- package/dist/runner/web/index.js +343 -0
- package/dist/test/context.d.ts +15 -18
- package/dist/test/context.js +52 -57
- package/dist/test/creator.d.ts +20 -19
- package/dist/test/creator.js +69 -57
- package/dist/test/debug.d.ts +15 -0
- package/dist/test/debug.js +205 -0
- package/dist/test/tester.d.ts +1 -0
- package/dist/test/tester.js +44 -6
- package/dist/type.d.ts +94 -64
- package/dist/type.js +8 -12
- package/package.json +22 -61
- package/rstest.d.ts +24 -0
- package/dist/case/diff.d.ts +0 -3
- package/dist/case/diff.js +0 -126
- package/dist/compare/comparator.d.ts +0 -17
- package/dist/compare/comparator.js +0 -52
- package/dist/compare/compare.d.ts +0 -17
- package/dist/compare/compare.js +0 -175
- package/dist/compare/format-code.d.ts +0 -16
- package/dist/compare/format-code.js +0 -239
- package/dist/compare/index.d.ts +0 -5
- package/dist/compare/index.js +0 -21
- package/dist/compare/replace-module-argument.d.ts +0 -1
- package/dist/compare/replace-module-argument.js +0 -8
- package/dist/compare/replace-runtime-module-name.d.ts +0 -1
- package/dist/compare/replace-runtime-module-name.js +0 -71
- package/dist/helper/legacy/FakeDocument.d.ts +0 -54
- package/dist/helper/legacy/FakeDocument.js +0 -278
- package/dist/helper/legacy/createLogger.d.ts +0 -23
- package/dist/helper/legacy/createLogger.js +0 -20
- package/dist/helper/legacy/supportsImportFn.d.ts +0 -1
- package/dist/helper/legacy/supportsImportFn.js +0 -15
- package/dist/helper/legacy/supportsWorker.js +0 -17
- package/dist/helper/legacy/walkCssTokens.d.ts +0 -40
- package/dist/helper/legacy/walkCssTokens.js +0 -761
- package/dist/helper/legacy/warmup-webpack.d.ts +0 -1
- package/dist/helper/legacy/warmup-webpack.js +0 -26
- package/dist/helper/loaders/hot-update.d.ts +0 -1
- package/dist/helper/loaders/hot-update.js +0 -40
- package/dist/helper/plugins/hot-update.d.ts +0 -7
- package/dist/helper/plugins/hot-update.js +0 -40
- package/dist/helper/plugins/index.d.ts +0 -1
- package/dist/helper/plugins/index.js +0 -17
- package/dist/helper/util/currentWatchStep.d.ts +0 -1
- package/dist/helper/util/currentWatchStep.js +0 -2
- package/dist/helper/util/identifier.d.ts +0 -76
- package/dist/helper/util/identifier.js +0 -339
- package/dist/helper/util/replaceMitteDiagnostic.d.ts +0 -2
- package/dist/helper/util/replaceMitteDiagnostic.js +0 -17
- package/dist/plugin/rspack-diff-config-plugin.d.ts +0 -7
- package/dist/plugin/rspack-diff-config-plugin.js +0 -42
- package/dist/plugin/webpack-diff-config-plugin.d.ts +0 -7
- package/dist/plugin/webpack-diff-config-plugin.js +0 -41
- package/dist/plugin/webpack-module-placeholder-plugin.d.ts +0 -3
- package/dist/plugin/webpack-module-placeholder-plugin.js +0 -106
- package/dist/processor/basic.d.ts +0 -24
- package/dist/processor/basic.js +0 -146
- package/dist/processor/builtin.d.ts +0 -9
- package/dist/processor/builtin.js +0 -171
- package/dist/processor/cache.d.ts +0 -20
- package/dist/processor/cache.js +0 -128
- package/dist/processor/config.d.ts +0 -11
- package/dist/processor/config.js +0 -81
- package/dist/processor/defaults.d.ts +0 -30
- package/dist/processor/defaults.js +0 -72
- package/dist/processor/diagnostic.d.ts +0 -15
- package/dist/processor/diagnostic.js +0 -102
- package/dist/processor/diff.d.ts +0 -30
- package/dist/processor/diff.js +0 -140
- package/dist/processor/error.d.ts +0 -23
- package/dist/processor/error.js +0 -95
- package/dist/processor/hash.d.ts +0 -10
- package/dist/processor/hash.js +0 -63
- package/dist/processor/hook.d.ts +0 -44
- package/dist/processor/hook.js +0 -204
- package/dist/processor/hot-incremental.d.ts +0 -14
- package/dist/processor/hot-incremental.js +0 -43
- package/dist/processor/hot-step.d.ts +0 -18
- package/dist/processor/hot-step.js +0 -304
- package/dist/processor/hot.d.ts +0 -17
- package/dist/processor/hot.js +0 -140
- package/dist/processor/index.d.ts +0 -20
- package/dist/processor/index.js +0 -36
- package/dist/processor/multi.d.ts +0 -17
- package/dist/processor/multi.js +0 -73
- package/dist/processor/normal.d.ts +0 -12
- package/dist/processor/normal.js +0 -150
- package/dist/processor/simple.d.ts +0 -23
- package/dist/processor/simple.js +0 -49
- package/dist/processor/snapshot.d.ts +0 -12
- package/dist/processor/snapshot.js +0 -66
- package/dist/processor/stats-api.d.ts +0 -18
- package/dist/processor/stats-api.js +0 -48
- package/dist/processor/stats.d.ts +0 -18
- package/dist/processor/stats.js +0 -206
- package/dist/processor/treeshaking.d.ts +0 -10
- package/dist/processor/treeshaking.js +0 -33
- package/dist/processor/watch.d.ts +0 -30
- package/dist/processor/watch.js +0 -241
- package/dist/reporter/diff-html.d.ts +0 -15
- package/dist/reporter/diff-html.js +0 -69
- package/dist/reporter/diff-stats.d.ts +0 -24
- package/dist/reporter/diff-stats.js +0 -131
- package/dist/reporter/index.d.ts +0 -2
- package/dist/reporter/index.js +0 -18
- package/dist/runner/basic.d.ts +0 -10
- package/dist/runner/basic.js +0 -63
- package/dist/runner/cache.d.ts +0 -5
- package/dist/runner/cache.js +0 -90
- package/dist/runner/hot-step.d.ts +0 -5
- package/dist/runner/hot-step.js +0 -87
- package/dist/runner/hot.d.ts +0 -5
- package/dist/runner/hot.js +0 -83
- package/dist/runner/multiple.d.ts +0 -11
- package/dist/runner/multiple.js +0 -38
- package/dist/runner/normal.d.ts +0 -5
- package/dist/runner/normal.js +0 -20
- package/dist/runner/runner/basic.d.ts +0 -30
- package/dist/runner/runner/basic.js +0 -107
- package/dist/runner/runner/cjs.d.ts +0 -14
- package/dist/runner/runner/cjs.js +0 -151
- package/dist/runner/runner/esm.d.ts +0 -7
- package/dist/runner/runner/esm.js +0 -125
- package/dist/runner/runner/index.d.ts +0 -8
- package/dist/runner/runner/index.js +0 -24
- package/dist/runner/runner/normal.d.ts +0 -9
- package/dist/runner/runner/normal.js +0 -23
- package/dist/runner/runner/watch.d.ts +0 -16
- package/dist/runner/runner/watch.js +0 -27
- package/dist/runner/runner/web/fake.d.ts +0 -18
- package/dist/runner/runner/web/fake.js +0 -143
- package/dist/runner/runner/web/jsdom.d.ts +0 -26
- package/dist/runner/runner/web/jsdom.js +0 -219
- package/dist/runner/runner/web.d.ts +0 -15
- package/dist/runner/runner/web.js +0 -32
- package/dist/runner/type.d.ts +0 -42
- package/dist/runner/type.js +0 -9
- package/dist/runner/watch.d.ts +0 -7
- package/dist/runner/watch.js +0 -60
- package/dist/test/simple.d.ts +0 -5
- package/dist/test/simple.js +0 -43
- package/jest.d.ts +0 -25
- package/template/diff.bundle.css +0 -1
- package/template/diff.bundle.js +0 -144
- package/template/diff.html +0 -14
- package/template/editor.worker.js +0 -1
- /package/dist/case/{nativeWatcher.d.ts → native-watcher.d.ts} +0 -0
- /package/dist/helper/legacy/{supportsWorker.d.ts → supportDefaultAssignment.d.ts} +0 -0
package/dist/case/incremental.js
CHANGED
|
@@ -7,12 +7,13 @@ exports.createHotIncrementalCase = createHotIncrementalCase;
|
|
|
7
7
|
exports.createWatchIncrementalCase = createWatchIncrementalCase;
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const hot_incremental_1 = require("../processor/hot-incremental");
|
|
11
|
-
const watch_1 = require("../processor/watch");
|
|
12
|
-
const runner_1 = require("../runner");
|
|
13
10
|
const creator_1 = require("../test/creator");
|
|
14
|
-
const
|
|
11
|
+
const hot_1 = require("./hot");
|
|
12
|
+
const watch_1 = require("./watch");
|
|
15
13
|
const hotCreators = new Map();
|
|
14
|
+
function createHotIncrementalProcessor(name, src, temp, target, webpackCases) {
|
|
15
|
+
return (0, hot_1.createHotProcessor)(name, src, temp, target, true);
|
|
16
|
+
}
|
|
16
17
|
function getHotCreator(target, webpackCases) {
|
|
17
18
|
const key = JSON.stringify({ target, webpackCases });
|
|
18
19
|
if (!hotCreators.has(key)) {
|
|
@@ -20,24 +21,21 @@ function getHotCreator(target, webpackCases) {
|
|
|
20
21
|
clean: true,
|
|
21
22
|
describe: true,
|
|
22
23
|
target,
|
|
23
|
-
steps: ({ name, target }) => [
|
|
24
|
-
|
|
25
|
-
name,
|
|
26
|
-
target: target,
|
|
27
|
-
compilerType: type_1.ECompilerType.Rspack,
|
|
28
|
-
configFiles: ["rspack.config.js", "webpack.config.js"],
|
|
29
|
-
webpackCases
|
|
30
|
-
})
|
|
24
|
+
steps: ({ name, target, src, temp, dist }) => [
|
|
25
|
+
createHotIncrementalProcessor(name, src, temp || node_path_1.default.resolve(dist, "temp"), target, webpackCases)
|
|
31
26
|
],
|
|
32
|
-
runner:
|
|
27
|
+
runner: {
|
|
28
|
+
key: (context, name, file) => name,
|
|
29
|
+
runner: hot_1.createHotRunner
|
|
30
|
+
},
|
|
33
31
|
concurrent: true
|
|
34
32
|
}));
|
|
35
33
|
}
|
|
36
34
|
return hotCreators.get(key);
|
|
37
35
|
}
|
|
38
|
-
function createHotIncrementalCase(name, src, dist, target, webpackCases) {
|
|
36
|
+
function createHotIncrementalCase(name, src, dist, temp, target, webpackCases) {
|
|
39
37
|
const creator = getHotCreator(target, webpackCases);
|
|
40
|
-
creator.create(name, src, dist);
|
|
38
|
+
creator.create(name, src, dist, temp);
|
|
41
39
|
}
|
|
42
40
|
const watchCreators = new Map();
|
|
43
41
|
function getWatchCreator(options) {
|
|
@@ -45,7 +43,10 @@ function getWatchCreator(options) {
|
|
|
45
43
|
if (!watchCreators.has(key)) {
|
|
46
44
|
watchCreators.set(key, new creator_1.BasicCaseCreator({
|
|
47
45
|
clean: true,
|
|
48
|
-
runner:
|
|
46
|
+
runner: {
|
|
47
|
+
key: watch_1.getWatchRunnerKey,
|
|
48
|
+
runner: watch_1.createWatchRunner
|
|
49
|
+
},
|
|
49
50
|
description: (name, index) => {
|
|
50
51
|
return index === 0
|
|
51
52
|
? `${name} should compile`
|
|
@@ -57,37 +58,15 @@ function getWatchCreator(options) {
|
|
|
57
58
|
const runs = node_fs_1.default
|
|
58
59
|
.readdirSync(src)
|
|
59
60
|
.sort()
|
|
60
|
-
.filter(name =>
|
|
61
|
-
return node_fs_1.default.statSync(node_path_1.default.join(src, name)).isDirectory();
|
|
62
|
-
})
|
|
61
|
+
.filter(name => node_fs_1.default.statSync(node_path_1.default.join(src, name)).isDirectory())
|
|
63
62
|
.map(name => ({ name }));
|
|
64
63
|
return runs.map((run, index) => index === 0
|
|
65
|
-
?
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
configFiles: ["rspack.config.js", "webpack.config.js"],
|
|
72
|
-
defaultOptions(index, context) {
|
|
73
|
-
return {
|
|
74
|
-
experiments: {
|
|
75
|
-
incremental: "advance"
|
|
76
|
-
},
|
|
77
|
-
ignoreWarnings: options.ignoreNotFriendlyForIncrementalWarnings
|
|
78
|
-
? [/is not friendly for incremental/]
|
|
79
|
-
: undefined
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}, watchState)
|
|
83
|
-
: new watch_1.WatchStepProcessor({
|
|
84
|
-
name,
|
|
85
|
-
stepName: run.name,
|
|
86
|
-
tempDir: temp,
|
|
87
|
-
runable: true,
|
|
88
|
-
compilerType: type_1.ECompilerType.Rspack,
|
|
89
|
-
configFiles: ["rspack.config.js", "webpack.config.js"]
|
|
90
|
-
}, watchState));
|
|
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
|
+
}));
|
|
91
70
|
},
|
|
92
71
|
concurrent: true
|
|
93
72
|
}));
|
package/dist/case/index.d.ts
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
1
|
+
export { createBuiltinCase } from "./builtin";
|
|
2
|
+
export { createCacheCase } from "./cache";
|
|
3
|
+
export type { TCompilerCaseConfig } from "./compiler";
|
|
4
|
+
export { createCompilerCase } from "./compiler";
|
|
5
|
+
export type { TConfigCaseConfig } from "./config";
|
|
6
|
+
export { createConfigCase } from "./config";
|
|
7
|
+
export type { TDefaultsCaseConfig } from "./defaults";
|
|
8
|
+
export { createDefaultsCase, getRspackDefaultConfig } from "./defaults";
|
|
9
|
+
export type { TDiagnosticOptions } from "./diagnostic";
|
|
10
|
+
export { createDiagnosticCase } from "./diagnostic";
|
|
11
|
+
export type { TErrorCaseConfig } from "./error";
|
|
12
|
+
export { createErrorCase } from "./error";
|
|
13
|
+
export { createEsmOutputCase } from "./esm-output";
|
|
14
|
+
export { createExampleCase } from "./example";
|
|
15
|
+
export type { THashCaseConfig } from "./hash";
|
|
16
|
+
export { createHashCase } from "./hash";
|
|
17
|
+
export type { THookCaseConfig } from "./hook";
|
|
18
|
+
export { createHookCase } from "./hook";
|
|
19
|
+
export { createHotCase } from "./hot";
|
|
20
|
+
export { createHotStepCase } from "./hot-step";
|
|
21
|
+
export { createHotIncrementalCase, createWatchIncrementalCase } from "./incremental";
|
|
22
|
+
export type { TMultiCompilerCaseConfig } from "./multi-compiler";
|
|
23
|
+
export { createMultiCompilerCase } from "./multi-compiler";
|
|
24
|
+
export { createNativeWatcher } from "./native-watcher";
|
|
25
|
+
export { createDevNormalCase, createHotNormalCase, createNormalCase, createProdNormalCase } from "./normal";
|
|
26
|
+
export { createSerialCase } from "./serial";
|
|
27
|
+
export type { TStatsAPICaseConfig } from "./stats-api";
|
|
28
|
+
export { createStatsAPICase } from "./stats-api";
|
|
29
|
+
export { createStatsOutputCase } from "./stats-output";
|
|
30
|
+
export { createTreeShakingCase } from "./treeshaking";
|
|
31
|
+
export { createWatchCase } from "./watch";
|
package/dist/case/index.js
CHANGED
|
@@ -1,36 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
3
|
+
exports.createWatchCase = exports.createTreeShakingCase = exports.createStatsOutputCase = exports.createStatsAPICase = exports.createSerialCase = exports.createProdNormalCase = exports.createNormalCase = exports.createHotNormalCase = exports.createDevNormalCase = exports.createNativeWatcher = exports.createMultiCompilerCase = exports.createWatchIncrementalCase = exports.createHotIncrementalCase = exports.createHotStepCase = exports.createHotCase = exports.createHookCase = exports.createHashCase = exports.createExampleCase = exports.createEsmOutputCase = exports.createErrorCase = exports.createDiagnosticCase = exports.getRspackDefaultConfig = exports.createDefaultsCase = exports.createConfigCase = exports.createCompilerCase = exports.createCacheCase = exports.createBuiltinCase = void 0;
|
|
4
|
+
var builtin_1 = require("./builtin");
|
|
5
|
+
Object.defineProperty(exports, "createBuiltinCase", { enumerable: true, get: function () { return builtin_1.createBuiltinCase; } });
|
|
6
|
+
var cache_1 = require("./cache");
|
|
7
|
+
Object.defineProperty(exports, "createCacheCase", { enumerable: true, get: function () { return cache_1.createCacheCase; } });
|
|
8
|
+
var compiler_1 = require("./compiler");
|
|
9
|
+
Object.defineProperty(exports, "createCompilerCase", { enumerable: true, get: function () { return compiler_1.createCompilerCase; } });
|
|
10
|
+
var config_1 = require("./config");
|
|
11
|
+
Object.defineProperty(exports, "createConfigCase", { enumerable: true, get: function () { return config_1.createConfigCase; } });
|
|
12
|
+
var defaults_1 = require("./defaults");
|
|
13
|
+
Object.defineProperty(exports, "createDefaultsCase", { enumerable: true, get: function () { return defaults_1.createDefaultsCase; } });
|
|
14
|
+
Object.defineProperty(exports, "getRspackDefaultConfig", { enumerable: true, get: function () { return defaults_1.getRspackDefaultConfig; } });
|
|
15
|
+
var diagnostic_1 = require("./diagnostic");
|
|
16
|
+
Object.defineProperty(exports, "createDiagnosticCase", { enumerable: true, get: function () { return diagnostic_1.createDiagnosticCase; } });
|
|
17
|
+
var error_1 = require("./error");
|
|
18
|
+
Object.defineProperty(exports, "createErrorCase", { enumerable: true, get: function () { return error_1.createErrorCase; } });
|
|
19
|
+
var esm_output_1 = require("./esm-output");
|
|
20
|
+
Object.defineProperty(exports, "createEsmOutputCase", { enumerable: true, get: function () { return esm_output_1.createEsmOutputCase; } });
|
|
21
|
+
var example_1 = require("./example");
|
|
22
|
+
Object.defineProperty(exports, "createExampleCase", { enumerable: true, get: function () { return example_1.createExampleCase; } });
|
|
23
|
+
var hash_1 = require("./hash");
|
|
24
|
+
Object.defineProperty(exports, "createHashCase", { enumerable: true, get: function () { return hash_1.createHashCase; } });
|
|
25
|
+
var hook_1 = require("./hook");
|
|
26
|
+
Object.defineProperty(exports, "createHookCase", { enumerable: true, get: function () { return hook_1.createHookCase; } });
|
|
27
|
+
var hot_1 = require("./hot");
|
|
28
|
+
Object.defineProperty(exports, "createHotCase", { enumerable: true, get: function () { return hot_1.createHotCase; } });
|
|
29
|
+
var hot_step_1 = require("./hot-step");
|
|
30
|
+
Object.defineProperty(exports, "createHotStepCase", { enumerable: true, get: function () { return hot_step_1.createHotStepCase; } });
|
|
31
|
+
var incremental_1 = require("./incremental");
|
|
32
|
+
Object.defineProperty(exports, "createHotIncrementalCase", { enumerable: true, get: function () { return incremental_1.createHotIncrementalCase; } });
|
|
33
|
+
Object.defineProperty(exports, "createWatchIncrementalCase", { enumerable: true, get: function () { return incremental_1.createWatchIncrementalCase; } });
|
|
34
|
+
var multi_compiler_1 = require("./multi-compiler");
|
|
35
|
+
Object.defineProperty(exports, "createMultiCompilerCase", { enumerable: true, get: function () { return multi_compiler_1.createMultiCompilerCase; } });
|
|
36
|
+
var native_watcher_1 = require("./native-watcher");
|
|
37
|
+
Object.defineProperty(exports, "createNativeWatcher", { enumerable: true, get: function () { return native_watcher_1.createNativeWatcher; } });
|
|
38
|
+
var normal_1 = require("./normal");
|
|
39
|
+
Object.defineProperty(exports, "createDevNormalCase", { enumerable: true, get: function () { return normal_1.createDevNormalCase; } });
|
|
40
|
+
Object.defineProperty(exports, "createHotNormalCase", { enumerable: true, get: function () { return normal_1.createHotNormalCase; } });
|
|
41
|
+
Object.defineProperty(exports, "createNormalCase", { enumerable: true, get: function () { return normal_1.createNormalCase; } });
|
|
42
|
+
Object.defineProperty(exports, "createProdNormalCase", { enumerable: true, get: function () { return normal_1.createProdNormalCase; } });
|
|
43
|
+
var serial_1 = require("./serial");
|
|
44
|
+
Object.defineProperty(exports, "createSerialCase", { enumerable: true, get: function () { return serial_1.createSerialCase; } });
|
|
45
|
+
var stats_api_1 = require("./stats-api");
|
|
46
|
+
Object.defineProperty(exports, "createStatsAPICase", { enumerable: true, get: function () { return stats_api_1.createStatsAPICase; } });
|
|
47
|
+
var stats_output_1 = require("./stats-output");
|
|
48
|
+
Object.defineProperty(exports, "createStatsOutputCase", { enumerable: true, get: function () { return stats_output_1.createStatsOutputCase; } });
|
|
49
|
+
var treeshaking_1 = require("./treeshaking");
|
|
50
|
+
Object.defineProperty(exports, "createTreeShakingCase", { enumerable: true, get: function () { return treeshaking_1.createTreeShakingCase; } });
|
|
51
|
+
var watch_1 = require("./watch");
|
|
52
|
+
Object.defineProperty(exports, "createWatchCase", { enumerable: true, get: function () { return watch_1.createWatchCase; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Compilation, Compiler, RspackOptions, Stats, StatsCompilation } from "@rspack/core";
|
|
2
|
+
import type { ITestContext } from "../type";
|
|
3
|
+
export declare function createMultiCompilerCase(name: string, src: string, dist: string, testConfig: string): void;
|
|
4
|
+
export type TMultiCompilerCaseConfig = {
|
|
5
|
+
description: string;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
skip?: boolean;
|
|
8
|
+
options?: (context: ITestContext) => RspackOptions;
|
|
9
|
+
compiler?: (context: ITestContext, compiler: Compiler) => Promise<void>;
|
|
10
|
+
build?: (context: ITestContext, compiler: Compiler) => Promise<void>;
|
|
11
|
+
check?: ({ context, stats, files, compiler, compilation }: {
|
|
12
|
+
context: ITestContext;
|
|
13
|
+
stats?: StatsCompilation;
|
|
14
|
+
files?: Record<string, string>;
|
|
15
|
+
compiler: Compiler;
|
|
16
|
+
compilation?: Compilation;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
compilerCallback?: (error: Error | null, stats: Stats | null) => void;
|
|
19
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
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.createMultiCompilerCase = createMultiCompilerCase;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const memfs_1 = require("memfs");
|
|
9
|
+
const creator_1 = require("../test/creator");
|
|
10
|
+
function createMultiCompilerProcessor(name, caseConfig) {
|
|
11
|
+
return {
|
|
12
|
+
config: async (context) => {
|
|
13
|
+
const compiler = context.getCompiler();
|
|
14
|
+
const options = Object.assign([
|
|
15
|
+
{
|
|
16
|
+
name: "a",
|
|
17
|
+
context: node_path_1.default.join(__dirname, "fixtures"),
|
|
18
|
+
entry: "./a.js"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "b",
|
|
22
|
+
context: node_path_1.default.join(__dirname, "fixtures"),
|
|
23
|
+
entry: "./b.js"
|
|
24
|
+
}
|
|
25
|
+
], caseConfig.options?.(context) || {});
|
|
26
|
+
compiler.setOptions(options);
|
|
27
|
+
},
|
|
28
|
+
compiler: async (context) => {
|
|
29
|
+
const compiler = context.getCompiler();
|
|
30
|
+
if (caseConfig.compilerCallback) {
|
|
31
|
+
compiler.createCompilerWithCallback(caseConfig.compilerCallback);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
compiler.createCompiler();
|
|
35
|
+
}
|
|
36
|
+
const c = compiler.getCompiler();
|
|
37
|
+
c.outputFileSystem = (0, memfs_1.createFsFromVolume)(new memfs_1.Volume());
|
|
38
|
+
c.watchFileSystem = {
|
|
39
|
+
watch() {
|
|
40
|
+
// watch should return a watcher instance
|
|
41
|
+
// watcher instance should have close, pause and getInfo methods
|
|
42
|
+
return {
|
|
43
|
+
close: () => { },
|
|
44
|
+
pause: () => { },
|
|
45
|
+
getInfo: () => {
|
|
46
|
+
return {
|
|
47
|
+
changes: new Set(),
|
|
48
|
+
removals: new Set(),
|
|
49
|
+
fileTimeInfoEntries: new Map(),
|
|
50
|
+
directoryTimeInfoEntries: new Map()
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
await caseConfig.compiler?.(context, c);
|
|
57
|
+
},
|
|
58
|
+
build: async (context) => {
|
|
59
|
+
const compiler = context.getCompiler();
|
|
60
|
+
if (typeof caseConfig.build === "function") {
|
|
61
|
+
await caseConfig.build?.(context, compiler.getCompiler());
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
await compiler.build();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
run: async (env, context) => { },
|
|
68
|
+
check: async (env, context) => { }
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const creator = new creator_1.BasicCaseCreator({
|
|
72
|
+
clean: true,
|
|
73
|
+
describe: false,
|
|
74
|
+
steps: ({ name, caseConfig }) => {
|
|
75
|
+
return [
|
|
76
|
+
createMultiCompilerProcessor(name, caseConfig)
|
|
77
|
+
];
|
|
78
|
+
},
|
|
79
|
+
concurrent: false
|
|
80
|
+
});
|
|
81
|
+
function createMultiCompilerCase(name, src, dist, testConfig) {
|
|
82
|
+
let caseConfigList = require(testConfig);
|
|
83
|
+
if (!Array.isArray(caseConfigList)) {
|
|
84
|
+
caseConfigList = [caseConfigList];
|
|
85
|
+
}
|
|
86
|
+
for (let i = 0; i < caseConfigList.length; i++) {
|
|
87
|
+
const caseConfig = caseConfigList[i];
|
|
88
|
+
if (caseConfig.skip) {
|
|
89
|
+
it.skip(`${name}[${i}]`, () => { });
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
creator.create(`${name}[${i}]`, src, dist, undefined, {
|
|
93
|
+
caseConfig,
|
|
94
|
+
description: () => caseConfig.description
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -6,13 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createNativeWatcher = createNativeWatcher;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const watch_1 = require("../processor/watch");
|
|
10
|
-
const runner_1 = require("../runner");
|
|
11
9
|
const creator_1 = require("../test/creator");
|
|
12
|
-
const
|
|
10
|
+
const watch_1 = require("./watch");
|
|
13
11
|
const creator = new creator_1.BasicCaseCreator({
|
|
14
12
|
clean: true,
|
|
15
|
-
runner:
|
|
13
|
+
runner: {
|
|
14
|
+
key: watch_1.getWatchRunnerKey,
|
|
15
|
+
runner: watch_1.createWatchRunner
|
|
16
|
+
},
|
|
16
17
|
description: (name, index) => {
|
|
17
18
|
return index === 0
|
|
18
19
|
? `${name} should compile`
|
|
@@ -24,28 +25,15 @@ const creator = new creator_1.BasicCaseCreator({
|
|
|
24
25
|
const runs = node_fs_1.default
|
|
25
26
|
.readdirSync(src)
|
|
26
27
|
.sort()
|
|
27
|
-
.filter(name =>
|
|
28
|
-
return node_fs_1.default.statSync(node_path_1.default.join(src, name)).isDirectory();
|
|
29
|
-
})
|
|
28
|
+
.filter(name => node_fs_1.default.statSync(node_path_1.default.join(src, name)).isDirectory())
|
|
30
29
|
.map(name => ({ name }));
|
|
31
30
|
return runs.map((run, index) => index === 0
|
|
32
|
-
?
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
runable: true,
|
|
37
|
-
compilerType: type_1.ECompilerType.Rspack,
|
|
38
|
-
configFiles: ["rspack.config.js", "webpack.config.js"],
|
|
31
|
+
? (0, watch_1.createWatchInitialProcessor)(name, temp, run.name, watchState, {
|
|
32
|
+
nativeWatcher: true
|
|
33
|
+
})
|
|
34
|
+
: (0, watch_1.createWatchStepProcessor)(name, temp, run.name, watchState, {
|
|
39
35
|
nativeWatcher: true
|
|
40
|
-
}
|
|
41
|
-
: new watch_1.WatchStepProcessor({
|
|
42
|
-
name,
|
|
43
|
-
stepName: run.name,
|
|
44
|
-
tempDir: temp,
|
|
45
|
-
runable: true,
|
|
46
|
-
compilerType: type_1.ECompilerType.Rspack,
|
|
47
|
-
configFiles: ["rspack.config.js", "webpack.config.js"]
|
|
48
|
-
}, watchState));
|
|
36
|
+
}));
|
|
49
37
|
},
|
|
50
38
|
concurrent: true
|
|
51
39
|
});
|
package/dist/case/normal.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
1
|
export declare function createNormalCase(name: string, src: string, dist: string): void;
|
|
2
|
+
export declare function createHotNormalCase(name: string, src: string, dist: string): void;
|
|
3
|
+
export declare function createDevNormalCase(name: string, src: string, dist: string): void;
|
|
4
|
+
export declare function createProdNormalCase(name: string, src: string, dist: string): void;
|
package/dist/case/normal.js
CHANGED
|
@@ -4,26 +4,210 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createNormalCase = createNormalCase;
|
|
7
|
+
exports.createHotNormalCase = createHotNormalCase;
|
|
8
|
+
exports.createDevNormalCase = createDevNormalCase;
|
|
9
|
+
exports.createProdNormalCase = createProdNormalCase;
|
|
10
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
7
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const
|
|
9
|
-
const runner_1 = require("../runner");
|
|
12
|
+
const core_1 = require("@rspack/core");
|
|
10
13
|
const creator_1 = require("../test/creator");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
const common_1 = require("./common");
|
|
15
|
+
const runner_1 = require("./runner");
|
|
16
|
+
const NORMAL_CASES_ROOT = node_path_1.default.resolve(__TEST_PATH__, "normalCases");
|
|
17
|
+
const createCaseOptions = (hot, mode) => {
|
|
18
|
+
return {
|
|
19
|
+
clean: true,
|
|
20
|
+
describe: false,
|
|
21
|
+
steps: ({ name }) => [
|
|
22
|
+
{
|
|
23
|
+
config: async (context) => {
|
|
24
|
+
const compiler = context.getCompiler();
|
|
25
|
+
let options = defaultOptions(context, {
|
|
26
|
+
plugins: hot ? [new core_1.HotModuleReplacementPlugin()] : []
|
|
27
|
+
}, mode);
|
|
28
|
+
options = await (0, common_1.config)(context, name, ["rspack.config.js", "webpack.config.js"], options);
|
|
29
|
+
overrideOptions(context, options);
|
|
30
|
+
compiler.setOptions(options);
|
|
31
|
+
},
|
|
32
|
+
compiler: async (context) => {
|
|
33
|
+
await (0, common_1.compiler)(context, name);
|
|
34
|
+
},
|
|
35
|
+
build: async (context) => {
|
|
36
|
+
await (0, common_1.build)(context, name);
|
|
37
|
+
},
|
|
38
|
+
run: async (env, context) => {
|
|
39
|
+
await (0, common_1.run)(env, context, name, findBundle);
|
|
40
|
+
},
|
|
41
|
+
check: async (env, context) => {
|
|
42
|
+
await (0, common_1.check)(env, context, name);
|
|
43
|
+
},
|
|
44
|
+
after: async (context) => {
|
|
45
|
+
await (0, common_1.afterExecute)(context, name);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
runner: {
|
|
50
|
+
key: (context, name, file) => name,
|
|
51
|
+
runner: runner_1.createRunner
|
|
52
|
+
},
|
|
53
|
+
concurrent: true
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const creator = new creator_1.BasicCaseCreator(createCaseOptions(false));
|
|
27
57
|
function createNormalCase(name, src, dist) {
|
|
28
58
|
creator.create(name, src, dist);
|
|
29
59
|
}
|
|
60
|
+
const hotCreator = new creator_1.BasicCaseCreator(createCaseOptions(true));
|
|
61
|
+
function createHotNormalCase(name, src, dist) {
|
|
62
|
+
hotCreator.create(name, src, dist);
|
|
63
|
+
}
|
|
64
|
+
const devCreator = new creator_1.BasicCaseCreator(createCaseOptions(false, "development"));
|
|
65
|
+
function createDevNormalCase(name, src, dist) {
|
|
66
|
+
devCreator.create(name, src, dist);
|
|
67
|
+
}
|
|
68
|
+
const prodCreator = new creator_1.BasicCaseCreator(createCaseOptions(false, "production"));
|
|
69
|
+
function createProdNormalCase(name, src, dist) {
|
|
70
|
+
prodCreator.create(name, src, dist);
|
|
71
|
+
}
|
|
72
|
+
function findBundle(context, options) {
|
|
73
|
+
const testConfig = context.getTestConfig();
|
|
74
|
+
if (typeof testConfig.findBundle === "function") {
|
|
75
|
+
return testConfig.findBundle(0, options);
|
|
76
|
+
}
|
|
77
|
+
const filename = options.output?.filename;
|
|
78
|
+
return typeof filename === "string" ? filename : undefined;
|
|
79
|
+
}
|
|
80
|
+
function defaultOptions(context, compilerOptions, mode) {
|
|
81
|
+
let testConfig = {};
|
|
82
|
+
const testConfigPath = node_path_1.default.join(context.getSource(), "test.config.js");
|
|
83
|
+
if (node_fs_1.default.existsSync(testConfigPath)) {
|
|
84
|
+
testConfig = require(testConfigPath);
|
|
85
|
+
}
|
|
86
|
+
const TerserPlugin = require("terser-webpack-plugin");
|
|
87
|
+
const terserForTesting = new TerserPlugin({
|
|
88
|
+
parallel: false
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
amd: {},
|
|
92
|
+
context: NORMAL_CASES_ROOT,
|
|
93
|
+
entry: `./${node_path_1.default.relative(NORMAL_CASES_ROOT, context.getSource())}/`,
|
|
94
|
+
target: compilerOptions?.target || "async-node",
|
|
95
|
+
devtool: mode === "development" ? false : compilerOptions?.devtool,
|
|
96
|
+
mode: compilerOptions?.mode || mode || "none",
|
|
97
|
+
optimization: compilerOptions?.mode
|
|
98
|
+
? {
|
|
99
|
+
emitOnErrors: true,
|
|
100
|
+
minimizer: [terserForTesting],
|
|
101
|
+
minimize: false,
|
|
102
|
+
...testConfig.optimization
|
|
103
|
+
}
|
|
104
|
+
: {
|
|
105
|
+
removeAvailableModules: true,
|
|
106
|
+
removeEmptyChunks: true,
|
|
107
|
+
mergeDuplicateChunks: true,
|
|
108
|
+
// CHANGE: rspack does not support `flagIncludedChunks` yet.
|
|
109
|
+
// flagIncludedChunks: true,
|
|
110
|
+
sideEffects: true,
|
|
111
|
+
providedExports: true,
|
|
112
|
+
usedExports: true,
|
|
113
|
+
mangleExports: true,
|
|
114
|
+
// CHANGE: rspack does not support `emitOnErrors` yet.
|
|
115
|
+
emitOnErrors: true,
|
|
116
|
+
concatenateModules: !!testConfig?.optimization?.concatenateModules,
|
|
117
|
+
innerGraph: true,
|
|
118
|
+
// CHANGE: size is not supported yet
|
|
119
|
+
// moduleIds: "size",
|
|
120
|
+
// chunkIds: "size",
|
|
121
|
+
moduleIds: "named",
|
|
122
|
+
chunkIds: "named",
|
|
123
|
+
minimize: false,
|
|
124
|
+
minimizer: [terserForTesting],
|
|
125
|
+
...compilerOptions?.optimization
|
|
126
|
+
},
|
|
127
|
+
// CHANGE: rspack does not support `performance` yet.
|
|
128
|
+
// performance: {
|
|
129
|
+
// hints: false
|
|
130
|
+
// },
|
|
131
|
+
node: {
|
|
132
|
+
__dirname: "mock",
|
|
133
|
+
__filename: "mock"
|
|
134
|
+
},
|
|
135
|
+
cache: compilerOptions?.cache && {
|
|
136
|
+
// cacheDirectory,
|
|
137
|
+
...compilerOptions.cache
|
|
138
|
+
},
|
|
139
|
+
output: {
|
|
140
|
+
pathinfo: "verbose",
|
|
141
|
+
path: context.getDist(),
|
|
142
|
+
filename: compilerOptions?.module ? "bundle.mjs" : "bundle.js"
|
|
143
|
+
},
|
|
144
|
+
resolve: {
|
|
145
|
+
modules: ["web_modules", "node_modules"],
|
|
146
|
+
mainFields: ["webpack", "browser", "web", "browserify", "main"],
|
|
147
|
+
aliasFields: ["browser"],
|
|
148
|
+
extensions: [".webpack.js", ".web.js", ".js", ".json"]
|
|
149
|
+
},
|
|
150
|
+
resolveLoader: {
|
|
151
|
+
modules: ["web_loaders", "web_modules", "node_loaders", "node_modules"],
|
|
152
|
+
mainFields: ["webpackLoader", "webLoader", "loader", "main"],
|
|
153
|
+
extensions: [".webpack-loader.js", ".web-loader.js", ".loader.js", ".js"]
|
|
154
|
+
},
|
|
155
|
+
module: {
|
|
156
|
+
rules: [
|
|
157
|
+
{
|
|
158
|
+
test: /\.coffee$/,
|
|
159
|
+
loader: "coffee-loader"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
test: /\.pug/,
|
|
163
|
+
loader: "@webdiscus/pug-loader"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
test: /\.wat$/i,
|
|
167
|
+
loader: "wast-loader",
|
|
168
|
+
type: "webassembly/async"
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
plugins: (compilerOptions?.plugins || [])
|
|
173
|
+
.concat(testConfig.plugins || [])
|
|
174
|
+
.concat(function () {
|
|
175
|
+
this.hooks.compilation.tap("TestCasesTest", compilation => {
|
|
176
|
+
const hooks = [
|
|
177
|
+
// CHANGE: the following hooks are not supported yet, so comment it out
|
|
178
|
+
// "optimize",
|
|
179
|
+
// "optimizeModules",
|
|
180
|
+
// "optimizeChunks",
|
|
181
|
+
// "afterOptimizeTree",
|
|
182
|
+
// "afterOptimizeAssets"
|
|
183
|
+
];
|
|
184
|
+
for (const hook of hooks) {
|
|
185
|
+
compilation.hooks[hook].tap("TestCasesTest", () => compilation.checkConstraints());
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}),
|
|
189
|
+
experiments: {
|
|
190
|
+
css: false,
|
|
191
|
+
rspackFuture: {
|
|
192
|
+
bundlerInfo: {
|
|
193
|
+
force: false
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
asyncWebAssembly: true,
|
|
197
|
+
topLevelAwait: true,
|
|
198
|
+
inlineConst: true,
|
|
199
|
+
// CHANGE: rspack does not support `backCompat` yet.
|
|
200
|
+
// backCompat: false,
|
|
201
|
+
// CHANGE: Rspack enables `css` by default.
|
|
202
|
+
// Turning off here to fallback to webpack's default css processing logic.
|
|
203
|
+
...(compilerOptions?.module ? { outputModule: true } : {})
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function overrideOptions(context, options) {
|
|
208
|
+
if (!global.printLogger) {
|
|
209
|
+
options.infrastructureLogging = {
|
|
210
|
+
level: "error"
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|