@rsbuild/core 0.3.8 → 0.3.9
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/cli/commands.js +1 -1
- package/dist/cli/prepare.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/cleanOutput.js +23 -2
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/rsdoctor.d.ts +2 -0
- package/dist/plugins/rsdoctor.js +81 -0
- package/dist/provider/core/createContext.js +1 -1
- package/dist/provider/plugins/transition.js +2 -0
- package/dist/provider/shared.js +1 -0
- package/package.json +2 -2
package/dist/cli/commands.js
CHANGED
|
@@ -112,7 +112,7 @@ const applyServerOptions = (command) => {
|
|
|
112
112
|
command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
|
|
113
113
|
};
|
|
114
114
|
function runCli() {
|
|
115
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.
|
|
115
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.9");
|
|
116
116
|
const devCommand = import_commander.program.command("dev");
|
|
117
117
|
const buildCommand = import_commander.program.command("build");
|
|
118
118
|
const previewCommand = import_commander.program.command("preview");
|
package/dist/cli/prepare.js
CHANGED
|
@@ -34,7 +34,7 @@ function prepareCli() {
|
|
|
34
34
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js")) {
|
|
35
35
|
console.log();
|
|
36
36
|
}
|
|
37
|
-
import_rslog.logger.greet(` ${`Rsbuild v${"0.3.
|
|
37
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"0.3.9"}`}
|
|
38
38
|
`);
|
|
39
39
|
}
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var import_createRsbuild = require("./createRsbuild");
|
|
|
38
38
|
var import_config = require("./cli/config");
|
|
39
39
|
var import_shared = require("@rsbuild/shared");
|
|
40
40
|
var import_constants = require("./constants");
|
|
41
|
-
const version = "0.3.
|
|
41
|
+
const version = "0.3.9";
|
|
42
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
43
|
0 && (module.exports = {
|
|
44
44
|
PLUGIN_BABEL_NAME,
|
|
@@ -21,19 +21,40 @@ __export(cleanOutput_exports, {
|
|
|
21
21
|
pluginCleanOutput: () => pluginCleanOutput
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(cleanOutput_exports);
|
|
24
|
+
var import_node_path = require("node:path");
|
|
24
25
|
var import_shared = require("@rsbuild/shared");
|
|
25
26
|
const emptyDir = async (dir) => {
|
|
26
27
|
if (await import_shared.fse.pathExists(dir)) {
|
|
27
28
|
await import_shared.fse.emptyDir(dir);
|
|
28
29
|
}
|
|
29
30
|
};
|
|
31
|
+
const addTrailingSep = (dir) => dir.endsWith(import_node_path.sep) ? dir : dir + import_node_path.sep;
|
|
32
|
+
const isStrictSubdir = (parent, child) => {
|
|
33
|
+
const parentDir = addTrailingSep(parent);
|
|
34
|
+
const childDir = addTrailingSep(child);
|
|
35
|
+
return parentDir !== childDir && childDir.startsWith(parentDir);
|
|
36
|
+
};
|
|
30
37
|
const pluginCleanOutput = () => ({
|
|
31
38
|
name: "rsbuild:clean-output",
|
|
32
39
|
setup(api) {
|
|
33
40
|
const clean = async () => {
|
|
41
|
+
const { distPath, rootPath } = api.context;
|
|
34
42
|
const config = api.getNormalizedConfig();
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
let { cleanDistPath } = config.output;
|
|
44
|
+
if (cleanDistPath === void 0) {
|
|
45
|
+
cleanDistPath = isStrictSubdir(rootPath, distPath);
|
|
46
|
+
if (!cleanDistPath) {
|
|
47
|
+
import_shared.logger.warn(
|
|
48
|
+
"The dist path is not a subdir of root path, Rsbuild will not empty it."
|
|
49
|
+
);
|
|
50
|
+
import_shared.logger.warn(
|
|
51
|
+
`Please set ${import_shared.color.yellow("`output.cleanDistPath`")} config manually.`
|
|
52
|
+
);
|
|
53
|
+
import_shared.logger.warn(`Current root path: ${import_shared.color.dim(rootPath)}`);
|
|
54
|
+
import_shared.logger.warn(`Current dist path: ${import_shared.color.dim(distPath)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (cleanDistPath) {
|
|
37
58
|
await emptyDir(distPath);
|
|
38
59
|
}
|
|
39
60
|
};
|
package/dist/plugins/index.js
CHANGED
|
@@ -43,6 +43,7 @@ const plugins = {
|
|
|
43
43
|
splitChunks: () => Promise.resolve().then(() => __toESM(require("./splitChunks"))).then((m) => m.pluginSplitChunks()),
|
|
44
44
|
inlineChunk: () => Promise.resolve().then(() => __toESM(require("./inlineChunk"))).then((m) => m.pluginInlineChunk()),
|
|
45
45
|
bundleAnalyzer: () => Promise.resolve().then(() => __toESM(require("./bundleAnalyzer"))).then((m) => m.pluginBundleAnalyzer()),
|
|
46
|
+
rsdoctor: () => Promise.resolve().then(() => __toESM(require("./rsdoctor"))).then((m) => m.pluginRsdoctor()),
|
|
46
47
|
asset: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset()),
|
|
47
48
|
wasm: () => Promise.resolve().then(() => __toESM(require("./wasm"))).then((m) => m.pluginWasm()),
|
|
48
49
|
moment: () => Promise.resolve().then(() => __toESM(require("./moment"))).then((m) => m.pluginMoment()),
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var rsdoctor_exports = {};
|
|
30
|
+
__export(rsdoctor_exports, {
|
|
31
|
+
pluginRsdoctor: () => pluginRsdoctor
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(rsdoctor_exports);
|
|
34
|
+
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
const pluginRsdoctor = () => ({
|
|
36
|
+
name: "rsbuild:rsdoctor",
|
|
37
|
+
setup(api) {
|
|
38
|
+
api.onBeforeCreateCompiler(async ({ bundlerConfigs }) => {
|
|
39
|
+
if (process.env.RSDOCTOR !== "true") {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const isRspack = api.context.bundlerType === "rspack";
|
|
43
|
+
const packageName = isRspack ? "@rsdoctor/rspack-plugin" : "@rsdoctor/webpack-plugin";
|
|
44
|
+
let module2;
|
|
45
|
+
try {
|
|
46
|
+
const path = require.resolve(packageName, {
|
|
47
|
+
paths: [api.context.rootPath]
|
|
48
|
+
});
|
|
49
|
+
module2 = await Promise.resolve().then(() => __toESM(require(path)));
|
|
50
|
+
} catch (err) {
|
|
51
|
+
import_shared.logger.warn(
|
|
52
|
+
`\`process.env.RSDOCTOR\` enabled, please install ${import_shared.color.bold(import_shared.color.yellow(packageName))} package.`
|
|
53
|
+
);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const pluginName = isRspack ? "RsdoctorRspackPlugin" : "RsdoctorWebpackPlugin";
|
|
57
|
+
if (!module2 || !module2[pluginName]) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let isAutoRegister = false;
|
|
61
|
+
bundlerConfigs.forEach((config) => {
|
|
62
|
+
const registered = config.plugins?.some(
|
|
63
|
+
(plugin) => plugin?.constructor?.name === pluginName
|
|
64
|
+
);
|
|
65
|
+
if (registered) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
config.plugins || (config.plugins = []);
|
|
69
|
+
config.plugins.push(new module2[pluginName]());
|
|
70
|
+
isAutoRegister = true;
|
|
71
|
+
});
|
|
72
|
+
if (isAutoRegister) {
|
|
73
|
+
import_shared.logger.info(`${import_shared.color.bold(import_shared.color.yellow(packageName))} enabled.`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
pluginRsdoctor
|
|
81
|
+
});
|
|
@@ -24,7 +24,9 @@ module.exports = __toCommonJS(transition_exports);
|
|
|
24
24
|
const pluginTransition = () => ({
|
|
25
25
|
name: "rsbuild:transition",
|
|
26
26
|
setup() {
|
|
27
|
+
var _a;
|
|
27
28
|
process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
|
|
29
|
+
(_a = process.env).WATCHPACK_WATCHER_LIMIT || (_a.WATCHPACK_WATCHER_LIMIT = "20");
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
32
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/provider/shared.js
CHANGED
|
@@ -69,6 +69,7 @@ const applyDefaultPlugins = (plugins) => (0, import_shared3.awaitableGetter)([
|
|
|
69
69
|
plugins.startUrl(),
|
|
70
70
|
plugins.inlineChunk(),
|
|
71
71
|
plugins.bundleAnalyzer(),
|
|
72
|
+
plugins.rsdoctor(),
|
|
72
73
|
plugins.networkPerformance(),
|
|
73
74
|
plugins.preloadOrPrefetch(),
|
|
74
75
|
plugins.performance(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"core-js": "~3.32.2",
|
|
58
58
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.5.7",
|
|
59
59
|
"postcss": "^8.4.33",
|
|
60
|
-
"@rsbuild/shared": "0.3.
|
|
60
|
+
"@rsbuild/shared": "0.3.9"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "16.x",
|