@rsbuild/core 0.0.23 → 0.0.24
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 +35 -11
- package/dist/cli/config.d.ts +1 -2
- package/dist/cli/run.d.ts +0 -2
- package/dist/cli/run.js +0 -6
- package/dist/createRsbuild.d.ts +1 -1
- package/dist/createRsbuild.js +5 -1
- package/dist/plugins/entry.d.ts +2 -2
- package/dist/plugins/entry.js +11 -0
- package/dist/plugins/startUrl.js +7 -3
- package/dist/rspack-provider/core/initConfigs.js +1 -0
- package/package.json +3 -3
package/dist/cli/commands.js
CHANGED
|
@@ -29,23 +29,47 @@ function setupProgram(rsbuild) {
|
|
|
29
29
|
const { version } = import_shared.fse.readJSONSync(pkgJson);
|
|
30
30
|
import_commander.program.name("rsbuild").usage("<command> [options]").version(version);
|
|
31
31
|
import_commander.program.command("dev").option(`--open`, "open the page in browser on startup").description("starting the dev server").action(async (options) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
try {
|
|
33
|
+
await rsbuild.startDevServer({
|
|
34
|
+
open: options.open
|
|
35
|
+
});
|
|
36
|
+
} catch (err) {
|
|
37
|
+
import_shared.logger.error("Failed to start dev server, please check logs.");
|
|
38
|
+
import_shared.logger.error(err);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
35
41
|
});
|
|
36
42
|
import_commander.program.command("build").description("build the app for production").action(async () => {
|
|
37
|
-
|
|
43
|
+
try {
|
|
44
|
+
await rsbuild.build();
|
|
45
|
+
} catch (err) {
|
|
46
|
+
import_shared.logger.error("Failed to build, please check logs.");
|
|
47
|
+
import_shared.logger.error(err);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
38
50
|
});
|
|
39
51
|
import_commander.program.command("preview").description("preview the production build locally").action(async () => {
|
|
40
|
-
|
|
52
|
+
try {
|
|
53
|
+
await rsbuild.preview();
|
|
54
|
+
} catch (err) {
|
|
55
|
+
import_shared.logger.error("Failed to start preview server, please check logs.");
|
|
56
|
+
import_shared.logger.error(err);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
41
59
|
});
|
|
42
60
|
import_commander.program.command("inspect").description("inspect the Rspack and Rsbuild configs").option(`--env <env>`, "specify env mode", "development").option("--output <output>", "specify inspect content output path", "/").option("--verbose", "show full function definitions in output").action(async (options) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
61
|
+
try {
|
|
62
|
+
await rsbuild.inspectConfig({
|
|
63
|
+
env: options.env,
|
|
64
|
+
verbose: options.verbose,
|
|
65
|
+
outputPath: (0, import_path.join)(rsbuild.context.distPath, options.output),
|
|
66
|
+
writeToDisk: true
|
|
67
|
+
});
|
|
68
|
+
} catch (err) {
|
|
69
|
+
import_shared.logger.error("Failed to inspect config, please check logs.");
|
|
70
|
+
import_shared.logger.error(err);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
49
73
|
});
|
|
50
74
|
import_commander.program.parse();
|
|
51
75
|
}
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RsbuildConfig as BaseRsbuildConfig } from '@rsbuild/shared';
|
|
2
2
|
export type RsbuildConfig = BaseRsbuildConfig & {
|
|
3
|
-
plugins?: RsbuildPlugin[];
|
|
4
3
|
/**
|
|
5
4
|
* @private only for testing
|
|
6
5
|
*/
|
package/dist/cli/run.d.ts
CHANGED
package/dist/cli/run.js
CHANGED
|
@@ -30,12 +30,6 @@ async function runCli(options = {}) {
|
|
|
30
30
|
rsbuildConfig: config,
|
|
31
31
|
provider: config.provider
|
|
32
32
|
});
|
|
33
|
-
if (options.defaultPlugins) {
|
|
34
|
-
rsbuild.addPlugins(options.defaultPlugins);
|
|
35
|
-
}
|
|
36
|
-
if (config.plugins) {
|
|
37
|
-
rsbuild.addPlugins(config.plugins);
|
|
38
|
-
}
|
|
39
33
|
if (!options.isRestart) {
|
|
40
34
|
(0, import_commands.setupProgram)(rsbuild);
|
|
41
35
|
}
|
package/dist/createRsbuild.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function createRsbuild<P extends ({
|
|
|
5
5
|
rsbuildConfig
|
|
6
6
|
}: {
|
|
7
7
|
rsbuildConfig: T;
|
|
8
|
-
}) => RsbuildProvider, T
|
|
8
|
+
}) => RsbuildProvider, T extends RsbuildConfig>(options: CreateRsbuildOptions & {
|
|
9
9
|
rsbuildConfig: T;
|
|
10
10
|
provider?: P;
|
|
11
11
|
}): Promise<RsbuildInstance<ReturnType<P>>>;
|
package/dist/createRsbuild.js
CHANGED
|
@@ -71,7 +71,7 @@ async function createRsbuild(options) {
|
|
|
71
71
|
(0, import_shared.debug)("add default plugins");
|
|
72
72
|
await applyDefaultPlugins(pluginStore);
|
|
73
73
|
(0, import_shared.debug)("add default plugins done");
|
|
74
|
-
|
|
74
|
+
const rsbuild = {
|
|
75
75
|
...(0, import_shared.pick)(pluginStore, ["addPlugins", "removePlugins", "isPluginExists"]),
|
|
76
76
|
...(0, import_shared.pick)(pluginAPI, [
|
|
77
77
|
"onBeforeBuild",
|
|
@@ -94,6 +94,10 @@ async function createRsbuild(options) {
|
|
|
94
94
|
startDevServer,
|
|
95
95
|
context: publicContext
|
|
96
96
|
};
|
|
97
|
+
if (rsbuildConfig.plugins) {
|
|
98
|
+
rsbuild.addPlugins(rsbuildConfig.plugins);
|
|
99
|
+
}
|
|
100
|
+
return rsbuild;
|
|
97
101
|
}
|
|
98
102
|
// Annotate the CommonJS export names for ESM import in node:
|
|
99
103
|
0 && (module.exports = {
|
package/dist/plugins/entry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const pluginEntry: () =>
|
|
1
|
+
import type { RsbuildPlugin } from '../rspack-provider/types';
|
|
2
|
+
export declare const pluginEntry: () => RsbuildPlugin;
|
package/dist/plugins/entry.js
CHANGED
|
@@ -34,6 +34,17 @@ const pluginEntry = () => ({
|
|
|
34
34
|
(0, import_shared.castArray)(entry[entryName]).forEach(appendEntry);
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
|
+
api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
|
|
38
|
+
if (bundlerConfigs.every((config) => !config.entry)) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`Could not find any entry module, please make sure that ${import_shared.color.cyan(
|
|
41
|
+
`src/index.(ts|js|tsx|jsx|mjs|cjs)`
|
|
42
|
+
)} exists, or customize entry through the ${import_shared.color.cyan(
|
|
43
|
+
`source.entry`
|
|
44
|
+
)} configuration.`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
37
48
|
}
|
|
38
49
|
});
|
|
39
50
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/plugins/startUrl.js
CHANGED
|
@@ -107,9 +107,13 @@ function pluginStartUrl() {
|
|
|
107
107
|
const urls = [];
|
|
108
108
|
if (startUrl === true || !startUrl) {
|
|
109
109
|
const protocol = https ? "https" : "http";
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
if (routes.length) {
|
|
111
|
+
urls.push(
|
|
112
|
+
(0, import_shared.normalizeUrl)(
|
|
113
|
+
`${protocol}://localhost:${port}/${routes[0].route}`
|
|
114
|
+
)
|
|
115
|
+
);
|
|
116
|
+
}
|
|
113
117
|
} else {
|
|
114
118
|
urls.push(
|
|
115
119
|
...(0, import_shared.castArray)(startUrl).map(
|
|
@@ -45,6 +45,7 @@ async function initConfigs({
|
|
|
45
45
|
});
|
|
46
46
|
await modifyRsbuildConfig(context);
|
|
47
47
|
context.normalizedConfig = (0, import_normalize.normalizeConfig)(context.config);
|
|
48
|
+
(0, import_shared.updateContextByNormalizedConfig)(context, context.normalizedConfig);
|
|
48
49
|
const targets = (0, import_shared.castArray)(rsbuildOptions.target);
|
|
49
50
|
const rspackConfigs = await Promise.all(
|
|
50
51
|
targets.map((target) => (0, import_rspackConfig.generateRspackConfig)({ target, context }))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "Unleash the power of Rspack with the out-of-the-box build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"types.d.ts"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@rspack/core": "0.3.
|
|
61
|
+
"@rspack/core": "0.3.13",
|
|
62
62
|
"core-js": "~3.32.2",
|
|
63
63
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.5.5",
|
|
64
64
|
"http-proxy-middleware": "^2.0.1",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"semver": "^7.5.4",
|
|
68
68
|
"sirv": "^2.0.3",
|
|
69
69
|
"ws": "^8.2.0",
|
|
70
|
-
"@rsbuild/shared": "0.0.
|
|
70
|
+
"@rsbuild/shared": "0.0.24"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@types/node": "^16",
|