@rsbuild/webpack 0.4.12 → 0.4.14
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/core/build.js +24 -16
- package/dist/core/createCompiler.js +8 -3
- package/dist/core/devMiddleware.js +2 -2
- package/dist/shared.js +1 -2
- package/package.json +6 -6
package/dist/core/build.js
CHANGED
|
@@ -41,9 +41,20 @@ const build = async (initOptions, { mode = "production", watch, compiler: custom
|
|
|
41
41
|
});
|
|
42
42
|
bundlerConfigs = webpackConfigs;
|
|
43
43
|
}
|
|
44
|
+
let isFirstCompile = true;
|
|
44
45
|
await context.hooks.onBeforeBuild.call({
|
|
45
46
|
bundlerConfigs
|
|
46
47
|
});
|
|
48
|
+
const onDone = async (stats) => {
|
|
49
|
+
const p = context.hooks.onAfterBuild.call({ isFirstCompile, stats });
|
|
50
|
+
isFirstCompile = false;
|
|
51
|
+
await p;
|
|
52
|
+
};
|
|
53
|
+
if ((0, import_shared.isMultiCompiler)(compiler)) {
|
|
54
|
+
compiler.hooks.done.tap("rsbuild:done", onDone);
|
|
55
|
+
} else {
|
|
56
|
+
compiler.hooks.done.tapPromise("rsbuild:done", onDone);
|
|
57
|
+
}
|
|
47
58
|
if (watch) {
|
|
48
59
|
compiler.watch({}, (err) => {
|
|
49
60
|
if (err) {
|
|
@@ -52,22 +63,19 @@ const build = async (initOptions, { mode = "production", watch, compiler: custom
|
|
|
52
63
|
});
|
|
53
64
|
return;
|
|
54
65
|
}
|
|
55
|
-
|
|
56
|
-
(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
await context.hooks.onAfterBuild.call({ stats });
|
|
66
|
+
await new Promise((resolve, reject) => {
|
|
67
|
+
compiler.run((err, stats) => {
|
|
68
|
+
if (err || stats?.hasErrors()) {
|
|
69
|
+
const buildError = err || new Error("Webpack build failed!");
|
|
70
|
+
reject(buildError);
|
|
71
|
+
} else {
|
|
72
|
+
compiler.close((closeErr) => {
|
|
73
|
+
closeErr && import_shared.logger.error(closeErr);
|
|
74
|
+
resolve({ stats });
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
71
79
|
};
|
|
72
80
|
// Annotate the CommonJS export names for ESM import in node:
|
|
73
81
|
0 && (module.exports = {
|
|
@@ -46,8 +46,7 @@ async function createCompiler({
|
|
|
46
46
|
});
|
|
47
47
|
const { default: webpack } = await Promise.resolve().then(() => __toESM(require("webpack")));
|
|
48
48
|
const compiler = webpackConfigs.length === 1 ? webpack(webpackConfigs[0]) : webpack(webpackConfigs);
|
|
49
|
-
|
|
50
|
-
compiler.hooks.done.tap("rsbuild:done", async (stats) => {
|
|
49
|
+
const done = async (stats) => {
|
|
51
50
|
const { message, level } = (0, import_provider.formatStats)(stats);
|
|
52
51
|
if (level === "error") {
|
|
53
52
|
import_shared.logger.error(message);
|
|
@@ -62,7 +61,13 @@ async function createCompiler({
|
|
|
62
61
|
});
|
|
63
62
|
}
|
|
64
63
|
isFirstCompile = false;
|
|
65
|
-
}
|
|
64
|
+
};
|
|
65
|
+
let isFirstCompile = true;
|
|
66
|
+
if ((0, import_shared.isMultiCompiler)(compiler)) {
|
|
67
|
+
compiler.hooks.done.tap("rsbuild:done", done);
|
|
68
|
+
} else {
|
|
69
|
+
compiler.hooks.done.tapPromise("rsbuild:done", done);
|
|
70
|
+
}
|
|
66
71
|
await context.hooks.onAfterCreateCompiler.call({
|
|
67
72
|
compiler
|
|
68
73
|
});
|
|
@@ -41,7 +41,7 @@ const applyHMREntry = (compiler, clientPath) => {
|
|
|
41
41
|
}).apply(compiler2);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
if (
|
|
44
|
+
if ((0, import_shared.isMultiCompiler)(compiler)) {
|
|
45
45
|
compiler.compilers.forEach((target) => {
|
|
46
46
|
applyEntry(clientPath, target);
|
|
47
47
|
});
|
|
@@ -50,7 +50,7 @@ const applyHMREntry = (compiler, clientPath) => {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
const setupHooks = (compiler, hookCallbacks) => {
|
|
53
|
-
if (
|
|
53
|
+
if ((0, import_shared.isMultiCompiler)(compiler)) {
|
|
54
54
|
compiler.compilers.forEach(
|
|
55
55
|
(compiler2) => (0, import_shared.setupServerHooks)(compiler2, hookCallbacks)
|
|
56
56
|
);
|
package/dist/shared.js
CHANGED
|
@@ -35,8 +35,7 @@ module.exports = __toCommonJS(shared_exports);
|
|
|
35
35
|
var import_node_fs = __toESM(require("node:fs"));
|
|
36
36
|
var import_node_path = require("node:path");
|
|
37
37
|
var import_shared = require("@rsbuild/shared");
|
|
38
|
-
|
|
39
|
-
const applyDefaultPlugins = (plugins) => (0, import_shared2.awaitableGetter)([
|
|
38
|
+
const applyDefaultPlugins = (plugins) => (0, import_shared.awaitableGetter)([
|
|
40
39
|
plugins.basic?.(),
|
|
41
40
|
plugins.entry?.(),
|
|
42
41
|
plugins.cache?.(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/webpack",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"homepage": "https://rsbuild.dev",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,19 +29,19 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"fast-glob": "^3.3.1",
|
|
31
31
|
"globby": "^11.1.0",
|
|
32
|
-
"html-webpack-plugin": "npm:html-rspack-plugin@5.6.
|
|
32
|
+
"html-webpack-plugin": "npm:html-rspack-plugin@5.6.2",
|
|
33
33
|
"mini-css-extract-plugin": "2.8.1",
|
|
34
34
|
"postcss": "^8.4.33",
|
|
35
35
|
"terser-webpack-plugin": "5.3.10",
|
|
36
36
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
37
37
|
"webpack": "^5.89.0",
|
|
38
|
-
"@rsbuild/core": "0.4.
|
|
39
|
-
"@rsbuild/shared": "0.4.
|
|
38
|
+
"@rsbuild/core": "0.4.14",
|
|
39
|
+
"@rsbuild/shared": "0.4.14"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "16.x",
|
|
43
|
-
"typescript": "^5.
|
|
44
|
-
"@scripts/test-helper": "0.4.
|
|
43
|
+
"typescript": "^5.4.2",
|
|
44
|
+
"@scripts/test-helper": "0.4.14"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public",
|