@rsbuild/core 0.3.6 → 0.3.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/compiled/on-finished/index.d.ts +13 -0
- package/compiled/on-finished/index.js +14 -0
- package/compiled/on-finished/license +23 -0
- package/compiled/on-finished/package.json +1 -0
- package/dist/cli/commands.js +7 -6
- package/dist/cli/config.d.ts +4 -2
- package/dist/cli/config.js +12 -10
- package/dist/cli/prepare.js +1 -1
- package/dist/index.js +1 -1
- package/dist/loadEnv.js +9 -4
- package/dist/plugins/asset.js +3 -3
- package/dist/plugins/basic.js +2 -2
- package/dist/plugins/cache.js +9 -9
- package/dist/plugins/fileSize.js +7 -7
- package/dist/plugins/html.js +4 -4
- package/dist/plugins/inlineChunk.js +2 -2
- package/dist/plugins/nodeAddons.js +3 -3
- package/dist/plugins/server.js +2 -2
- package/dist/plugins/splitChunks.js +2 -2
- package/dist/plugins/startUrl.js +5 -5
- package/dist/plugins/wasm.js +2 -2
- package/dist/provider/config.js +5 -11
- package/dist/provider/core/createContext.js +4 -4
- package/dist/provider/core/inspectConfig.js +3 -3
- package/dist/provider/core/rspackConfig.d.ts +2 -1
- package/dist/provider/core/rspackConfig.js +8 -5
- package/dist/provider/htmlPluginUtil.d.ts +1 -1
- package/dist/provider/htmlPluginUtil.js +7 -13
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.js +3 -0
- package/dist/provider/plugins/css.js +9 -5
- package/dist/provider/plugins/output.js +3 -3
- package/dist/provider/plugins/resolve.js +3 -7
- package/dist/provider/plugins/rspackProfile.d.ts +1 -1
- package/dist/provider/plugins/rspackProfile.js +7 -7
- package/dist/provider/plugins/swc.js +3 -3
- package/dist/provider/shared.js +2 -2
- package/dist/rspack/HtmlAppIconPlugin.js +5 -5
- package/dist/rspack/InlineChunkHtmlPlugin.js +2 -2
- package/dist/rspack/preload/helpers/determineAsValue.js +11 -27
- package/dist/server/compilerDevMiddleware.d.ts +2 -2
- package/dist/server/getDevMiddlewares.js +9 -5
- package/dist/server/httpServer.js +2 -2
- package/dist/server/middlewares.d.ts +2 -0
- package/dist/server/middlewares.js +55 -11
- package/dist/server/prodServer.d.ts +1 -1
- package/dist/server/prodServer.js +5 -2
- package/dist/server/restart.js +2 -2
- package/dist/server/socketServer.d.ts +2 -2
- package/package.json +3 -3
- package/types.d.ts +24 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage, OutgoingMessage } from 'http';
|
|
3
|
+
|
|
4
|
+
export = onFinished;
|
|
5
|
+
|
|
6
|
+
declare function onFinished<T extends IncomingMessage | OutgoingMessage>(
|
|
7
|
+
msg: T,
|
|
8
|
+
listener: (err: Error | null, msg: T) => void,
|
|
9
|
+
): T;
|
|
10
|
+
|
|
11
|
+
declare namespace onFinished {
|
|
12
|
+
function isFinished(msg: IncomingMessage | OutgoingMessage): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
(()=>{"use strict";var e={261:e=>{
|
|
2
|
+
/*!
|
|
3
|
+
* ee-first
|
|
4
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
*/
|
|
7
|
+
e.exports=first;function first(e,n){if(!Array.isArray(e))throw new TypeError("arg must be an array of [ee, events...] arrays");var r=[];for(var t=0;t<e.length;t++){var i=e[t];if(!Array.isArray(i)||i.length<2)throw new TypeError("each array member must be [ee, events...]");var o=i[0];for(var a=1;a<i.length;a++){var s=i[a];var u=listener(s,callback);o.on(s,u);r.push({ee:o,event:s,fn:u})}}function callback(){cleanup();n.apply(null,arguments)}function cleanup(){var e;for(var n=0;n<r.length;n++){e=r[n];e.ee.removeListener(e.event,e.fn)}}function thunk(e){n=e}thunk.cancel=cleanup;return thunk}function listener(e,n){return function onevent(r){var t=new Array(arguments.length);var i=this;var o=e==="error"?r:null;for(var a=0;a<t.length;a++){t[a]=arguments[a]}n(o,i,e,t)}}},772:(e,n,r)=>{
|
|
8
|
+
/*!
|
|
9
|
+
* on-finished
|
|
10
|
+
* Copyright(c) 2013 Jonathan Ong
|
|
11
|
+
* Copyright(c) 2014 Douglas Christopher Wilson
|
|
12
|
+
* MIT Licensed
|
|
13
|
+
*/
|
|
14
|
+
e.exports=onFinished;e.exports.isFinished=isFinished;var t=tryRequireAsyncHooks();var i=r(261);var o=typeof setImmediate==="function"?setImmediate:function(e){process.nextTick(e.bind.apply(e,arguments))};function onFinished(e,n){if(isFinished(e)!==false){o(n,null,e);return e}attachListener(e,wrap(n));return e}function isFinished(e){var n=e.socket;if(typeof e.finished==="boolean"){return Boolean(e.finished||n&&!n.writable)}if(typeof e.complete==="boolean"){return Boolean(e.upgrade||!n||!n.readable||e.complete&&!e.readable)}return undefined}function attachFinishedListener(e,n){var r;var t;var o=false;function onFinish(e){r.cancel();t.cancel();o=true;n(e)}r=t=i([[e,"end","finish"]],onFinish);function onSocket(n){e.removeListener("socket",onSocket);if(o)return;if(r!==t)return;t=i([[n,"error","close"]],onFinish)}if(e.socket){onSocket(e.socket);return}e.on("socket",onSocket);if(e.socket===undefined){patchAssignSocket(e,onSocket)}}function attachListener(e,n){var r=e.__onFinished;if(!r||!r.queue){r=e.__onFinished=createListener(e);attachFinishedListener(e,r)}r.queue.push(n)}function createListener(e){function listener(n){if(e.__onFinished===listener)e.__onFinished=null;if(!listener.queue)return;var r=listener.queue;listener.queue=null;for(var t=0;t<r.length;t++){r[t](n,e)}}listener.queue=[];return listener}function patchAssignSocket(e,n){var r=e.assignSocket;if(typeof r!=="function")return;e.assignSocket=function _assignSocket(e){r.call(this,e);n(e)}}function tryRequireAsyncHooks(){try{return r(852)}catch(e){return{}}}function wrap(e){var n;if(t.AsyncResource){n=new t.AsyncResource(e.name||"bound-anonymous-fn")}if(!n||!n.runInAsyncScope){return e}return n.runInAsyncScope.bind(n,e,null)}},852:e=>{e.exports=require("async_hooks")}};var n={};function __nccwpck_require__(r){var t=n[r];if(t!==undefined){return t.exports}var i=n[r]={exports:{}};var o=true;try{e[r](i,i.exports,__nccwpck_require__);o=false}finally{if(o)delete n[r]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(772);module.exports=r})();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 Jonathan Ong <me@jongleberry.com>
|
|
4
|
+
Copyright (c) 2014 Douglas Christopher Wilson <doug@somethingdoug.com>
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
'Software'), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
20
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
21
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
22
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
23
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"on-finished","version":"2.4.1","license":"MIT","type":"commonjs"}
|
package/dist/cli/commands.js
CHANGED
|
@@ -32,8 +32,8 @@ __export(commands_exports, {
|
|
|
32
32
|
runCli: () => runCli
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(commands_exports);
|
|
35
|
-
var
|
|
36
|
-
var
|
|
35
|
+
var import_node_path = require("node:path");
|
|
36
|
+
var import_node_fs = require("node:fs");
|
|
37
37
|
var import_shared = require("@rsbuild/shared");
|
|
38
38
|
var import_commander = require("@rsbuild/shared/commander");
|
|
39
39
|
var import_loadEnv = require("../loadEnv");
|
|
@@ -58,7 +58,8 @@ async function init({
|
|
|
58
58
|
}
|
|
59
59
|
const { content: config, filePath: configFilePath } = await (0, import_config.loadConfigV2)({
|
|
60
60
|
cwd: root,
|
|
61
|
-
path: commonOpts.config
|
|
61
|
+
path: commonOpts.config,
|
|
62
|
+
envMode: commonOpts.envMode
|
|
62
63
|
});
|
|
63
64
|
const command = process.argv[2];
|
|
64
65
|
if (command === "dev") {
|
|
@@ -111,7 +112,7 @@ const applyServerOptions = (command) => {
|
|
|
111
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");
|
|
112
113
|
};
|
|
113
114
|
function runCli() {
|
|
114
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.
|
|
115
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.8");
|
|
115
116
|
const devCommand = import_commander.program.command("dev");
|
|
116
117
|
const buildCommand = import_commander.program.command("build");
|
|
117
118
|
const previewCommand = import_commander.program.command("preview");
|
|
@@ -145,7 +146,7 @@ function runCli() {
|
|
|
145
146
|
previewCommand.description("preview the production build locally").action(async (options) => {
|
|
146
147
|
try {
|
|
147
148
|
const rsbuild = await init({ cliOptions: options });
|
|
148
|
-
if (rsbuild && !(0,
|
|
149
|
+
if (rsbuild && !(0, import_node_fs.existsSync)(rsbuild.context.distPath)) {
|
|
149
150
|
throw new Error(
|
|
150
151
|
`The output directory ${import_shared.color.yellow(
|
|
151
152
|
rsbuild.context.distPath
|
|
@@ -165,7 +166,7 @@ function runCli() {
|
|
|
165
166
|
await rsbuild?.inspectConfig({
|
|
166
167
|
env: options.env,
|
|
167
168
|
verbose: options.verbose,
|
|
168
|
-
outputPath: (0,
|
|
169
|
+
outputPath: (0, import_node_path.join)(rsbuild.context.distPath, options.output),
|
|
169
170
|
writeToDisk: true
|
|
170
171
|
});
|
|
171
172
|
} catch (err) {
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type RsbuildConfig } from '@rsbuild/shared';
|
|
|
2
2
|
export type ConfigParams = {
|
|
3
3
|
env: string;
|
|
4
4
|
command: string;
|
|
5
|
+
envMode?: string;
|
|
5
6
|
};
|
|
6
7
|
export type RsbuildConfigAsyncFn = (env: ConfigParams) => Promise<RsbuildConfig>;
|
|
7
8
|
export type RsbuildConfigSyncFn = (env: ConfigParams) => RsbuildConfig;
|
|
@@ -15,14 +16,15 @@ export declare function defineConfig(config: RsbuildConfigSyncFn): RsbuildConfig
|
|
|
15
16
|
export declare function defineConfig(config: RsbuildConfigAsyncFn): RsbuildConfigAsyncFn;
|
|
16
17
|
export declare function defineConfig(config: RsbuildConfigExport): RsbuildConfigExport;
|
|
17
18
|
export declare function watchFiles(files: string[]): Promise<void>;
|
|
18
|
-
export declare function loadConfigByPath(configFile: string): Promise<RsbuildConfig>;
|
|
19
|
+
export declare function loadConfigByPath(configFile: string, envMode?: string): Promise<RsbuildConfig>;
|
|
19
20
|
export declare function loadConfig({ cwd, path, }: {
|
|
20
21
|
cwd: string;
|
|
21
22
|
path?: string;
|
|
22
23
|
}): Promise<RsbuildConfig>;
|
|
23
|
-
export declare function loadConfigV2({ cwd, path, }: {
|
|
24
|
+
export declare function loadConfigV2({ cwd, path, envMode, }: {
|
|
24
25
|
cwd: string;
|
|
25
26
|
path?: string;
|
|
27
|
+
envMode?: string;
|
|
26
28
|
}): Promise<{
|
|
27
29
|
content: RsbuildConfig;
|
|
28
30
|
filePath: string | null;
|
package/dist/cli/config.js
CHANGED
|
@@ -35,8 +35,8 @@ __export(config_exports, {
|
|
|
35
35
|
watchFiles: () => watchFiles
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(config_exports);
|
|
38
|
-
var
|
|
39
|
-
var
|
|
38
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
39
|
+
var import_node_path = require("node:path");
|
|
40
40
|
var import_shared = require("@rsbuild/shared");
|
|
41
41
|
var import_restart = require("../server/restart");
|
|
42
42
|
function defineConfig(config) {
|
|
@@ -44,8 +44,8 @@ function defineConfig(config) {
|
|
|
44
44
|
}
|
|
45
45
|
const resolveConfigPath = (root, customConfig) => {
|
|
46
46
|
if (customConfig) {
|
|
47
|
-
const customConfigPath = (0,
|
|
48
|
-
if (
|
|
47
|
+
const customConfigPath = (0, import_node_path.isAbsolute)(customConfig) ? customConfig : (0, import_node_path.join)(root, customConfig);
|
|
48
|
+
if (import_node_fs.default.existsSync(customConfigPath)) {
|
|
49
49
|
return customConfigPath;
|
|
50
50
|
}
|
|
51
51
|
import_shared.logger.warn(`Cannot find config file: ${import_shared.color.dim(customConfigPath)}
|
|
@@ -60,8 +60,8 @@ const resolveConfigPath = (root, customConfig) => {
|
|
|
60
60
|
"rsbuild.config.cts"
|
|
61
61
|
];
|
|
62
62
|
for (const file of CONFIG_FILES) {
|
|
63
|
-
const configFile = (0,
|
|
64
|
-
if (
|
|
63
|
+
const configFile = (0, import_node_path.join)(root, file);
|
|
64
|
+
if (import_node_fs.default.existsSync(configFile)) {
|
|
65
65
|
return configFile;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -90,7 +90,7 @@ async function watchFiles(files) {
|
|
|
90
90
|
watcher.on("change", callback);
|
|
91
91
|
watcher.on("unlink", callback);
|
|
92
92
|
}
|
|
93
|
-
async function loadConfigByPath(configFile) {
|
|
93
|
+
async function loadConfigByPath(configFile, envMode) {
|
|
94
94
|
try {
|
|
95
95
|
const { default: jiti } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/jiti")));
|
|
96
96
|
const loadConfig2 = jiti(__filename, {
|
|
@@ -104,7 +104,8 @@ async function loadConfigByPath(configFile) {
|
|
|
104
104
|
const command = process.argv[2];
|
|
105
105
|
const params = {
|
|
106
106
|
env: (0, import_shared.getNodeEnv)(),
|
|
107
|
-
command
|
|
107
|
+
command,
|
|
108
|
+
envMode: envMode || (0, import_shared.getNodeEnv)()
|
|
108
109
|
};
|
|
109
110
|
const result = await configExport(params);
|
|
110
111
|
if (result === void 0) {
|
|
@@ -137,7 +138,8 @@ async function loadConfig({
|
|
|
137
138
|
}
|
|
138
139
|
async function loadConfigV2({
|
|
139
140
|
cwd,
|
|
140
|
-
path
|
|
141
|
+
path,
|
|
142
|
+
envMode
|
|
141
143
|
}) {
|
|
142
144
|
const configFile = resolveConfigPath(cwd, path);
|
|
143
145
|
if (!configFile) {
|
|
@@ -147,7 +149,7 @@ async function loadConfigV2({
|
|
|
147
149
|
};
|
|
148
150
|
}
|
|
149
151
|
return {
|
|
150
|
-
content: await loadConfigByPath(configFile),
|
|
152
|
+
content: await loadConfigByPath(configFile, envMode),
|
|
151
153
|
filePath: configFile
|
|
152
154
|
};
|
|
153
155
|
}
|
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.8"}`}
|
|
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.8";
|
|
42
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
43
|
0 && (module.exports = {
|
|
44
44
|
PLUGIN_BABEL_NAME,
|
package/dist/loadEnv.js
CHANGED
|
@@ -31,8 +31,8 @@ __export(loadEnv_exports, {
|
|
|
31
31
|
loadEnv: () => loadEnv
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(loadEnv_exports);
|
|
34
|
-
var
|
|
35
|
-
var
|
|
34
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
35
|
+
var import_node_path = require("node:path");
|
|
36
36
|
var import_shared = require("@rsbuild/shared");
|
|
37
37
|
var import_dotenv = require("../compiled/dotenv");
|
|
38
38
|
var import_dotenv_expand = require("../compiled/dotenv-expand");
|
|
@@ -41,16 +41,21 @@ function loadEnv({
|
|
|
41
41
|
mode = (0, import_shared.getNodeEnv)(),
|
|
42
42
|
prefixes = ["PUBLIC_"]
|
|
43
43
|
} = {}) {
|
|
44
|
+
if (mode === "local") {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`'local' cannot be used as a value for env mode, because ".env.local" represents a temporary local file. Please use another value.`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
44
49
|
const filenames = [
|
|
45
50
|
".env",
|
|
46
51
|
".env.local",
|
|
47
52
|
`.env.${mode}`,
|
|
48
53
|
`.env.${mode}.local`
|
|
49
54
|
];
|
|
50
|
-
const filePaths = filenames.map((filename) => (0,
|
|
55
|
+
const filePaths = filenames.map((filename) => (0, import_node_path.join)(cwd, filename)).filter(import_shared.isFileSync);
|
|
51
56
|
const parsed = {};
|
|
52
57
|
filePaths.forEach((envPath) => {
|
|
53
|
-
Object.assign(parsed, (0, import_dotenv.parse)(
|
|
58
|
+
Object.assign(parsed, (0, import_dotenv.parse)(import_node_fs.default.readFileSync(envPath)));
|
|
54
59
|
});
|
|
55
60
|
(0, import_dotenv_expand.expand)({ parsed });
|
|
56
61
|
const publicVars = {};
|
package/dist/plugins/asset.js
CHANGED
|
@@ -32,7 +32,7 @@ __export(asset_exports, {
|
|
|
32
32
|
pluginAsset: () => pluginAsset
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(asset_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_node_path = __toESM(require("node:path"));
|
|
36
36
|
var import_shared = require("@rsbuild/shared");
|
|
37
37
|
function getRegExpForExts(exts) {
|
|
38
38
|
const matcher = exts.map((ext) => ext.trim()).map((ext) => ext.startsWith(".") ? ext.slice(1) : ext).join("|");
|
|
@@ -55,13 +55,13 @@ const pluginAsset = () => ({
|
|
|
55
55
|
(0, import_shared.chainStaticAssetRule)({
|
|
56
56
|
rule,
|
|
57
57
|
maxSize,
|
|
58
|
-
filename:
|
|
58
|
+
filename: import_node_path.default.posix.join(distDir, filename),
|
|
59
59
|
assetType
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
62
|
createAssetRule("image", import_shared.IMAGE_EXTENSIONS);
|
|
63
63
|
createAssetRule("svg", ["svg"]);
|
|
64
|
-
createAssetRule("media", import_shared.
|
|
64
|
+
createAssetRule("media", [...import_shared.VIDEO_EXTENSIONS, ...import_shared.AUDIO_EXTENSIONS]);
|
|
65
65
|
createAssetRule("font", import_shared.FONT_EXTENSIONS);
|
|
66
66
|
});
|
|
67
67
|
}
|
package/dist/plugins/basic.js
CHANGED
|
@@ -31,7 +31,7 @@ __export(basic_exports, {
|
|
|
31
31
|
pluginBasic: () => pluginBasic
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(basic_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_node_path = __toESM(require("node:path"));
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
36
|
const pluginBasic = () => ({
|
|
37
37
|
name: "rsbuild:basic",
|
|
@@ -61,7 +61,7 @@ const pluginBasic = () => ({
|
|
|
61
61
|
}
|
|
62
62
|
if (env === "development") {
|
|
63
63
|
chain.output.devtoolModuleFilenameTemplate(
|
|
64
|
-
(info) =>
|
|
64
|
+
(info) => import_node_path.default.resolve(info.absoluteResourcePath).replace(/\\/g, "/")
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
}
|
package/dist/plugins/cache.js
CHANGED
|
@@ -31,12 +31,12 @@ __export(cache_exports, {
|
|
|
31
31
|
pluginCache: () => pluginCache
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(cache_exports);
|
|
34
|
-
var
|
|
35
|
-
var
|
|
34
|
+
var import_node_crypto = __toESM(require("node:crypto"));
|
|
35
|
+
var import_node_path = require("node:path");
|
|
36
36
|
var import_shared = require("@rsbuild/shared");
|
|
37
37
|
var import_shared2 = require("@rsbuild/shared");
|
|
38
38
|
async function validateCache(cacheDirectory, buildDependencies) {
|
|
39
|
-
const configFile = (0,
|
|
39
|
+
const configFile = (0, import_node_path.join)(cacheDirectory, "buildDependencies.json");
|
|
40
40
|
if (await (0, import_shared2.isFileExists)(configFile)) {
|
|
41
41
|
const prevBuildDependencies = await import_shared.fse.readJSON(configFile);
|
|
42
42
|
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) {
|
|
@@ -47,19 +47,19 @@ async function validateCache(cacheDirectory, buildDependencies) {
|
|
|
47
47
|
await import_shared.fse.outputJSON(configFile, buildDependencies);
|
|
48
48
|
}
|
|
49
49
|
function getDigestHash(digest) {
|
|
50
|
-
const fsHash =
|
|
50
|
+
const fsHash = import_node_crypto.default.createHash("md5");
|
|
51
51
|
const md5 = fsHash.update(JSON.stringify(digest)).digest("hex").slice(0, 8);
|
|
52
52
|
return md5;
|
|
53
53
|
}
|
|
54
54
|
function getCacheDirectory({ cacheDirectory }, context) {
|
|
55
55
|
if (cacheDirectory) {
|
|
56
|
-
return (0,
|
|
56
|
+
return (0, import_node_path.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, import_node_path.join)(context.rootPath, cacheDirectory);
|
|
57
57
|
}
|
|
58
|
-
return (0,
|
|
58
|
+
return (0, import_node_path.join)(context.cachePath, context.bundlerType);
|
|
59
59
|
}
|
|
60
60
|
async function getBuildDependencies(context) {
|
|
61
|
-
const rootPackageJson = (0,
|
|
62
|
-
const browserslistConfig = (0,
|
|
61
|
+
const rootPackageJson = (0, import_node_path.join)(context.rootPath, "package.json");
|
|
62
|
+
const browserslistConfig = (0, import_node_path.join)(context.rootPath, ".browserslistrc");
|
|
63
63
|
const buildDependencies = {};
|
|
64
64
|
if (await (0, import_shared2.isFileExists)(rootPackageJson)) {
|
|
65
65
|
buildDependencies.packageJson = [rootPackageJson];
|
|
@@ -72,7 +72,7 @@ async function getBuildDependencies(context) {
|
|
|
72
72
|
}
|
|
73
73
|
const tailwindExts = ["ts", "js", "cjs", "mjs"];
|
|
74
74
|
const configs = tailwindExts.map(
|
|
75
|
-
(ext) => (0,
|
|
75
|
+
(ext) => (0, import_node_path.join)(context.rootPath, `tailwind.config.${ext}`)
|
|
76
76
|
);
|
|
77
77
|
const tailwindConfig = (0, import_shared2.findExists)(configs);
|
|
78
78
|
if (tailwindConfig) {
|
package/dist/plugins/fileSize.js
CHANGED
|
@@ -32,7 +32,7 @@ __export(fileSize_exports, {
|
|
|
32
32
|
pluginFileSize: () => pluginFileSize
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(fileSize_exports);
|
|
35
|
-
var
|
|
35
|
+
var import_node_path = __toESM(require("node:path"));
|
|
36
36
|
var import_shared = require("@rsbuild/shared");
|
|
37
37
|
var import_shared2 = require("@rsbuild/shared");
|
|
38
38
|
const filterAsset = (asset) => !/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
|
|
@@ -68,13 +68,13 @@ async function printFileSizes(config, stats, distPath) {
|
|
|
68
68
|
const { default: gzipSize } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/gzip-size")));
|
|
69
69
|
const formatAsset = (asset) => {
|
|
70
70
|
const fileName = asset.name.split("?")[0];
|
|
71
|
-
const contents = import_shared.fse.readFileSync(
|
|
71
|
+
const contents = import_shared.fse.readFileSync(import_node_path.default.join(distPath, fileName));
|
|
72
72
|
const size = contents.length;
|
|
73
73
|
const gzippedSize = gzipSize.sync(contents);
|
|
74
74
|
return {
|
|
75
75
|
size,
|
|
76
|
-
folder:
|
|
77
|
-
name:
|
|
76
|
+
folder: import_node_path.default.join(import_node_path.default.basename(distPath), import_node_path.default.dirname(fileName)),
|
|
77
|
+
name: import_node_path.default.basename(fileName),
|
|
78
78
|
gzippedSize,
|
|
79
79
|
sizeLabel: calcFileSize(size),
|
|
80
80
|
gzipSizeLabel: getAssetColor(gzippedSize)(calcFileSize(gzippedSize))
|
|
@@ -104,7 +104,7 @@ async function printFileSizes(config, stats, distPath) {
|
|
|
104
104
|
import_shared2.logger.info("Production file sizes:\n");
|
|
105
105
|
const longestLabelLength = Math.max(...assets.map((a) => a.sizeLabel.length));
|
|
106
106
|
const longestFileLength = Math.max(
|
|
107
|
-
...assets.map((a) => (a.folder +
|
|
107
|
+
...assets.map((a) => (a.folder + import_node_path.default.sep + a.name).length)
|
|
108
108
|
);
|
|
109
109
|
if (config.detail !== false) {
|
|
110
110
|
printHeader(longestFileLength, longestLabelLength);
|
|
@@ -114,7 +114,7 @@ async function printFileSizes(config, stats, distPath) {
|
|
|
114
114
|
assets.forEach((asset) => {
|
|
115
115
|
let { sizeLabel } = asset;
|
|
116
116
|
const { name, folder, gzipSizeLabel } = asset;
|
|
117
|
-
const fileNameLength = (folder +
|
|
117
|
+
const fileNameLength = (folder + import_node_path.default.sep + name).length;
|
|
118
118
|
const sizeLength = sizeLabel.length;
|
|
119
119
|
totalSize += asset.size;
|
|
120
120
|
totalGzipSize += asset.gzippedSize;
|
|
@@ -123,7 +123,7 @@ async function printFileSizes(config, stats, distPath) {
|
|
|
123
123
|
const rightPadding = " ".repeat(longestLabelLength - sizeLength);
|
|
124
124
|
sizeLabel += rightPadding;
|
|
125
125
|
}
|
|
126
|
-
let fileNameLabel = import_shared2.color.dim(asset.folder +
|
|
126
|
+
let fileNameLabel = import_shared2.color.dim(asset.folder + import_node_path.default.sep) + import_shared2.color.cyan(asset.name);
|
|
127
127
|
if (fileNameLength < longestFileLength) {
|
|
128
128
|
const rightPadding = " ".repeat(longestFileLength - fileNameLength);
|
|
129
129
|
fileNameLabel += rightPadding;
|
package/dist/plugins/html.js
CHANGED
|
@@ -37,7 +37,7 @@ __export(html_exports, {
|
|
|
37
37
|
pluginHtml: () => pluginHtml
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(html_exports);
|
|
40
|
-
var
|
|
40
|
+
var import_node_path = __toESM(require("node:path"));
|
|
41
41
|
var import_shared = require("@rsbuild/shared");
|
|
42
42
|
function getTitle(entryName, config) {
|
|
43
43
|
return (0, import_shared.mergeChainedOptions)({
|
|
@@ -58,7 +58,7 @@ function getInject(entryName, config) {
|
|
|
58
58
|
}
|
|
59
59
|
const existTemplatePath = [];
|
|
60
60
|
async function getTemplate(entryName, config, rootPath) {
|
|
61
|
-
const DEFAULT_TEMPLATE =
|
|
61
|
+
const DEFAULT_TEMPLATE = import_node_path.default.resolve(
|
|
62
62
|
__dirname,
|
|
63
63
|
"../../static/template.html"
|
|
64
64
|
);
|
|
@@ -73,7 +73,7 @@ async function getTemplate(entryName, config, rootPath) {
|
|
|
73
73
|
templatePath
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
const absolutePath = (0,
|
|
76
|
+
const absolutePath = (0, import_node_path.isAbsolute)(templatePath) ? templatePath : import_node_path.default.resolve(rootPath, templatePath);
|
|
77
77
|
if (!existTemplatePath.includes(absolutePath)) {
|
|
78
78
|
if (!await (0, import_shared.isFileExists)(absolutePath)) {
|
|
79
79
|
throw new Error(
|
|
@@ -274,7 +274,7 @@ const pluginHtml = () => ({
|
|
|
274
274
|
if (appIcon) {
|
|
275
275
|
const { HtmlAppIconPlugin } = await Promise.resolve().then(() => __toESM(require("../rspack/HtmlAppIconPlugin")));
|
|
276
276
|
const distDir = (0, import_shared.getDistPath)(config, "image");
|
|
277
|
-
const iconPath =
|
|
277
|
+
const iconPath = import_node_path.default.isAbsolute(appIcon) ? appIcon : import_node_path.default.join(api.context.rootPath, appIcon);
|
|
278
278
|
chain.plugin(CHAIN_ID.PLUGIN.APP_ICON).use(HtmlAppIconPlugin, [{ iconPath, distDir }]);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
@@ -35,9 +35,9 @@ var import_shared = require("@rsbuild/shared");
|
|
|
35
35
|
const pluginInlineChunk = () => ({
|
|
36
36
|
name: "rsbuild:inline-chunk",
|
|
37
37
|
setup(api) {
|
|
38
|
-
api.modifyBundlerChain(async (chain, { target, CHAIN_ID,
|
|
38
|
+
api.modifyBundlerChain(async (chain, { target, CHAIN_ID, isDev }) => {
|
|
39
39
|
const config = api.getNormalizedConfig();
|
|
40
|
-
if ((0, import_shared.isHtmlDisabled)(config, target) ||
|
|
40
|
+
if ((0, import_shared.isHtmlDisabled)(config, target) || isDev) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
const { InlineChunkHtmlPlugin } = await Promise.resolve().then(() => __toESM(require("../rspack/InlineChunkHtmlPlugin")));
|
|
@@ -21,7 +21,7 @@ __export(nodeAddons_exports, {
|
|
|
21
21
|
pluginNodeAddons: () => pluginNodeAddons
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(nodeAddons_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_node_path = require("node:path");
|
|
25
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
26
|
const pluginNodeAddons = () => ({
|
|
27
27
|
name: "rsbuild:node-addons",
|
|
@@ -33,7 +33,7 @@ const pluginNodeAddons = () => ({
|
|
|
33
33
|
const getDistName = (resourcePath) => {
|
|
34
34
|
const pkgJSON = (0, import_shared.findUpSync)({
|
|
35
35
|
filename: "package.json",
|
|
36
|
-
cwd: (0,
|
|
36
|
+
cwd: (0, import_node_path.dirname)(resourcePath)
|
|
37
37
|
});
|
|
38
38
|
if (!pkgJSON) {
|
|
39
39
|
throw new Error(
|
|
@@ -56,7 +56,7 @@ const pluginNodeAddons = () => ({
|
|
|
56
56
|
const serverPath = (0, import_shared.getDistPath)(config, "server");
|
|
57
57
|
return `${serverPath}/${getFilename(resourcePath, pkgName)}`;
|
|
58
58
|
};
|
|
59
|
-
chain.module.rule(CHAIN_ID.RULE.NODE).test(/\.node$/).use(CHAIN_ID.USE.NODE).loader((0,
|
|
59
|
+
chain.module.rule(CHAIN_ID.RULE.NODE).test(/\.node$/).use(CHAIN_ID.USE.NODE).loader((0, import_node_path.join)(__dirname, "../../compiled/node-loader")).options({
|
|
60
60
|
name: getDistName
|
|
61
61
|
});
|
|
62
62
|
});
|
package/dist/plugins/server.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(server_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(server_exports);
|
|
24
24
|
var import_shared = require("@rsbuild/shared");
|
|
25
|
-
var
|
|
25
|
+
var import_node_path = require("node:path");
|
|
26
26
|
const pluginServer = () => ({
|
|
27
27
|
name: "rsbuild:server",
|
|
28
28
|
setup(api) {
|
|
@@ -33,7 +33,7 @@ const pluginServer = () => ({
|
|
|
33
33
|
if (!copyOnBuild || !name) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
const publicDir = (0,
|
|
36
|
+
const publicDir = (0, import_node_path.isAbsolute)(name) ? name : (0, import_node_path.join)(api.context.rootPath, name);
|
|
37
37
|
if (!import_shared.fse.existsSync(publicDir)) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
@@ -33,7 +33,7 @@ __export(splitChunks_exports, {
|
|
|
33
33
|
pluginSplitChunks: () => pluginSplitChunks
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(splitChunks_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_node_assert = __toESM(require("node:assert"));
|
|
37
37
|
var import_shared = require("@rsbuild/shared");
|
|
38
38
|
function getUserDefinedCacheGroups(forceSplitting) {
|
|
39
39
|
const cacheGroups = {};
|
|
@@ -120,7 +120,7 @@ function splitByModule(ctx) {
|
|
|
120
120
|
}
|
|
121
121
|
function splitBySize(ctx) {
|
|
122
122
|
const { override, userDefinedCacheGroups, defaultConfig, rsbuildConfig } = ctx;
|
|
123
|
-
(0,
|
|
123
|
+
(0, import_node_assert.default)(rsbuildConfig.strategy === "split-by-size");
|
|
124
124
|
return {
|
|
125
125
|
...defaultConfig,
|
|
126
126
|
minSize: rsbuildConfig.minSize ?? 0,
|
package/dist/plugins/startUrl.js
CHANGED
|
@@ -33,11 +33,11 @@ __export(startUrl_exports, {
|
|
|
33
33
|
replacePlaceholder: () => replacePlaceholder
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(startUrl_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_node_path = require("node:path");
|
|
37
37
|
var import_shared = require("@rsbuild/shared");
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
const execAsync = (0,
|
|
38
|
+
var import_node_child_process = require("node:child_process");
|
|
39
|
+
var import_node_util = require("node:util");
|
|
40
|
+
const execAsync = (0, import_node_util.promisify)(import_node_child_process.exec);
|
|
41
41
|
const supportedChromiumBrowsers = [
|
|
42
42
|
"Google Chrome Canary",
|
|
43
43
|
"Google Chrome Dev",
|
|
@@ -67,7 +67,7 @@ async function openBrowser(url) {
|
|
|
67
67
|
url
|
|
68
68
|
)}" "${targetBrowser}"`,
|
|
69
69
|
{
|
|
70
|
-
cwd: (0,
|
|
70
|
+
cwd: (0, import_node_path.join)(__dirname, "../../static")
|
|
71
71
|
}
|
|
72
72
|
);
|
|
73
73
|
return true;
|
package/dist/plugins/wasm.js
CHANGED
|
@@ -21,7 +21,7 @@ __export(wasm_exports, {
|
|
|
21
21
|
pluginWasm: () => pluginWasm
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(wasm_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_node_path = require("node:path");
|
|
25
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
26
|
const pluginWasm = () => ({
|
|
27
27
|
name: "rsbuild:wasm",
|
|
@@ -33,7 +33,7 @@ const pluginWasm = () => ({
|
|
|
33
33
|
...chain.get("experiments"),
|
|
34
34
|
asyncWebAssembly: true
|
|
35
35
|
});
|
|
36
|
-
const wasmFilename =
|
|
36
|
+
const wasmFilename = import_node_path.posix.join(distPath, "[hash].module.wasm");
|
|
37
37
|
chain.output.merge({
|
|
38
38
|
webassemblyModuleFilename: wasmFilename
|
|
39
39
|
});
|
package/dist/provider/config.js
CHANGED
|
@@ -22,7 +22,7 @@ __export(config_exports, {
|
|
|
22
22
|
withDefaultConfig: () => withDefaultConfig
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(config_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_node_path = require("node:path");
|
|
26
26
|
var import_shared = require("@rsbuild/shared");
|
|
27
27
|
const createDefaultConfig = () => ({
|
|
28
28
|
dev: (0, import_shared.getDefaultDevConfig)(),
|
|
@@ -44,7 +44,7 @@ function getDefaultEntry(root) {
|
|
|
44
44
|
"jsx",
|
|
45
45
|
".mjs",
|
|
46
46
|
".cjs"
|
|
47
|
-
].map((ext) => (0,
|
|
47
|
+
].map((ext) => (0, import_node_path.join)(root, `src/index.${ext}`));
|
|
48
48
|
const entryFile = (0, import_shared.findExists)(files);
|
|
49
49
|
if (entryFile) {
|
|
50
50
|
return {
|
|
@@ -54,26 +54,20 @@ function getDefaultEntry(root) {
|
|
|
54
54
|
return {};
|
|
55
55
|
}
|
|
56
56
|
const withDefaultConfig = async (rootPath, config) => {
|
|
57
|
-
const merged = (0, import_shared.mergeRsbuildConfig)(
|
|
58
|
-
createDefaultConfig(),
|
|
59
|
-
config
|
|
60
|
-
);
|
|
57
|
+
const merged = (0, import_shared.mergeRsbuildConfig)(createDefaultConfig(), config);
|
|
61
58
|
merged.source || (merged.source = {});
|
|
62
59
|
if (!merged.source.entry) {
|
|
63
60
|
merged.source.entry = getDefaultEntry(rootPath);
|
|
64
61
|
}
|
|
65
62
|
if (!merged.source.tsconfigPath) {
|
|
66
|
-
const tsconfigPath = (0,
|
|
63
|
+
const tsconfigPath = (0, import_node_path.join)(rootPath, import_shared.TS_CONFIG_FILE);
|
|
67
64
|
if (await (0, import_shared.isFileExists)(tsconfigPath)) {
|
|
68
65
|
merged.source.tsconfigPath = tsconfigPath;
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
return merged;
|
|
72
69
|
};
|
|
73
|
-
const normalizeConfig = (config) => (0, import_shared.mergeRsbuildConfig)(
|
|
74
|
-
createDefaultConfig(),
|
|
75
|
-
config
|
|
76
|
-
);
|
|
70
|
+
const normalizeConfig = (config) => (0, import_shared.mergeRsbuildConfig)(createDefaultConfig(), config);
|
|
77
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
78
72
|
0 && (module.exports = {
|
|
79
73
|
normalizeConfig,
|
|
@@ -23,12 +23,12 @@ __export(createContext_exports, {
|
|
|
23
23
|
updateContextByNormalizedConfig: () => updateContextByNormalizedConfig
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(createContext_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_node_path = require("node:path");
|
|
27
27
|
var import_shared = require("@rsbuild/shared");
|
|
28
28
|
var import_initHooks = require("./initHooks");
|
|
29
29
|
var import_config = require("../config");
|
|
30
30
|
function getAbsolutePath(root, filepath) {
|
|
31
|
-
return (0,
|
|
31
|
+
return (0, import_node_path.isAbsolute)(filepath) ? filepath : (0, import_node_path.join)(root, filepath);
|
|
32
32
|
}
|
|
33
33
|
function getAbsoluteDistPath(cwd, config) {
|
|
34
34
|
const dirRoot = (0, import_shared.getDistPath)(config, "root");
|
|
@@ -38,12 +38,12 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
38
38
|
const { cwd } = options;
|
|
39
39
|
const rootPath = cwd;
|
|
40
40
|
const distPath = getAbsoluteDistPath(cwd, config);
|
|
41
|
-
const cachePath = (0,
|
|
41
|
+
const cachePath = (0, import_node_path.join)(rootPath, "node_modules", ".cache");
|
|
42
42
|
const tsconfigPath = config.source?.tsconfigPath;
|
|
43
43
|
const context = {
|
|
44
44
|
entry: config.source?.entry || {},
|
|
45
45
|
targets: config.output?.targets || [],
|
|
46
|
-
version: "0.3.
|
|
46
|
+
version: "0.3.8",
|
|
47
47
|
rootPath,
|
|
48
48
|
distPath,
|
|
49
49
|
cachePath,
|