@rsbuild/core 0.2.11 → 0.2.13
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 -1
- package/dist/cli/commands.js +5 -5
- package/dist/cli/prepare.js +1 -1
- package/dist/client/hmr.js +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/plugins/bundleAnalyzer.js +11 -1
- package/dist/plugins/entry.js +28 -1
- package/dist/plugins/html.js +10 -4
- package/dist/plugins/index.js +2 -1
- package/dist/{provider/plugins → plugins}/server.d.ts +1 -1
- package/dist/{provider/plugins → plugins}/server.js +8 -27
- package/dist/plugins/splitChunks.d.ts +2 -0
- package/dist/plugins/splitChunks.js +15 -1
- package/dist/provider/core/createCompiler.d.ts +2 -2
- package/dist/provider/core/createContext.d.ts +6 -6
- package/dist/provider/core/createContext.js +1 -1
- package/dist/provider/core/devMiddleware.d.ts +1 -1
- package/dist/provider/core/initConfigs.d.ts +2 -2
- package/dist/provider/core/initPlugins.d.ts +3 -2
- package/dist/provider/core/initPlugins.js +8 -1
- package/dist/provider/core/rspackConfig.d.ts +2 -2
- package/dist/provider/index.d.ts +1 -1
- package/dist/provider/plugins/css.d.ts +2 -2
- package/dist/provider/shared.js +1 -1
- package/dist/rspack/HtmlAppIconPlugin.js +1 -1
- package/dist/rspack/InlineChunkHtmlPlugin.js +1 -1
- package/dist/rspack/RemoveCssSourcemapPlugin.js +1 -2
- package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +4 -5
- package/dist/server/devServer.d.ts +4 -4
- package/dist/server/devServer.js +4 -3
- package/dist/server/helper.d.ts +61 -0
- package/dist/server/helper.js +124 -0
- package/dist/server/prodServer.d.ts +3 -3
- package/dist/server/prodServer.js +4 -3
- package/dist/types.d.ts +2 -2
- package/package.json +2 -2
- package/compiled/commander/index.js +0 -1
- package/compiled/commander/license +0 -22
- package/compiled/commander/package.json +0 -1
- package/compiled/commander/typings/index.d.ts +0 -889
package/dist/cli/commands.d.ts
CHANGED
package/dist/cli/commands.js
CHANGED
|
@@ -34,7 +34,7 @@ __export(commands_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(commands_exports);
|
|
35
35
|
var import_path = require("path");
|
|
36
36
|
var import_shared = require("@rsbuild/shared");
|
|
37
|
-
var import_commander = require("
|
|
37
|
+
var import_commander = require("@rsbuild/shared/commander");
|
|
38
38
|
var import_loadEnv = require("../loadEnv");
|
|
39
39
|
var import_config = require("./config");
|
|
40
40
|
let commonOpts = {};
|
|
@@ -60,7 +60,7 @@ async function init({
|
|
|
60
60
|
};
|
|
61
61
|
if (commonOpts.open && !config.dev?.startUrl) {
|
|
62
62
|
config.dev || (config.dev = {});
|
|
63
|
-
config.dev.startUrl =
|
|
63
|
+
config.dev.startUrl = commonOpts.open;
|
|
64
64
|
}
|
|
65
65
|
if (commonOpts.host) {
|
|
66
66
|
config.server || (config.server = {});
|
|
@@ -83,8 +83,8 @@ async function init({
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
function runCli() {
|
|
86
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.2.
|
|
87
|
-
import_commander.program.command("dev").option("--open", "open the page in browser on startup").option(
|
|
86
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.2.13");
|
|
87
|
+
import_commander.program.command("dev").option("--open [url]", "open the page in browser on startup").option(
|
|
88
88
|
"--port <port>",
|
|
89
89
|
"specify a port number for Rsbuild Server to listen"
|
|
90
90
|
).option(
|
|
@@ -118,7 +118,7 @@ function runCli() {
|
|
|
118
118
|
process.exit(1);
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
|
-
import_commander.program.command("preview").option("--open", "open the page in browser on startup").option(
|
|
121
|
+
import_commander.program.command("preview").option("--open [url]", "open the page in browser on startup").option(
|
|
122
122
|
"--port <port>",
|
|
123
123
|
"specify a port number for Rsbuild Server to listen"
|
|
124
124
|
).option(
|
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.2.
|
|
37
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"0.2.13"}`}
|
|
38
38
|
`);
|
|
39
39
|
}
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/client/hmr.js
CHANGED
|
@@ -394,7 +394,6 @@ function getSocketUrl(urlParts, location) {
|
|
|
394
394
|
});
|
|
395
395
|
}
|
|
396
396
|
// src/client/hmr/index.ts
|
|
397
|
-
var hadRuntimeError = false;
|
|
398
397
|
var socketUrl = createSocketUrl(__resourceQuery);
|
|
399
398
|
var isFirstCompilation = true;
|
|
400
399
|
var mostRecentCompilationHash = null;
|
|
@@ -489,7 +488,7 @@ function tryApplyUpdates() {
|
|
|
489
488
|
return;
|
|
490
489
|
}
|
|
491
490
|
function handleApplyUpdates(err, updatedModules) {
|
|
492
|
-
var wantsForcedReload = err || !updatedModules
|
|
491
|
+
var wantsForcedReload = err || !updatedModules;
|
|
493
492
|
if (wantsForcedReload) {
|
|
494
493
|
window.location.reload();
|
|
495
494
|
return;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@ export { loadConfig, defineConfig } from './cli/config';
|
|
|
8
8
|
export { logger, mergeRsbuildConfig } from '@rsbuild/shared';
|
|
9
9
|
export type { Rspack } from './provider';
|
|
10
10
|
export type { RsbuildConfig, NormalizedConfig, RsbuildPlugin, RsbuildPluginAPI, } from './types';
|
|
11
|
-
export type {
|
|
11
|
+
export type { RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildContext, RsbuildInstance, CreateRsbuildOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn, } from '@rsbuild/shared';
|
|
@@ -31,13 +31,23 @@ __export(bundleAnalyzer_exports, {
|
|
|
31
31
|
pluginBundleAnalyzer: () => pluginBundleAnalyzer
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(bundleAnalyzer_exports);
|
|
34
|
+
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
const isUseAnalyzer = (config) => process.env.BUNDLE_ANALYZE || config.performance?.bundleAnalyze;
|
|
34
36
|
function pluginBundleAnalyzer() {
|
|
35
37
|
return {
|
|
36
38
|
name: "rsbuild:bundle-analyzer",
|
|
37
39
|
setup(api) {
|
|
40
|
+
api.modifyRsbuildConfig((config) => {
|
|
41
|
+
if ((0, import_shared.isProd)() || !isUseAnalyzer(config)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
config.dev || (config.dev = {});
|
|
45
|
+
config.dev.writeToDisk = true;
|
|
46
|
+
return config;
|
|
47
|
+
});
|
|
38
48
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
|
|
39
49
|
const config = api.getNormalizedConfig();
|
|
40
|
-
if (!
|
|
50
|
+
if (!isUseAnalyzer(config)) {
|
|
41
51
|
return;
|
|
42
52
|
}
|
|
43
53
|
const { default: BundleAnalyzer } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/webpack-bundle-analyzer")));
|
package/dist/plugins/entry.js
CHANGED
|
@@ -31,12 +31,39 @@ const pluginEntry = () => ({
|
|
|
31
31
|
const { preEntry } = config.source;
|
|
32
32
|
const injectCoreJsEntry = config.output.polyfill === "entry" && !isServer && !isServiceWorker;
|
|
33
33
|
Object.keys(entry).forEach((entryName) => {
|
|
34
|
-
const
|
|
34
|
+
const entryImport = [];
|
|
35
|
+
let entryDescription = null;
|
|
36
|
+
const appendEntry = (item) => {
|
|
37
|
+
if (typeof item === "string") {
|
|
38
|
+
entryImport.push(item);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (item.import) {
|
|
42
|
+
entryImport.push(...(0, import_shared.castArray)(item.import));
|
|
43
|
+
}
|
|
44
|
+
if (entryDescription) {
|
|
45
|
+
Object.assign(entryDescription, item);
|
|
46
|
+
} else {
|
|
47
|
+
entryDescription = item;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
35
50
|
preEntry.forEach(appendEntry);
|
|
36
51
|
if (injectCoreJsEntry) {
|
|
37
52
|
appendEntry((0, import_shared.createVirtualModule)('import "core-js";'));
|
|
38
53
|
}
|
|
39
54
|
(0, import_shared.castArray)(entry[entryName]).forEach(appendEntry);
|
|
55
|
+
chain.entryPoints.set(entryName, {
|
|
56
|
+
// @ts-expect-error EntryDescription type mismatch
|
|
57
|
+
values() {
|
|
58
|
+
if (entryDescription) {
|
|
59
|
+
return {
|
|
60
|
+
...entryDescription,
|
|
61
|
+
import: entryImport
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return entryImport;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
40
67
|
});
|
|
41
68
|
});
|
|
42
69
|
api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
|
package/dist/plugins/html.js
CHANGED
|
@@ -136,11 +136,13 @@ function getTemplateParameters(entryName, config, assetPrefix) {
|
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
function getChunks(entryName, entryValue) {
|
|
139
|
-
const dependOn = [];
|
|
140
139
|
if ((0, import_shared.isPlainObject)(entryValue)) {
|
|
141
|
-
dependOn
|
|
140
|
+
const { dependOn } = entryValue;
|
|
141
|
+
if (Array.isArray(dependOn)) {
|
|
142
|
+
return [...dependOn, entryName];
|
|
143
|
+
}
|
|
142
144
|
}
|
|
143
|
-
return [
|
|
145
|
+
return [entryName];
|
|
144
146
|
}
|
|
145
147
|
const applyInjectTags = (api) => {
|
|
146
148
|
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
@@ -194,7 +196,11 @@ const pluginHtml = () => ({
|
|
|
194
196
|
await Promise.all(
|
|
195
197
|
entryNames.map(async (entryName) => {
|
|
196
198
|
const entryValue = entries[entryName].values();
|
|
197
|
-
const chunks = getChunks(
|
|
199
|
+
const chunks = getChunks(
|
|
200
|
+
entryName,
|
|
201
|
+
// @ts-expect-error EntryDescription type mismatch
|
|
202
|
+
entryValue
|
|
203
|
+
);
|
|
198
204
|
const inject = getInject(entryName, config);
|
|
199
205
|
const filename = htmlPaths[entryName];
|
|
200
206
|
const { templatePath, templateContent } = await getTemplate(
|
package/dist/plugins/index.js
CHANGED
|
@@ -53,7 +53,8 @@ const plugins = {
|
|
|
53
53
|
networkPerformance: () => Promise.resolve().then(() => __toESM(require("./networkPerformance"))).then((m) => m.pluginNetworkPerformance()),
|
|
54
54
|
preloadOrPrefetch: () => Promise.resolve().then(() => __toESM(require("./preloadOrPrefetch"))).then((m) => m.pluginPreloadOrPrefetch()),
|
|
55
55
|
performance: () => Promise.resolve().then(() => __toESM(require("./performance"))).then((m) => m.pluginPerformance()),
|
|
56
|
-
define: () => Promise.resolve().then(() => __toESM(require("./define"))).then((m) => m.pluginDefine())
|
|
56
|
+
define: () => Promise.resolve().then(() => __toESM(require("./define"))).then((m) => m.pluginDefine()),
|
|
57
|
+
server: () => Promise.resolve().then(() => __toESM(require("./server"))).then((m) => m.pluginServer())
|
|
57
58
|
};
|
|
58
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
60
|
0 && (module.exports = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '
|
|
1
|
+
import type { RsbuildPlugin } from '../types';
|
|
2
2
|
export declare const pluginServer: () => RsbuildPlugin;
|
|
@@ -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,49 +15,32 @@ 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 server_exports = {};
|
|
30
20
|
__export(server_exports, {
|
|
31
21
|
pluginServer: () => pluginServer
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(server_exports);
|
|
34
|
-
var
|
|
24
|
+
var import_shared = require("@rsbuild/shared");
|
|
35
25
|
var import_path = require("path");
|
|
36
26
|
const pluginServer = () => ({
|
|
37
27
|
name: "rsbuild:server",
|
|
38
28
|
setup(api) {
|
|
39
|
-
api.
|
|
29
|
+
api.onBeforeBuild(async () => {
|
|
40
30
|
const config = api.getNormalizedConfig();
|
|
41
|
-
if (
|
|
31
|
+
if (config.server?.publicDir) {
|
|
42
32
|
const { name, copyOnBuild } = config.server?.publicDir;
|
|
43
33
|
if (!copyOnBuild || !name) {
|
|
44
34
|
return;
|
|
45
35
|
}
|
|
46
36
|
const publicDir = (0, import_path.isAbsolute)(name) ? name : (0, import_path.join)(api.context.rootPath, name);
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
from: publicDir,
|
|
50
|
-
to: "",
|
|
51
|
-
noErrorOnMissing: true
|
|
52
|
-
}
|
|
53
|
-
];
|
|
54
|
-
if (!import_fs.default.existsSync(publicDir)) {
|
|
37
|
+
if (!import_shared.fse.existsSync(publicDir)) {
|
|
55
38
|
return;
|
|
56
39
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
]);
|
|
40
|
+
await import_shared.fse.copy(publicDir, api.context.distPath, {
|
|
41
|
+
// dereference symlinks
|
|
42
|
+
dereference: true
|
|
43
|
+
});
|
|
63
44
|
}
|
|
64
45
|
});
|
|
65
46
|
}
|
|
@@ -28,6 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var splitChunks_exports = {};
|
|
30
30
|
__export(splitChunks_exports, {
|
|
31
|
+
MODULE_PATH_REGEX: () => MODULE_PATH_REGEX,
|
|
32
|
+
getPackageNameFromModulePath: () => getPackageNameFromModulePath,
|
|
31
33
|
pluginSplitChunks: () => pluginSplitChunks
|
|
32
34
|
});
|
|
33
35
|
module.exports = __toCommonJS(splitChunks_exports);
|
|
@@ -84,6 +86,16 @@ function splitByExperience(ctx) {
|
|
|
84
86
|
}
|
|
85
87
|
};
|
|
86
88
|
}
|
|
89
|
+
const MODULE_PATH_REGEX = /[\\/]node_modules[\\/](\.pnpm[\\/])?(?:(@[^[\\/]+)(?:[\\/]))?([^\\/]+)/;
|
|
90
|
+
function getPackageNameFromModulePath(modulePath) {
|
|
91
|
+
const handleModuleContext = modulePath?.match(MODULE_PATH_REGEX);
|
|
92
|
+
if (!handleModuleContext) {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
const [, , scope, name] = handleModuleContext;
|
|
96
|
+
const packageName = ["npm", (scope ?? "").replace("@", ""), name].filter(Boolean).join(".");
|
|
97
|
+
return packageName;
|
|
98
|
+
}
|
|
87
99
|
function splitByModule(ctx) {
|
|
88
100
|
const { override, userDefinedCacheGroups, defaultConfig } = ctx;
|
|
89
101
|
return {
|
|
@@ -99,7 +111,7 @@ function splitByModule(ctx) {
|
|
|
99
111
|
priority: -10,
|
|
100
112
|
test: import_shared.NODE_MODULES_REGEX,
|
|
101
113
|
name(module2) {
|
|
102
|
-
return module2 ?
|
|
114
|
+
return module2 ? getPackageNameFromModulePath(module2.context) : void 0;
|
|
103
115
|
}
|
|
104
116
|
},
|
|
105
117
|
...override.cacheGroups
|
|
@@ -220,5 +232,7 @@ function pluginSplitChunks() {
|
|
|
220
232
|
}
|
|
221
233
|
// Annotate the CommonJS export names for ESM import in node:
|
|
222
234
|
0 && (module.exports = {
|
|
235
|
+
MODULE_PATH_REGEX,
|
|
236
|
+
getPackageNameFromModulePath,
|
|
223
237
|
pluginSplitChunks
|
|
224
238
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type RspackConfig, type RspackCompiler, type RspackMultiCompiler, type CreateDevMiddlewareReturns } from '@rsbuild/shared';
|
|
2
2
|
import { type InitConfigsOptions } from './initConfigs';
|
|
3
|
-
import type {
|
|
3
|
+
import type { InternalContext } from '../../types';
|
|
4
4
|
export declare function createCompiler({ context, rspackConfigs, }: {
|
|
5
|
-
context:
|
|
5
|
+
context: InternalContext;
|
|
6
6
|
rspackConfigs: RspackConfig[];
|
|
7
7
|
}): Promise<RspackCompiler | RspackMultiCompiler>;
|
|
8
8
|
export declare function createDevMiddleware(options: InitConfigsOptions, customCompiler?: RspackCompiler | RspackMultiCompiler): Promise<CreateDevMiddlewareReturns>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { RsbuildConfig, type
|
|
2
|
-
import type {
|
|
1
|
+
import { RsbuildConfig, type BundlerType, type RsbuildContext, type NormalizedConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
+
import type { InternalContext } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Create context by config.
|
|
5
5
|
*/
|
|
6
|
-
export declare function createContextByConfig(options: Required<CreateRsbuildOptions>, bundlerType: BundlerType, config?: RsbuildConfig):
|
|
7
|
-
export declare function updateContextByNormalizedConfig(context:
|
|
8
|
-
export declare function createPublicContext(context:
|
|
6
|
+
export declare function createContextByConfig(options: Required<CreateRsbuildOptions>, bundlerType: BundlerType, config?: RsbuildConfig): RsbuildContext;
|
|
7
|
+
export declare function updateContextByNormalizedConfig(context: RsbuildContext, config: NormalizedConfig): void;
|
|
8
|
+
export declare function createPublicContext(context: RsbuildContext): Readonly<RsbuildContext>;
|
|
9
9
|
/**
|
|
10
10
|
* Generate the actual context used in the build,
|
|
11
11
|
* which can have a lot of overhead and take some side effects.
|
|
12
12
|
*/
|
|
13
|
-
export declare function createContext(options: Required<CreateRsbuildOptions>, userRsbuildConfig: RsbuildConfig, bundlerType: BundlerType): Promise<
|
|
13
|
+
export declare function createContext(options: Required<CreateRsbuildOptions>, userRsbuildConfig: RsbuildConfig, bundlerType: BundlerType): Promise<InternalContext>;
|
|
@@ -59,7 +59,7 @@ function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
59
59
|
const context = {
|
|
60
60
|
entry: config.source?.entry || getDefaultEntry(rootPath),
|
|
61
61
|
targets: config.output?.targets || [],
|
|
62
|
-
version: "0.2.
|
|
62
|
+
version: "0.2.13",
|
|
63
63
|
rootPath,
|
|
64
64
|
distPath,
|
|
65
65
|
cachePath,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DevMiddleware } from '@rsbuild/shared';
|
|
1
|
+
import { type DevMiddleware } from '@rsbuild/shared';
|
|
2
2
|
import type { Compiler, MultiCompiler } from '@rspack/core';
|
|
3
3
|
export declare const getDevMiddleware: (multiCompiler: Compiler | MultiCompiler) => NonNullable<DevMiddleware>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type PluginStore, type RspackConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
-
import type {
|
|
2
|
+
import type { InternalContext, NormalizedConfig } from '../../types';
|
|
3
3
|
export type InitConfigsOptions = {
|
|
4
|
-
context:
|
|
4
|
+
context: InternalContext;
|
|
5
5
|
pluginStore: PluginStore;
|
|
6
6
|
rsbuildOptions: Required<CreateRsbuildOptions>;
|
|
7
7
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type PluginStore, type RsbuildPluginAPI } from '@rsbuild/shared';
|
|
2
|
-
import type {
|
|
2
|
+
import type { InternalContext, NormalizedConfig } from '../../types';
|
|
3
|
+
export declare function getHTMLPathByEntry(entryName: string, config: NormalizedConfig): string;
|
|
3
4
|
export declare function getPluginAPI({ context, pluginStore, }: {
|
|
4
|
-
context:
|
|
5
|
+
context: InternalContext;
|
|
5
6
|
pluginStore: PluginStore;
|
|
6
7
|
}): RsbuildPluginAPI;
|
|
@@ -18,11 +18,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var initPlugins_exports = {};
|
|
20
20
|
__export(initPlugins_exports, {
|
|
21
|
+
getHTMLPathByEntry: () => getHTMLPathByEntry,
|
|
21
22
|
getPluginAPI: () => getPluginAPI
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(initPlugins_exports);
|
|
24
25
|
var import_shared = require("@rsbuild/shared");
|
|
25
26
|
var import_createContext = require("./createContext");
|
|
27
|
+
function getHTMLPathByEntry(entryName, config) {
|
|
28
|
+
const htmlPath = (0, import_shared.getDistPath)(config, "html");
|
|
29
|
+
const filename = config.html.outputStructure === "flat" ? `${entryName}.html` : `${entryName}/index.html`;
|
|
30
|
+
return (0, import_shared.removeLeadingSlash)(`${htmlPath}/${filename}`);
|
|
31
|
+
}
|
|
26
32
|
function getPluginAPI({
|
|
27
33
|
context,
|
|
28
34
|
pluginStore
|
|
@@ -51,7 +57,7 @@ function getPluginAPI({
|
|
|
51
57
|
const getHTMLPaths = () => {
|
|
52
58
|
return Object.keys(context.entry).reduce(
|
|
53
59
|
(prev, key) => {
|
|
54
|
-
prev[key] =
|
|
60
|
+
prev[key] = getHTMLPathByEntry(key, getNormalizedConfig());
|
|
55
61
|
return prev;
|
|
56
62
|
},
|
|
57
63
|
{}
|
|
@@ -86,5 +92,6 @@ function getPluginAPI({
|
|
|
86
92
|
}
|
|
87
93
|
// Annotate the CommonJS export names for ESM import in node:
|
|
88
94
|
0 && (module.exports = {
|
|
95
|
+
getHTMLPathByEntry,
|
|
89
96
|
getPluginAPI
|
|
90
97
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RspackConfig, type RsbuildTarget } from '@rsbuild/shared';
|
|
2
|
-
import type {
|
|
2
|
+
import type { InternalContext } from '../../types';
|
|
3
3
|
export declare function generateRspackConfig({ target, context, }: {
|
|
4
4
|
target: RsbuildTarget;
|
|
5
|
-
context:
|
|
5
|
+
context: InternalContext;
|
|
6
6
|
}): Promise<RspackConfig>;
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export { withDefaultConfig } from './config';
|
|
|
7
7
|
export { initRsbuildConfig } from './core/initConfigs';
|
|
8
8
|
export { getPluginAPI } from './core/initPlugins';
|
|
9
9
|
export { applyBaseCSSRule, applyCSSModuleRule } from './plugins/css';
|
|
10
|
-
export type {
|
|
10
|
+
export type { InternalContext } from '../types';
|
|
11
11
|
export { setHTMLPlugin, getHTMLPlugin } from './htmlPluginUtil';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type BundlerChain, type
|
|
1
|
+
import { type BundlerChain, type RsbuildContext, type RspackRule, type ModifyBundlerChainUtils } from '@rsbuild/shared';
|
|
2
2
|
import type { RsbuildPlugin, NormalizedConfig } from '../../types';
|
|
3
3
|
export declare const enableNativeCss: (config: NormalizedConfig) => boolean;
|
|
4
4
|
export declare function applyBaseCSSRule({ rule, config, context, utils: { target, isProd, isServer, isWebWorker, CHAIN_ID }, importLoaders, }: {
|
|
5
5
|
rule: ReturnType<BundlerChain['module']['rule']>;
|
|
6
6
|
config: NormalizedConfig;
|
|
7
|
-
context:
|
|
7
|
+
context: RsbuildContext;
|
|
8
8
|
utils: ModifyBundlerChainUtils;
|
|
9
9
|
importLoaders?: number;
|
|
10
10
|
}): Promise<void>;
|
package/dist/provider/shared.js
CHANGED
|
@@ -73,7 +73,7 @@ const applyDefaultPlugins = (plugins) => (0, import_shared3.awaitableGetter)([
|
|
|
73
73
|
plugins.networkPerformance(),
|
|
74
74
|
plugins.preloadOrPrefetch(),
|
|
75
75
|
plugins.performance(),
|
|
76
|
-
|
|
76
|
+
plugins.server(),
|
|
77
77
|
Promise.resolve().then(() => __toESM(require("./plugins/rspackProfile"))).then((m) => m.pluginRspackProfile())
|
|
78
78
|
]);
|
|
79
79
|
const rspackMinVersion = "0.4.0";
|
|
@@ -71,7 +71,7 @@ class HtmlAppIconPlugin {
|
|
|
71
71
|
compilation.hooks.processAssets.tap(
|
|
72
72
|
{
|
|
73
73
|
name: this.name,
|
|
74
|
-
stage:
|
|
74
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_PRE_PROCESS
|
|
75
75
|
},
|
|
76
76
|
(assets) => {
|
|
77
77
|
const source = import_fs.default.readFileSync(this.iconPath);
|
|
@@ -163,7 +163,7 @@ class InlineChunkHtmlPlugin {
|
|
|
163
163
|
* Remove marked inline assets in summarize stage,
|
|
164
164
|
* which should be later than the emitting of html-webpack-plugin
|
|
165
165
|
*/
|
|
166
|
-
stage:
|
|
166
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
167
167
|
},
|
|
168
168
|
() => {
|
|
169
169
|
const { devtool } = compiler.options;
|
|
@@ -21,7 +21,6 @@ __export(RemoveCssSourcemapPlugin_exports, {
|
|
|
21
21
|
RemoveCssSourcemapPlugin: () => RemoveCssSourcemapPlugin
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(RemoveCssSourcemapPlugin_exports);
|
|
24
|
-
var import_shared = require("@rsbuild/shared");
|
|
25
24
|
class RemoveCssSourcemapPlugin {
|
|
26
25
|
constructor() {
|
|
27
26
|
this.name = "RemoveCssSourcemapPlugin";
|
|
@@ -31,7 +30,7 @@ class RemoveCssSourcemapPlugin {
|
|
|
31
30
|
compilation.hooks.processAssets.tap(
|
|
32
31
|
{
|
|
33
32
|
name: this.name,
|
|
34
|
-
stage:
|
|
33
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
35
34
|
},
|
|
36
35
|
() => {
|
|
37
36
|
Object.keys(compilation.assets).forEach((name) => {
|
|
@@ -58,11 +58,10 @@ function generateLinks(options, type, compilation, htmlPluginData, HTMLCount) {
|
|
|
58
58
|
});
|
|
59
59
|
const htmlChunks = (
|
|
60
60
|
// Handle all chunks.
|
|
61
|
-
options.type === "all-assets" || HTMLCount === 1 ? extractedChunks :
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
(0, import_helpers.doesChunkBelongToHtml)({
|
|
61
|
+
options.type === "all-assets" || HTMLCount === 1 ? extractedChunks : (
|
|
62
|
+
// Only handle chunks imported by this HtmlWebpackPlugin.
|
|
63
|
+
extractedChunks.filter(
|
|
64
|
+
(chunk) => (0, import_helpers.doesChunkBelongToHtml)({
|
|
66
65
|
chunk,
|
|
67
66
|
compilation,
|
|
68
67
|
htmlPluginData,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import { StartServerResult, type DevServerAPIs, type StartDevServerOptions, type CreateDevMiddlewareReturns } from '@rsbuild/shared';
|
|
2
|
+
import type { InternalContext } from '../types';
|
|
3
3
|
export declare function getServerAPIs<Options extends {
|
|
4
|
-
context:
|
|
4
|
+
context: InternalContext;
|
|
5
5
|
}>(options: Options, createDevMiddleware: (options: Options, compiler: StartDevServerOptions['compiler']) => Promise<CreateDevMiddlewareReturns>, { compiler: customCompiler, getPortSilently, }?: StartDevServerOptions & {
|
|
6
6
|
defaultPort?: number;
|
|
7
7
|
}): Promise<DevServerAPIs>;
|
|
8
8
|
export declare function startDevServer<Options extends {
|
|
9
|
-
context:
|
|
9
|
+
context: InternalContext;
|
|
10
10
|
}>(options: Options, createDevMiddleware: (options: Options, compiler: StartDevServerOptions['compiler']) => Promise<CreateDevMiddlewareReturns>, { compiler, printURLs, logger: customLogger, getPortSilently, }?: StartDevServerOptions & {
|
|
11
11
|
defaultPort?: number;
|
|
12
12
|
}): Promise<StartServerResult>;
|
package/dist/server/devServer.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(devServer_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(devServer_exports);
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
|
+
var import_helper = require("./helper");
|
|
36
37
|
var import_connect = __toESM(require("@rsbuild/shared/connect"));
|
|
37
38
|
var import_restart = require("./restart");
|
|
38
39
|
var import_httpServer = require("./httpServer");
|
|
@@ -46,11 +47,11 @@ async function getServerAPIs(options, createDevMiddleware, {
|
|
|
46
47
|
process.env.NODE_ENV = "development";
|
|
47
48
|
}
|
|
48
49
|
const rsbuildConfig = options.context.config;
|
|
49
|
-
const { devServerConfig, port, host, https } = await (0,
|
|
50
|
+
const { devServerConfig, port, host, https } = await (0, import_helper.getDevOptions)({
|
|
50
51
|
rsbuildConfig,
|
|
51
52
|
getPortSilently
|
|
52
53
|
});
|
|
53
|
-
const defaultRoutes = (0,
|
|
54
|
+
const defaultRoutes = (0, import_helper.formatRoutes)(
|
|
54
55
|
options.context.entry,
|
|
55
56
|
rsbuildConfig.output?.distPath?.html,
|
|
56
57
|
rsbuildConfig.html?.outputStructure
|
|
@@ -141,7 +142,7 @@ async function startDevServer(options, createDevMiddleware, {
|
|
|
141
142
|
throw new Error("Please return an array in the `printURLs` function.");
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
|
-
(0,
|
|
145
|
+
(0, import_helper.printServerURLs)(urls, defaultRoutes, logger);
|
|
145
146
|
}
|
|
146
147
|
const compileMiddlewareAPI = await serverAPIs.startCompile();
|
|
147
148
|
const devMiddlewares = await serverAPIs.getMiddlewares({
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Logger, Routes, DevConfig, RsbuildEntry, RsbuildConfig, OutputStructure } from '@rsbuild/shared';
|
|
3
|
+
export declare const formatRoutes: (entry: RsbuildEntry, prefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
|
|
4
|
+
export declare function printServerURLs(urls: Array<{
|
|
5
|
+
url: string;
|
|
6
|
+
label: string;
|
|
7
|
+
}>, routes: Routes, logger?: Logger): void;
|
|
8
|
+
/**
|
|
9
|
+
* hmr socket connect path
|
|
10
|
+
*/
|
|
11
|
+
export declare const HMR_SOCK_PATH = "/rsbuild-hmr";
|
|
12
|
+
export declare const mergeDevOptions: ({ rsbuildConfig, port, }: {
|
|
13
|
+
rsbuildConfig: RsbuildConfig;
|
|
14
|
+
port: number;
|
|
15
|
+
}) => DevConfig;
|
|
16
|
+
export declare const getServerOptions: ({ rsbuildConfig, getPortSilently, }: {
|
|
17
|
+
rsbuildConfig: RsbuildConfig;
|
|
18
|
+
getPortSilently?: boolean | undefined;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
port: number;
|
|
21
|
+
host: string;
|
|
22
|
+
https: boolean;
|
|
23
|
+
serverConfig: import("@rsbuild/shared").ServerConfig;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const getDevOptions: ({ rsbuildConfig, getPortSilently, }: {
|
|
26
|
+
rsbuildConfig: RsbuildConfig;
|
|
27
|
+
getPortSilently?: boolean | undefined;
|
|
28
|
+
}) => Promise<{
|
|
29
|
+
devServerConfig: {
|
|
30
|
+
hmr?: boolean | undefined;
|
|
31
|
+
liveReload?: boolean | undefined;
|
|
32
|
+
startUrl?: string | boolean | string[] | undefined;
|
|
33
|
+
beforeStartUrl?: import("@rsbuild/shared").ArrayOrNot<() => void | Promise<void>> | undefined;
|
|
34
|
+
assetPrefix?: string | boolean | undefined;
|
|
35
|
+
progressBar?: boolean | import("@rsbuild/shared").ProgressBarConfig | undefined;
|
|
36
|
+
client?: {
|
|
37
|
+
path?: string | undefined;
|
|
38
|
+
port?: string | undefined;
|
|
39
|
+
host?: string | undefined;
|
|
40
|
+
protocol?: string | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
setupMiddlewares?: ((middlewares: {
|
|
43
|
+
unshift: (...handlers: import("@rsbuild/shared").RequestHandler[]) => void;
|
|
44
|
+
push: (...handlers: import("@rsbuild/shared").RequestHandler[]) => void;
|
|
45
|
+
}, server: import("@rsbuild/shared").ServerAPIs) => void)[] | undefined;
|
|
46
|
+
writeToDisk?: boolean | ((filename: string) => boolean) | undefined;
|
|
47
|
+
compress?: boolean | undefined;
|
|
48
|
+
publicDir?: import("@rsbuild/shared").PublicDir | undefined;
|
|
49
|
+
port?: number | undefined;
|
|
50
|
+
https?: import("https").ServerOptions | undefined;
|
|
51
|
+
host?: string | undefined;
|
|
52
|
+
headers?: Record<string, string | string[]> | undefined;
|
|
53
|
+
htmlFallback?: import("@rsbuild/shared").HtmlFallback | undefined;
|
|
54
|
+
historyApiFallback?: boolean | import("@rsbuild/shared").HistoryApiFallbackOptions | undefined;
|
|
55
|
+
proxy?: import("@rsbuild/shared").ProxyOptions | undefined;
|
|
56
|
+
strictPort?: boolean | undefined;
|
|
57
|
+
};
|
|
58
|
+
port: number;
|
|
59
|
+
host: string;
|
|
60
|
+
https: boolean;
|
|
61
|
+
}>;
|