@rsbuild/core 0.0.17 → 0.0.19
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/bin/rsbuild.js +11 -0
- package/dist/cli/commands.d.ts +3 -0
- package/dist/cli/commands.js +4 -2
- package/dist/cli/config.d.ts +4 -0
- package/dist/cli/index.js +2 -1
- package/dist/plugins/define.js +8 -18
- package/dist/plugins/index.js +0 -1
- package/dist/plugins/nodeAddons.js +10 -17
- package/dist/plugins/startUrl.js +11 -15
- package/dist/rspack-provider/core/createCompiler.d.ts +4 -1
- package/dist/rspack-provider/core/createCompiler.js +26 -7
- package/dist/rspack-provider/core/devMiddleware.d.ts +2 -4
- package/dist/rspack-provider/plugins/progress.js +5 -1
- package/dist/rspack-provider/plugins/swc.js +2 -3
- package/dist/rspack-provider/provider.js +5 -3
- package/dist/rspack-provider/shared/plugin.js +0 -1
- package/dist/server/constants.d.ts +6 -0
- package/dist/server/constants.js +49 -0
- package/dist/server/dev-middleware/hmr-client/createSocketUrl.d.ts +16 -0
- package/dist/server/dev-middleware/hmr-client/createSocketUrl.js +68 -0
- package/dist/server/dev-middleware/hmr-client/index.d.ts +1 -0
- package/dist/server/dev-middleware/hmr-client/index.js +164 -0
- package/dist/server/dev-middleware/index.d.ts +22 -0
- package/dist/server/dev-middleware/index.js +90 -0
- package/dist/server/dev-middleware/socketServer.d.ts +22 -0
- package/dist/server/dev-middleware/socketServer.js +167 -0
- package/dist/server/devServer.d.ts +35 -0
- package/dist/server/devServer.js +235 -0
- package/dist/server/https.d.ts +6 -0
- package/dist/server/https.js +50 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +31 -0
- package/dist/server/middlewares.d.ts +2 -0
- package/dist/server/middlewares.js +35 -0
- package/dist/server/prodServer.d.ts +27 -0
- package/dist/server/prodServer.js +136 -0
- package/dist/server/proxy.d.ts +9 -0
- package/dist/server/proxy.js +92 -0
- package/package.json +32 -5
- package/types.d.ts +130 -0
- package/dist/plugins/assetsRetry.d.ts +0 -2
- package/dist/plugins/assetsRetry.js +0 -66
- package/dist/rspack-provider/core/startDevServer.d.ts +0 -6
- package/dist/rspack-provider/core/startDevServer.js +0 -84
package/bin/rsbuild.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { logger } = require('rslog');
|
|
3
3
|
|
|
4
|
+
function initNodeEnv() {
|
|
5
|
+
if (!process.env.NODE_ENV) {
|
|
6
|
+
const command = process.argv[2];
|
|
7
|
+
process.env.NODE_ENV = ['build', 'preview'].includes(command)
|
|
8
|
+
? 'production'
|
|
9
|
+
: 'development';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
4
13
|
async function main() {
|
|
14
|
+
initNodeEnv();
|
|
15
|
+
|
|
5
16
|
const { version } = require('../package.json');
|
|
6
17
|
|
|
7
18
|
// If not called through a package manager,
|
package/dist/cli/commands.d.ts
CHANGED
package/dist/cli/commands.js
CHANGED
|
@@ -28,8 +28,10 @@ function setupProgram(rsbuild) {
|
|
|
28
28
|
const pkgJson = (0, import_path.join)(__dirname, "../../package.json");
|
|
29
29
|
const { version } = import_fs_extra.fs.readJSONSync(pkgJson);
|
|
30
30
|
import_commander.program.name("rsbuild").usage("<command> [options]").version(version);
|
|
31
|
-
import_commander.program.command("dev").description("starting the dev server").action(async () => {
|
|
32
|
-
await rsbuild.startDevServer(
|
|
31
|
+
import_commander.program.command("dev").option(`--open`, "open the page in browser on startup").description("starting the dev server").action(async (options) => {
|
|
32
|
+
await rsbuild.startDevServer({
|
|
33
|
+
open: options.open
|
|
34
|
+
});
|
|
33
35
|
});
|
|
34
36
|
import_commander.program.command("build").description("build the app for production").action(async () => {
|
|
35
37
|
await rsbuild.build();
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ export type RsbuildConfig = BaseRsbuildConfig & {
|
|
|
4
4
|
entries?: RsbuildEntry;
|
|
5
5
|
};
|
|
6
6
|
plugins?: RsbuildPlugin[];
|
|
7
|
+
/**
|
|
8
|
+
* @private only for testing
|
|
9
|
+
*/
|
|
10
|
+
provider?: any;
|
|
7
11
|
};
|
|
8
12
|
export declare const defineConfig: (config: RsbuildConfig) => RsbuildConfig;
|
|
9
13
|
export declare function loadConfig(): Promise<ReturnType<typeof defineConfig>>;
|
package/dist/cli/index.js
CHANGED
|
@@ -31,7 +31,8 @@ async function runCli(options = {}) {
|
|
|
31
31
|
const config = await (0, import_config.loadConfig)();
|
|
32
32
|
const rsbuild = await (0, import__.createRsbuild)({
|
|
33
33
|
rsbuildConfig: config,
|
|
34
|
-
entry: ((_a = config.source) == null ? void 0 : _a.entries) || (0, import_config.getDefaultEntries)()
|
|
34
|
+
entry: ((_a = config.source) == null ? void 0 : _a.entries) || (0, import_config.getDefaultEntries)(),
|
|
35
|
+
provider: config.provider
|
|
35
36
|
});
|
|
36
37
|
if (options.defaultPlugins) {
|
|
37
38
|
rsbuild.addPlugins(options.defaultPlugins);
|
package/dist/plugins/define.js
CHANGED
|
@@ -21,33 +21,23 @@ __export(define_exports, {
|
|
|
21
21
|
pluginDefine: () => pluginDefine
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(define_exports);
|
|
24
|
-
var import_lodash = require("lodash");
|
|
25
24
|
var import_shared = require("@rsbuild/shared");
|
|
26
25
|
const pluginDefine = () => ({
|
|
27
26
|
name: "plugin-define",
|
|
28
27
|
setup(api) {
|
|
29
|
-
api.modifyBundlerChain((chain, {
|
|
28
|
+
api.modifyBundlerChain((chain, { CHAIN_ID, bundler }) => {
|
|
30
29
|
const config = api.getNormalizedConfig();
|
|
31
30
|
const publicPath = chain.output.get("publicPath");
|
|
32
31
|
const assetPrefix = publicPath && typeof publicPath === "string" ? publicPath : config.output.assetPrefix;
|
|
33
32
|
const builtinVars = {
|
|
34
|
-
"process.env.NODE_ENV": process.env.NODE_ENV,
|
|
35
|
-
"process.env.ASSET_PREFIX":
|
|
33
|
+
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
|
|
34
|
+
"process.env.ASSET_PREFIX": JSON.stringify(
|
|
35
|
+
(0, import_shared.removeTailSlash)(assetPrefix)
|
|
36
|
+
)
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
utils: { env, target }
|
|
41
|
-
});
|
|
42
|
-
const serializedVars = (0, import_lodash.mapValues)(
|
|
43
|
-
globalVars,
|
|
44
|
-
(value) => {
|
|
45
|
-
var _a;
|
|
46
|
-
return (_a = JSON.stringify(value)) != null ? _a : "undefined";
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
const defineExprs = config.source.define;
|
|
50
|
-
chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(bundler.DefinePlugin, [{ ...serializedVars, ...defineExprs }]);
|
|
38
|
+
chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(bundler.DefinePlugin, [
|
|
39
|
+
{ ...builtinVars, ...config.source.define }
|
|
40
|
+
]);
|
|
51
41
|
});
|
|
52
42
|
}
|
|
53
43
|
});
|
package/dist/plugins/index.js
CHANGED
|
@@ -50,7 +50,6 @@ const plugins = {
|
|
|
50
50
|
font: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset("font", import_shared.FONT_EXTENSIONS)),
|
|
51
51
|
image: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset("image", import_shared.IMAGE_EXTENSIONS)),
|
|
52
52
|
media: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset("media", import_shared.MEDIA_EXTENSIONS)),
|
|
53
|
-
assetsRetry: () => Promise.resolve().then(() => __toESM(require("./assetsRetry"))).then((m) => m.pluginAssetsRetry()),
|
|
54
53
|
rem: () => Promise.resolve().then(() => __toESM(require("./rem"))).then((m) => m.pluginRem()),
|
|
55
54
|
wasm: () => Promise.resolve().then(() => __toESM(require("./wasm"))).then((m) => m.pluginWasm()),
|
|
56
55
|
moment: () => Promise.resolve().then(() => __toESM(require("./moment"))).then((m) => m.pluginMoment()),
|
|
@@ -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,20 +15,13 @@ 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 nodeAddons_exports = {};
|
|
30
20
|
__export(nodeAddons_exports, {
|
|
31
21
|
pluginNodeAddons: () => pluginNodeAddons
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(nodeAddons_exports);
|
|
24
|
+
var import_path = require("path");
|
|
34
25
|
var import_shared = require("@rsbuild/shared");
|
|
35
26
|
const pluginNodeAddons = () => ({
|
|
36
27
|
name: "plugin-node-addons",
|
|
@@ -40,19 +31,21 @@ const pluginNodeAddons = () => ({
|
|
|
40
31
|
if (!isServer && !isServiceWorker) {
|
|
41
32
|
return;
|
|
42
33
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
const getDistName = (resourcePath) => {
|
|
35
|
+
const pkgJSON = (0, import_shared.findUpSync)({
|
|
36
|
+
filename: "package.json",
|
|
37
|
+
cwd: (0, import_path.dirname)(resourcePath)
|
|
38
|
+
});
|
|
46
39
|
if (!pkgJSON) {
|
|
47
40
|
throw new Error(
|
|
48
41
|
`Failed to compile Node.js addons, couldn't find the package.json of ${import_shared.color.yellow(
|
|
49
|
-
|
|
42
|
+
resourcePath
|
|
50
43
|
)}.`
|
|
51
44
|
);
|
|
52
45
|
}
|
|
53
|
-
const getFilename = (
|
|
46
|
+
const getFilename = (resource, pkgName2) => {
|
|
54
47
|
const reg = new RegExp(`node_modules/${pkgName2}/(.+)`);
|
|
55
|
-
const match =
|
|
48
|
+
const match = resource.match(reg);
|
|
56
49
|
const filename = match == null ? void 0 : match[1];
|
|
57
50
|
if (!filename) {
|
|
58
51
|
return "[name].[ext]";
|
|
@@ -62,7 +55,7 @@ const pluginNodeAddons = () => ({
|
|
|
62
55
|
const { name: pkgName } = require(pkgJSON);
|
|
63
56
|
const config = api.getNormalizedConfig();
|
|
64
57
|
const serverPath = (0, import_shared.getDistPath)(config.output, "server");
|
|
65
|
-
return `${serverPath}/${getFilename(
|
|
58
|
+
return `${serverPath}/${getFilename(resourcePath, pkgName)}`;
|
|
66
59
|
};
|
|
67
60
|
chain.module.rule(CHAIN_ID.RULE.NODE).test(/\.node$/).use(CHAIN_ID.USE.NODE).loader((0, import_shared.getSharedPkgCompiledPath)("node-loader")).options({
|
|
68
61
|
name: getDistName
|
package/dist/plugins/startUrl.js
CHANGED
|
@@ -36,6 +36,8 @@ module.exports = __toCommonJS(startUrl_exports);
|
|
|
36
36
|
var import_path = require("path");
|
|
37
37
|
var import_shared = require("@rsbuild/shared");
|
|
38
38
|
var import_child_process = require("child_process");
|
|
39
|
+
var import_util = require("util");
|
|
40
|
+
const execAsync = (0, import_util.promisify)(import_child_process.exec);
|
|
39
41
|
const supportedChromiumBrowsers = [
|
|
40
42
|
"Google Chrome Canary",
|
|
41
43
|
"Google Chrome Dev",
|
|
@@ -46,10 +48,10 @@ const supportedChromiumBrowsers = [
|
|
|
46
48
|
"Vivaldi",
|
|
47
49
|
"Chromium"
|
|
48
50
|
];
|
|
49
|
-
const getTargetBrowser = () => {
|
|
51
|
+
const getTargetBrowser = async () => {
|
|
50
52
|
let targetBrowser = process.env.BROWSER;
|
|
51
53
|
if (!targetBrowser || !supportedChromiumBrowsers.includes(targetBrowser)) {
|
|
52
|
-
const ps =
|
|
54
|
+
const { stdout: ps } = await execAsync("ps cax");
|
|
53
55
|
targetBrowser = supportedChromiumBrowsers.find((b) => ps.includes(b));
|
|
54
56
|
}
|
|
55
57
|
return targetBrowser;
|
|
@@ -58,14 +60,13 @@ async function openBrowser(url) {
|
|
|
58
60
|
const shouldTryOpenChromeWithAppleScript = process.platform === "darwin";
|
|
59
61
|
if (shouldTryOpenChromeWithAppleScript) {
|
|
60
62
|
try {
|
|
61
|
-
const targetBrowser = getTargetBrowser();
|
|
63
|
+
const targetBrowser = await getTargetBrowser();
|
|
62
64
|
if (targetBrowser) {
|
|
63
|
-
|
|
65
|
+
await execAsync(
|
|
64
66
|
`osascript openChrome.applescript "${encodeURI(
|
|
65
67
|
url
|
|
66
68
|
)}" "${targetBrowser}"`,
|
|
67
69
|
{
|
|
68
|
-
stdio: "ignore",
|
|
69
70
|
cwd: (0, import_path.join)(__dirname, "../../static")
|
|
70
71
|
}
|
|
71
72
|
);
|
|
@@ -94,22 +95,17 @@ function pluginStartUrl() {
|
|
|
94
95
|
return {
|
|
95
96
|
name: "plugin-start-url",
|
|
96
97
|
setup(api) {
|
|
97
|
-
let port;
|
|
98
98
|
api.onAfterStartDevServer(async (params) => {
|
|
99
|
-
|
|
100
|
-
});
|
|
101
|
-
api.onDevCompileDone(async ({ isFirstCompile }) => {
|
|
102
|
-
if (!isFirstCompile || !port) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
99
|
+
const { port } = params;
|
|
105
100
|
const config = api.getNormalizedConfig();
|
|
106
101
|
const { startUrl, beforeStartUrl } = config.dev;
|
|
107
|
-
const { https } = api.context.devServer || {};
|
|
108
|
-
|
|
102
|
+
const { open, https } = api.context.devServer || {};
|
|
103
|
+
const shouldOpen = Boolean(startUrl) || open;
|
|
104
|
+
if (!shouldOpen) {
|
|
109
105
|
return;
|
|
110
106
|
}
|
|
111
107
|
const urls = [];
|
|
112
|
-
if (startUrl === true) {
|
|
108
|
+
if (startUrl === true || !startUrl) {
|
|
113
109
|
const protocol = https ? "https" : "http";
|
|
114
110
|
urls.push(`${protocol}://localhost:${port}`);
|
|
115
111
|
} else {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type RspackConfig } from '@rsbuild/shared';
|
|
2
|
+
import { type RspackCompiler, type RspackMultiCompiler } from '@rsbuild/shared';
|
|
3
|
+
import { type InitConfigsOptions } from './initConfigs';
|
|
2
4
|
import type { Context } from '../types';
|
|
3
5
|
export declare function createCompiler({
|
|
4
6
|
context,
|
|
@@ -6,4 +8,5 @@ export declare function createCompiler({
|
|
|
6
8
|
}: {
|
|
7
9
|
context: Context;
|
|
8
10
|
rspackConfigs: RspackConfig[];
|
|
9
|
-
}): Promise<import("@rspack/core").MultiCompiler>;
|
|
11
|
+
}): Promise<import("@rspack/core").MultiCompiler>;
|
|
12
|
+
export declare function startDevCompile(options: InitConfigsOptions, customCompiler?: RspackCompiler | RspackMultiCompiler): Promise<import("@rsbuild/shared").DevMiddleware>;
|
|
@@ -28,10 +28,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var createCompiler_exports = {};
|
|
30
30
|
__export(createCompiler_exports, {
|
|
31
|
-
createCompiler: () => createCompiler
|
|
31
|
+
createCompiler: () => createCompiler,
|
|
32
|
+
startDevCompile: () => startDevCompile
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(createCompiler_exports);
|
|
34
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
|
+
var import_devMiddleware = require("./devMiddleware");
|
|
37
|
+
var import_initConfigs = require("./initConfigs");
|
|
35
38
|
async function createCompiler({
|
|
36
39
|
context,
|
|
37
40
|
rspackConfigs
|
|
@@ -43,16 +46,18 @@ async function createCompiler({
|
|
|
43
46
|
const { rspack } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
44
47
|
const compiler = rspack(rspackConfigs);
|
|
45
48
|
let isFirstCompile = true;
|
|
46
|
-
compiler.hooks.
|
|
47
|
-
|
|
49
|
+
compiler.hooks.watchRun.tap("rsbuild:compiling", () => {
|
|
50
|
+
import_shared.logger.start("Compiling...");
|
|
51
|
+
});
|
|
52
|
+
compiler.hooks.done.tap("rsbuild:done", async (stats) => {
|
|
48
53
|
const obj = stats.toJson({
|
|
49
54
|
all: false,
|
|
50
55
|
timings: true
|
|
51
56
|
});
|
|
52
|
-
if (!stats.hasErrors()) {
|
|
53
|
-
|
|
57
|
+
if (!stats.hasErrors() && obj.children) {
|
|
58
|
+
obj.children.forEach((c, index) => {
|
|
54
59
|
if (c.time) {
|
|
55
|
-
const time = (0, import_shared.prettyTime)(
|
|
60
|
+
const time = (0, import_shared.prettyTime)(c.time / 1e3);
|
|
56
61
|
const target = Array.isArray(context.target) ? context.target[index] : context.target;
|
|
57
62
|
const name = import_shared.TARGET_ID_MAP[target || "web"];
|
|
58
63
|
import_shared.logger.ready(`${name} compiled in ${time}`);
|
|
@@ -77,7 +82,21 @@ async function createCompiler({
|
|
|
77
82
|
(0, import_shared.debug)("create compiler done");
|
|
78
83
|
return compiler;
|
|
79
84
|
}
|
|
85
|
+
async function startDevCompile(options, customCompiler) {
|
|
86
|
+
let compiler;
|
|
87
|
+
if (customCompiler) {
|
|
88
|
+
compiler = customCompiler;
|
|
89
|
+
} else {
|
|
90
|
+
const { rspackConfigs } = await (0, import_initConfigs.initConfigs)(options);
|
|
91
|
+
compiler = await createCompiler({
|
|
92
|
+
context: options.context,
|
|
93
|
+
rspackConfigs
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return (0, import_devMiddleware.getDevMiddleware)(compiler);
|
|
97
|
+
}
|
|
80
98
|
// Annotate the CommonJS export names for ESM import in node:
|
|
81
99
|
0 && (module.exports = {
|
|
82
|
-
createCompiler
|
|
100
|
+
createCompiler,
|
|
101
|
+
startDevCompile
|
|
83
102
|
});
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DevMiddleware } from '@rsbuild/shared';
|
|
2
2
|
import type { Compiler, MultiCompiler } from '@rspack/core';
|
|
3
|
-
|
|
4
|
-
export declare const getDevMiddleware: (multiCompiler: Compiler | MultiCompiler) => NonNullable<DevMiddlewareOptions>;
|
|
5
|
-
export {};
|
|
3
|
+
export declare const getDevMiddleware: (multiCompiler: Compiler | MultiCompiler) => NonNullable<DevMiddleware>;
|
|
@@ -36,8 +36,12 @@ const pluginProgress = () => ({
|
|
|
36
36
|
name: "plugin-progress",
|
|
37
37
|
setup(api) {
|
|
38
38
|
api.modifyBundlerChain(async (chain, { target, CHAIN_ID }) => {
|
|
39
|
+
var _a;
|
|
39
40
|
const config = api.getNormalizedConfig();
|
|
40
|
-
const options = config.dev.progressBar
|
|
41
|
+
const options = (_a = config.dev.progressBar) != null ? _a : (
|
|
42
|
+
// enable progress bar in production by default
|
|
43
|
+
(0, import_shared.isProd)()
|
|
44
|
+
);
|
|
41
45
|
if (!options) {
|
|
42
46
|
return;
|
|
43
47
|
}
|
|
@@ -44,11 +44,10 @@ async function getDefaultSwcConfig(config, rootPath, target) {
|
|
|
44
44
|
tsx: true,
|
|
45
45
|
syntax: "typescript",
|
|
46
46
|
decorators: true
|
|
47
|
-
}
|
|
48
|
-
// TODO: Enabling it will cause performance degradation
|
|
47
|
+
},
|
|
49
48
|
// Avoid the webpack magic comment to be removed
|
|
50
49
|
// https://github.com/swc-project/swc/issues/6403
|
|
51
|
-
|
|
50
|
+
preserveAllComments: true
|
|
52
51
|
},
|
|
53
52
|
isModule: "unknown",
|
|
54
53
|
minify: false,
|
|
@@ -37,6 +37,7 @@ var import_initConfigs = require("./core/initConfigs");
|
|
|
37
37
|
var import_initPlugins = require("./core/initPlugins");
|
|
38
38
|
var import_plugin = require("./shared/plugin");
|
|
39
39
|
var import_rspackVersion = require("./shared/rspackVersion");
|
|
40
|
+
var import_server = require("../server");
|
|
40
41
|
function rspackProvider({
|
|
41
42
|
rsbuildConfig: originalRsbuildConfig
|
|
42
43
|
}) {
|
|
@@ -72,14 +73,15 @@ function rspackProvider({
|
|
|
72
73
|
});
|
|
73
74
|
},
|
|
74
75
|
async startDevServer(options) {
|
|
75
|
-
const {
|
|
76
|
-
return startDevServer(
|
|
76
|
+
const { startDevCompile } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
|
|
77
|
+
return (0, import_server.startDevServer)(
|
|
77
78
|
{ context, pluginStore, rsbuildOptions },
|
|
79
|
+
startDevCompile,
|
|
78
80
|
options
|
|
79
81
|
);
|
|
80
82
|
},
|
|
81
83
|
async preview() {
|
|
82
|
-
return (0,
|
|
84
|
+
return (0, import_server.startProdServer)(context, context.config);
|
|
83
85
|
},
|
|
84
86
|
async build(options) {
|
|
85
87
|
const { build: buildImpl, rspackBuild } = await Promise.resolve().then(() => __toESM(require("./core/build")));
|
|
@@ -68,7 +68,6 @@ const applyDefaultPlugins = (plugins) => (0, import_shared.awaitableGetter)([
|
|
|
68
68
|
plugins.startUrl(),
|
|
69
69
|
plugins.inlineChunk(),
|
|
70
70
|
plugins.bundleAnalyzer(),
|
|
71
|
-
plugins.assetsRetry(),
|
|
72
71
|
plugins.networkPerformance(),
|
|
73
72
|
plugins.preloadOrPrefetch(),
|
|
74
73
|
plugins.performance(),
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
HMR_SOCK_PATH: () => HMR_SOCK_PATH,
|
|
22
|
+
getDefaultDevOptions: () => getDefaultDevOptions
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(constants_exports);
|
|
25
|
+
const HMR_SOCK_PATH = "/webpack-hmr";
|
|
26
|
+
const getDefaultDevOptions = () => {
|
|
27
|
+
return {
|
|
28
|
+
client: {
|
|
29
|
+
path: HMR_SOCK_PATH,
|
|
30
|
+
// By default it is set to the port number of the dev server
|
|
31
|
+
port: "",
|
|
32
|
+
// By default it is set to "location.hostname"
|
|
33
|
+
host: "",
|
|
34
|
+
// By default it is set to "location.protocol === 'https:' ? 'wss' : 'ws'""
|
|
35
|
+
protocol: ""
|
|
36
|
+
},
|
|
37
|
+
https: false,
|
|
38
|
+
devMiddleware: { writeToDisk: true },
|
|
39
|
+
watch: true,
|
|
40
|
+
hot: true,
|
|
41
|
+
compress: true,
|
|
42
|
+
liveReload: true
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
HMR_SOCK_PATH,
|
|
48
|
+
getDefaultDevOptions
|
|
49
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hmr socket connect path
|
|
3
|
+
*/
|
|
4
|
+
export declare const HMR_SOCK_PATH = "/webpack-hmr";
|
|
5
|
+
export declare function createSocketUrl(resourceQuery: string): string;
|
|
6
|
+
export declare function formatURL({
|
|
7
|
+
port,
|
|
8
|
+
protocol,
|
|
9
|
+
hostname,
|
|
10
|
+
pathname
|
|
11
|
+
}: {
|
|
12
|
+
port: string;
|
|
13
|
+
protocol: string;
|
|
14
|
+
hostname: string;
|
|
15
|
+
pathname: string;
|
|
16
|
+
}): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var createSocketUrl_exports = {};
|
|
20
|
+
__export(createSocketUrl_exports, {
|
|
21
|
+
HMR_SOCK_PATH: () => HMR_SOCK_PATH,
|
|
22
|
+
createSocketUrl: () => createSocketUrl,
|
|
23
|
+
formatURL: () => formatURL
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(createSocketUrl_exports);
|
|
26
|
+
const HMR_SOCK_PATH = "/webpack-hmr";
|
|
27
|
+
function createSocketUrl(resourceQuery) {
|
|
28
|
+
const searchParams = resourceQuery.substr(1).split("&");
|
|
29
|
+
const options = {};
|
|
30
|
+
for (const pair of searchParams) {
|
|
31
|
+
const ary = pair.split("=");
|
|
32
|
+
options[ary[0]] = decodeURIComponent(ary[1]);
|
|
33
|
+
}
|
|
34
|
+
const currentLocation = self.location;
|
|
35
|
+
return getSocketUrl(options, currentLocation);
|
|
36
|
+
}
|
|
37
|
+
function formatURL({
|
|
38
|
+
port,
|
|
39
|
+
protocol,
|
|
40
|
+
hostname,
|
|
41
|
+
pathname
|
|
42
|
+
}) {
|
|
43
|
+
if (window.URL) {
|
|
44
|
+
const url = new URL("http://localhost");
|
|
45
|
+
url.port = port;
|
|
46
|
+
url.hostname = hostname;
|
|
47
|
+
url.protocol = protocol;
|
|
48
|
+
url.pathname = pathname;
|
|
49
|
+
return url.toString();
|
|
50
|
+
}
|
|
51
|
+
const colon = protocol.indexOf(":") === -1 ? ":" : "";
|
|
52
|
+
return `${protocol}${colon}//${hostname}:${port}${pathname}`;
|
|
53
|
+
}
|
|
54
|
+
function getSocketUrl(urlParts, location) {
|
|
55
|
+
const { host, port, path, protocol } = urlParts;
|
|
56
|
+
return formatURL({
|
|
57
|
+
protocol: protocol || (location.protocol === "https:" ? "wss" : "ws"),
|
|
58
|
+
hostname: host || location.hostname,
|
|
59
|
+
port: port || location.port,
|
|
60
|
+
pathname: path || HMR_SOCK_PATH
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
HMR_SOCK_PATH,
|
|
66
|
+
createSocketUrl,
|
|
67
|
+
formatURL
|
|
68
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|