@rsbuild/core 0.4.6 → 0.4.8
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.d.ts +1 -5
- package/dist/cli/commands.js +6 -80
- package/dist/cli/init.d.ts +5 -0
- package/dist/cli/init.js +101 -0
- package/dist/cli/prepare.js +1 -1
- package/dist/{cli/config.js → config.js} +14 -10
- package/dist/createRsbuild.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/loadEnv.js +5 -1
- package/dist/plugins/cache.js +7 -3
- package/dist/provider/createContext.js +1 -1
- package/dist/provider/plugins/progress.js +2 -1
- package/dist/provider/plugins/swc.js +1 -0
- package/dist/rspack/HtmlCrossOriginPlugin.d.ts +1 -1
- package/dist/rspack/HtmlCrossOriginPlugin.js +12 -5
- package/dist/server/restart.js +2 -2
- package/package.json +4 -4
- /package/dist/{cli/config.d.ts → config.d.ts} +0 -0
package/dist/cli/commands.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RsbuildMode } from '@rsbuild/shared';
|
|
2
2
|
export type CommonOptions = {
|
|
3
3
|
config?: string;
|
|
4
4
|
envMode?: string;
|
|
@@ -16,8 +16,4 @@ export type InspectOptions = CommonOptions & {
|
|
|
16
16
|
};
|
|
17
17
|
export type DevOptions = CommonOptions;
|
|
18
18
|
export type PreviewOptions = CommonOptions;
|
|
19
|
-
export declare function init({ cliOptions, isRestart, }: {
|
|
20
|
-
cliOptions?: CommonOptions;
|
|
21
|
-
isRestart?: boolean;
|
|
22
|
-
}): Promise<import("@rsbuild/shared").RsbuildInstance | undefined>;
|
|
23
19
|
export declare function runCli(): void;
|
package/dist/cli/commands.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,18 +15,9 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var commands_exports = {};
|
|
30
20
|
__export(commands_exports, {
|
|
31
|
-
init: () => init,
|
|
32
21
|
runCli: () => runCli
|
|
33
22
|
});
|
|
34
23
|
module.exports = __toCommonJS(commands_exports);
|
|
@@ -36,69 +25,7 @@ var import_node_path = require("node:path");
|
|
|
36
25
|
var import_node_fs = require("node:fs");
|
|
37
26
|
var import_shared = require("@rsbuild/shared");
|
|
38
27
|
var import_commander = require("@rsbuild/shared/commander");
|
|
39
|
-
var
|
|
40
|
-
var import_config = require("./config");
|
|
41
|
-
var import_restart = require("../server/restart");
|
|
42
|
-
let commonOpts = {};
|
|
43
|
-
async function init({
|
|
44
|
-
cliOptions,
|
|
45
|
-
isRestart
|
|
46
|
-
}) {
|
|
47
|
-
if (cliOptions) {
|
|
48
|
-
commonOpts = cliOptions;
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
const root = process.cwd();
|
|
52
|
-
const envs = (0, import_loadEnv.loadEnv)({
|
|
53
|
-
cwd: root,
|
|
54
|
-
mode: cliOptions?.envMode
|
|
55
|
-
});
|
|
56
|
-
if ((0, import_shared.isDev)()) {
|
|
57
|
-
(0, import_restart.onBeforeRestartServer)(envs.cleanup);
|
|
58
|
-
}
|
|
59
|
-
const { content: config, filePath: configFilePath } = await (0, import_config.loadConfig)({
|
|
60
|
-
cwd: root,
|
|
61
|
-
path: commonOpts.config,
|
|
62
|
-
envMode: commonOpts.envMode
|
|
63
|
-
});
|
|
64
|
-
const command = process.argv[2];
|
|
65
|
-
if (command === "dev") {
|
|
66
|
-
const files = [...envs.filePaths];
|
|
67
|
-
if (configFilePath) {
|
|
68
|
-
files.push(configFilePath);
|
|
69
|
-
}
|
|
70
|
-
(0, import_config.watchFiles)(files);
|
|
71
|
-
}
|
|
72
|
-
const { createRsbuild } = await Promise.resolve().then(() => __toESM(require("../createRsbuild")));
|
|
73
|
-
config.source || (config.source = {});
|
|
74
|
-
config.source.define = {
|
|
75
|
-
...envs.publicVars,
|
|
76
|
-
...config.source.define
|
|
77
|
-
};
|
|
78
|
-
if (commonOpts.open && !config.dev?.startUrl) {
|
|
79
|
-
config.dev || (config.dev = {});
|
|
80
|
-
config.dev.startUrl = commonOpts.open;
|
|
81
|
-
}
|
|
82
|
-
if (commonOpts.host) {
|
|
83
|
-
config.server || (config.server = {});
|
|
84
|
-
config.server.host = commonOpts.host;
|
|
85
|
-
}
|
|
86
|
-
if (commonOpts.port) {
|
|
87
|
-
config.server || (config.server = {});
|
|
88
|
-
config.server.port = commonOpts.port;
|
|
89
|
-
}
|
|
90
|
-
return await createRsbuild({
|
|
91
|
-
cwd: root,
|
|
92
|
-
rsbuildConfig: config
|
|
93
|
-
});
|
|
94
|
-
} catch (err) {
|
|
95
|
-
if (isRestart) {
|
|
96
|
-
import_shared.logger.error(err);
|
|
97
|
-
} else {
|
|
98
|
-
throw err;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
28
|
+
var import_init = require("./init");
|
|
102
29
|
const applyCommonOptions = (command) => {
|
|
103
30
|
command.option(
|
|
104
31
|
"-c --config <config>",
|
|
@@ -112,7 +39,7 @@ const applyServerOptions = (command) => {
|
|
|
112
39
|
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
40
|
};
|
|
114
41
|
function runCli() {
|
|
115
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.4.
|
|
42
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.4.8");
|
|
116
43
|
const devCommand = import_commander.program.command("dev");
|
|
117
44
|
const buildCommand = import_commander.program.command("build");
|
|
118
45
|
const previewCommand = import_commander.program.command("preview");
|
|
@@ -123,7 +50,7 @@ function runCli() {
|
|
|
123
50
|
[devCommand, previewCommand].forEach(applyServerOptions);
|
|
124
51
|
devCommand.description("starting the dev server").action(async (options) => {
|
|
125
52
|
try {
|
|
126
|
-
const rsbuild = await init({ cliOptions: options });
|
|
53
|
+
const rsbuild = await (0, import_init.init)({ cliOptions: options });
|
|
127
54
|
await rsbuild?.startDevServer();
|
|
128
55
|
} catch (err) {
|
|
129
56
|
import_shared.logger.error("Failed to start dev server.");
|
|
@@ -133,7 +60,7 @@ function runCli() {
|
|
|
133
60
|
});
|
|
134
61
|
buildCommand.option("-w --watch", "turn on watch mode, watch for changes and rebuild").description("build the app for production").action(async (options) => {
|
|
135
62
|
try {
|
|
136
|
-
const rsbuild = await init({ cliOptions: options });
|
|
63
|
+
const rsbuild = await (0, import_init.init)({ cliOptions: options });
|
|
137
64
|
await rsbuild?.build({
|
|
138
65
|
watch: options.watch
|
|
139
66
|
});
|
|
@@ -145,7 +72,7 @@ function runCli() {
|
|
|
145
72
|
});
|
|
146
73
|
previewCommand.description("preview the production build locally").action(async (options) => {
|
|
147
74
|
try {
|
|
148
|
-
const rsbuild = await init({ cliOptions: options });
|
|
75
|
+
const rsbuild = await (0, import_init.init)({ cliOptions: options });
|
|
149
76
|
if (rsbuild && !(0, import_node_fs.existsSync)(rsbuild.context.distPath)) {
|
|
150
77
|
throw new Error(
|
|
151
78
|
`The output directory ${import_shared.color.yellow(
|
|
@@ -162,7 +89,7 @@ function runCli() {
|
|
|
162
89
|
});
|
|
163
90
|
inspectCommand.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) => {
|
|
164
91
|
try {
|
|
165
|
-
const rsbuild = await init({ cliOptions: options });
|
|
92
|
+
const rsbuild = await (0, import_init.init)({ cliOptions: options });
|
|
166
93
|
await rsbuild?.inspectConfig({
|
|
167
94
|
env: options.env,
|
|
168
95
|
verbose: options.verbose,
|
|
@@ -179,6 +106,5 @@ function runCli() {
|
|
|
179
106
|
}
|
|
180
107
|
// Annotate the CommonJS export names for ESM import in node:
|
|
181
108
|
0 && (module.exports = {
|
|
182
|
-
init,
|
|
183
109
|
runCli
|
|
184
110
|
});
|
package/dist/cli/init.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
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 init_exports = {};
|
|
30
|
+
__export(init_exports, {
|
|
31
|
+
init: () => init
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(init_exports);
|
|
34
|
+
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
var import_loadEnv = require("../loadEnv");
|
|
36
|
+
var import_config = require("../config");
|
|
37
|
+
var import_restart = require("../server/restart");
|
|
38
|
+
let commonOpts = {};
|
|
39
|
+
async function init({
|
|
40
|
+
cliOptions,
|
|
41
|
+
isRestart
|
|
42
|
+
}) {
|
|
43
|
+
if (cliOptions) {
|
|
44
|
+
commonOpts = cliOptions;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const root = process.cwd();
|
|
48
|
+
const envs = (0, import_loadEnv.loadEnv)({
|
|
49
|
+
cwd: root,
|
|
50
|
+
mode: cliOptions?.envMode
|
|
51
|
+
});
|
|
52
|
+
if ((0, import_shared.isDev)()) {
|
|
53
|
+
(0, import_restart.onBeforeRestartServer)(envs.cleanup);
|
|
54
|
+
}
|
|
55
|
+
const { content: config, filePath: configFilePath } = await (0, import_config.loadConfig)({
|
|
56
|
+
cwd: root,
|
|
57
|
+
path: commonOpts.config,
|
|
58
|
+
envMode: commonOpts.envMode
|
|
59
|
+
});
|
|
60
|
+
const command = process.argv[2];
|
|
61
|
+
if (command === "dev") {
|
|
62
|
+
const files = [...envs.filePaths];
|
|
63
|
+
if (configFilePath) {
|
|
64
|
+
files.push(configFilePath);
|
|
65
|
+
}
|
|
66
|
+
(0, import_config.watchFiles)(files);
|
|
67
|
+
}
|
|
68
|
+
const { createRsbuild } = await Promise.resolve().then(() => __toESM(require("../createRsbuild")));
|
|
69
|
+
config.source || (config.source = {});
|
|
70
|
+
config.source.define = {
|
|
71
|
+
...envs.publicVars,
|
|
72
|
+
...config.source.define
|
|
73
|
+
};
|
|
74
|
+
if (commonOpts.open && !config.dev?.startUrl) {
|
|
75
|
+
config.dev || (config.dev = {});
|
|
76
|
+
config.dev.startUrl = commonOpts.open;
|
|
77
|
+
}
|
|
78
|
+
if (commonOpts.host) {
|
|
79
|
+
config.server || (config.server = {});
|
|
80
|
+
config.server.host = commonOpts.host;
|
|
81
|
+
}
|
|
82
|
+
if (commonOpts.port) {
|
|
83
|
+
config.server || (config.server = {});
|
|
84
|
+
config.server.port = commonOpts.port;
|
|
85
|
+
}
|
|
86
|
+
return createRsbuild({
|
|
87
|
+
cwd: root,
|
|
88
|
+
rsbuildConfig: config
|
|
89
|
+
});
|
|
90
|
+
} catch (err) {
|
|
91
|
+
if (isRestart) {
|
|
92
|
+
import_shared.logger.error(err);
|
|
93
|
+
} else {
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
init
|
|
101
|
+
});
|
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.4.
|
|
37
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"0.4.8"}`}
|
|
38
38
|
`);
|
|
39
39
|
}
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(config_exports);
|
|
|
36
36
|
var import_node_fs = __toESM(require("node:fs"));
|
|
37
37
|
var import_node_path = require("node:path");
|
|
38
38
|
var import_shared = require("@rsbuild/shared");
|
|
39
|
-
var import_restart = require("
|
|
39
|
+
var import_restart = require("./server/restart");
|
|
40
40
|
function defineConfig(config) {
|
|
41
41
|
return config;
|
|
42
42
|
}
|
|
@@ -93,13 +93,17 @@ async function loadConfig({
|
|
|
93
93
|
path,
|
|
94
94
|
envMode
|
|
95
95
|
}) {
|
|
96
|
-
const
|
|
97
|
-
if (!
|
|
96
|
+
const configFilePath = resolveConfigPath(cwd, path);
|
|
97
|
+
if (!configFilePath) {
|
|
98
98
|
return {
|
|
99
99
|
content: {},
|
|
100
|
-
filePath:
|
|
100
|
+
filePath: configFilePath
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
+
const applyMetaInfo = (config) => {
|
|
104
|
+
config._privateMeta = { configFilePath };
|
|
105
|
+
return config;
|
|
106
|
+
};
|
|
103
107
|
try {
|
|
104
108
|
const { default: jiti } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/jiti")));
|
|
105
109
|
const loadConfig2 = jiti(__filename, {
|
|
@@ -108,7 +112,7 @@ async function loadConfig({
|
|
|
108
112
|
requireCache: false,
|
|
109
113
|
interopDefault: true
|
|
110
114
|
});
|
|
111
|
-
const configExport = loadConfig2(
|
|
115
|
+
const configExport = loadConfig2(configFilePath);
|
|
112
116
|
if (typeof configExport === "function") {
|
|
113
117
|
const command = process.argv[2];
|
|
114
118
|
const params = {
|
|
@@ -121,8 +125,8 @@ async function loadConfig({
|
|
|
121
125
|
throw new Error("Rsbuild config function must return a config object.");
|
|
122
126
|
}
|
|
123
127
|
return {
|
|
124
|
-
content: result,
|
|
125
|
-
filePath:
|
|
128
|
+
content: applyMetaInfo(result),
|
|
129
|
+
filePath: configFilePath
|
|
126
130
|
};
|
|
127
131
|
}
|
|
128
132
|
if (!(0, import_shared.isObject)(configExport)) {
|
|
@@ -133,11 +137,11 @@ async function loadConfig({
|
|
|
133
137
|
);
|
|
134
138
|
}
|
|
135
139
|
return {
|
|
136
|
-
content: configExport,
|
|
137
|
-
filePath:
|
|
140
|
+
content: applyMetaInfo(configExport),
|
|
141
|
+
filePath: configFilePath
|
|
138
142
|
};
|
|
139
143
|
} catch (err) {
|
|
140
|
-
import_shared.logger.error(`Failed to load file: ${import_shared.color.dim(
|
|
144
|
+
import_shared.logger.error(`Failed to load file: ${import_shared.color.dim(configFilePath)}`);
|
|
141
145
|
throw err;
|
|
142
146
|
}
|
|
143
147
|
}
|
package/dist/createRsbuild.js
CHANGED
|
@@ -94,7 +94,8 @@ async function createRsbuild(options) {
|
|
|
94
94
|
context: publicContext
|
|
95
95
|
};
|
|
96
96
|
if (rsbuildConfig.plugins) {
|
|
97
|
-
|
|
97
|
+
const plugins2 = await Promise.all(rsbuildConfig.plugins);
|
|
98
|
+
rsbuild.addPlugins(plugins2);
|
|
98
99
|
}
|
|
99
100
|
return rsbuild;
|
|
100
101
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { loadEnv } from './loadEnv';
|
|
6
6
|
export { createRsbuild } from './createRsbuild';
|
|
7
|
-
export { loadConfig, defineConfig } from './
|
|
7
|
+
export { loadConfig, defineConfig } from './config';
|
|
8
8
|
export declare const version: any;
|
|
9
9
|
export { logger, mergeRsbuildConfig } from '@rsbuild/shared';
|
|
10
10
|
export { PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, PLUGIN_SASS_NAME, PLUGIN_LESS_NAME, PLUGIN_STYLUS_NAME, } from './constants';
|
package/dist/index.js
CHANGED
|
@@ -34,10 +34,10 @@ __export(src_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(src_exports);
|
|
35
35
|
var import_loadEnv = require("./loadEnv");
|
|
36
36
|
var import_createRsbuild = require("./createRsbuild");
|
|
37
|
-
var import_config = require("./
|
|
37
|
+
var import_config = require("./config");
|
|
38
38
|
var import_shared = require("@rsbuild/shared");
|
|
39
39
|
var import_constants = require("./constants");
|
|
40
|
-
const version = "0.4.
|
|
40
|
+
const version = "0.4.8";
|
|
41
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
42
|
0 && (module.exports = {
|
|
43
43
|
PLUGIN_CSS_NAME,
|
package/dist/loadEnv.js
CHANGED
|
@@ -67,9 +67,13 @@ function loadEnv({
|
|
|
67
67
|
});
|
|
68
68
|
let cleaned = false;
|
|
69
69
|
const cleanup = () => {
|
|
70
|
-
if (cleaned)
|
|
70
|
+
if (cleaned) {
|
|
71
71
|
return;
|
|
72
|
+
}
|
|
72
73
|
Object.keys(parsed).forEach((key) => {
|
|
74
|
+
if (key === "NODE_ENV") {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
73
77
|
if (process.env[key] === parsed[key]) {
|
|
74
78
|
delete process.env[key];
|
|
75
79
|
}
|
package/dist/plugins/cache.js
CHANGED
|
@@ -57,7 +57,7 @@ function getCacheDirectory({ cacheDirectory }, context) {
|
|
|
57
57
|
}
|
|
58
58
|
return (0, import_node_path.join)(context.cachePath, context.bundlerType);
|
|
59
59
|
}
|
|
60
|
-
async function getBuildDependencies(context) {
|
|
60
|
+
async function getBuildDependencies(context, config) {
|
|
61
61
|
const rootPackageJson = (0, import_node_path.join)(context.rootPath, "package.json");
|
|
62
62
|
const browserslistConfig = (0, import_node_path.join)(context.rootPath, ".browserslistrc");
|
|
63
63
|
const buildDependencies = {};
|
|
@@ -67,6 +67,9 @@ async function getBuildDependencies(context) {
|
|
|
67
67
|
if (context.tsconfigPath) {
|
|
68
68
|
buildDependencies.tsconfig = [context.tsconfigPath];
|
|
69
69
|
}
|
|
70
|
+
if (config._privateMeta?.configFilePath) {
|
|
71
|
+
buildDependencies.rsbuildConfig = [config._privateMeta.configFilePath];
|
|
72
|
+
}
|
|
70
73
|
if (await (0, import_shared2.isFileExists)(browserslistConfig)) {
|
|
71
74
|
buildDependencies.browserslistrc = [browserslistConfig];
|
|
72
75
|
}
|
|
@@ -84,7 +87,8 @@ const pluginCache = () => ({
|
|
|
84
87
|
name: "rsbuild:cache",
|
|
85
88
|
setup(api) {
|
|
86
89
|
api.modifyBundlerChain(async (chain, { target, env }) => {
|
|
87
|
-
const
|
|
90
|
+
const config = api.getNormalizedConfig();
|
|
91
|
+
const { buildCache } = config.performance;
|
|
88
92
|
if (buildCache === false) {
|
|
89
93
|
chain.cache(false);
|
|
90
94
|
return;
|
|
@@ -92,7 +96,7 @@ const pluginCache = () => ({
|
|
|
92
96
|
const { context } = api;
|
|
93
97
|
const cacheConfig = typeof buildCache === "boolean" ? {} : buildCache;
|
|
94
98
|
const cacheDirectory = getCacheDirectory(cacheConfig, context);
|
|
95
|
-
const buildDependencies = await getBuildDependencies(context);
|
|
99
|
+
const buildDependencies = await getBuildDependencies(context, config);
|
|
96
100
|
await validateCache(cacheDirectory, buildDependencies);
|
|
97
101
|
const useDigest = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length;
|
|
98
102
|
chain.cache({
|
|
@@ -44,7 +44,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
44
44
|
const context = {
|
|
45
45
|
entry: (0, import_entry.getEntryObject)(config, "web"),
|
|
46
46
|
targets: config.output?.targets || [],
|
|
47
|
-
version: "0.4.
|
|
47
|
+
version: "0.4.8",
|
|
48
48
|
rootPath,
|
|
49
49
|
distPath,
|
|
50
50
|
cachePath,
|
|
@@ -42,10 +42,11 @@ const pluginProgress = () => ({
|
|
|
42
42
|
if (!options) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
+
const prefix = options !== true && options.id !== void 0 ? options.id : import_shared.TARGET_ID_MAP[target];
|
|
45
46
|
const { ProgressPlugin } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
46
47
|
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
|
|
47
48
|
{
|
|
48
|
-
prefix
|
|
49
|
+
prefix,
|
|
49
50
|
...options === true ? {} : options
|
|
50
51
|
}
|
|
51
52
|
]);
|
|
@@ -131,6 +131,7 @@ function applySwcDecoratorConfig(swcConfig, config) {
|
|
|
131
131
|
case "legacy":
|
|
132
132
|
swcConfig.jsc.transform.legacyDecorator = true;
|
|
133
133
|
swcConfig.jsc.transform.decoratorMetadata = true;
|
|
134
|
+
swcConfig.jsc.transform.useDefineForClassFields = false;
|
|
134
135
|
break;
|
|
135
136
|
case "2022-03":
|
|
136
137
|
swcConfig.jsc.transform.legacyDecorator = false;
|
|
@@ -26,6 +26,7 @@ __export(HtmlCrossOriginPlugin_exports, {
|
|
|
26
26
|
HtmlCrossOriginPlugin: () => HtmlCrossOriginPlugin
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(HtmlCrossOriginPlugin_exports);
|
|
29
|
+
var import_shared = require("@rsbuild/shared");
|
|
29
30
|
var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
|
|
30
31
|
class HtmlCrossOriginPlugin {
|
|
31
32
|
constructor(options) {
|
|
@@ -36,21 +37,27 @@ class HtmlCrossOriginPlugin {
|
|
|
36
37
|
this.crossOrigin = crossOrigin;
|
|
37
38
|
}
|
|
38
39
|
apply(compiler) {
|
|
39
|
-
if (!this.crossOrigin
|
|
40
|
-
// https://github.com/web-infra-dev/rspack/blob/bc8e67b5419adda15c2b389517c9b37d02c8240f/crates/rspack_plugin_runtime/src/runtime_module/load_script.rs#L39
|
|
41
|
-
compiler.options.output.publicPath === "/" && this.crossOrigin !== "use-credentials") {
|
|
40
|
+
if (!this.crossOrigin) {
|
|
42
41
|
return;
|
|
43
42
|
}
|
|
43
|
+
if (this.crossOrigin !== "use-credentials") {
|
|
44
|
+
const { publicPath } = compiler.options.output;
|
|
45
|
+
if (!publicPath || publicPath === import_shared.DEFAULT_ASSET_PREFIX || publicPath === "auto") {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
44
49
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
45
50
|
(0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTags.tap(this.name, (alterAssetTags) => {
|
|
46
51
|
const {
|
|
47
52
|
assetTags: { scripts, styles }
|
|
48
53
|
} = alterAssetTags;
|
|
49
54
|
scripts.forEach((script) => {
|
|
50
|
-
|
|
55
|
+
var _a;
|
|
56
|
+
(_a = script.attributes).crossorigin ?? (_a.crossorigin = this.crossOrigin);
|
|
51
57
|
});
|
|
52
58
|
styles.forEach((style) => {
|
|
53
|
-
|
|
59
|
+
var _a;
|
|
60
|
+
(_a = style.attributes).crossorigin ?? (_a.crossorigin = this.crossOrigin);
|
|
54
61
|
});
|
|
55
62
|
return alterAssetTags;
|
|
56
63
|
});
|
package/dist/server/restart.js
CHANGED
|
@@ -34,7 +34,7 @@ __export(restart_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(restart_exports);
|
|
35
35
|
var import_node_path = __toESM(require("node:path"));
|
|
36
36
|
var import_shared = require("@rsbuild/shared");
|
|
37
|
-
var
|
|
37
|
+
var import_init = require("../cli/init");
|
|
38
38
|
let cleaners = [];
|
|
39
39
|
const onBeforeRestartServer = (cleaner) => {
|
|
40
40
|
cleaners.push(cleaner);
|
|
@@ -53,7 +53,7 @@ const restartDevServer = async ({ filePath }) => {
|
|
|
53
53
|
await cleaner();
|
|
54
54
|
cleaners = [];
|
|
55
55
|
}
|
|
56
|
-
const rsbuild = await (0,
|
|
56
|
+
const rsbuild = await (0, import_init.init)({ isRestart: true });
|
|
57
57
|
if (!rsbuild) {
|
|
58
58
|
return;
|
|
59
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"types.d.ts"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@rspack/core": "0.5.
|
|
55
|
+
"@rspack/core": "0.5.5",
|
|
56
56
|
"@swc/helpers": "0.5.3",
|
|
57
57
|
"core-js": "~3.32.2",
|
|
58
|
-
"html-webpack-plugin": "npm:html-rspack-plugin@5.6.
|
|
58
|
+
"html-webpack-plugin": "npm:html-rspack-plugin@5.6.1",
|
|
59
59
|
"postcss": "^8.4.33",
|
|
60
|
-
"@rsbuild/shared": "0.4.
|
|
60
|
+
"@rsbuild/shared": "0.4.8"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "16.x",
|
|
File without changes
|