@rsbuild/core 0.0.21 → 0.0.22
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/connect-history-api-fallback/index.d.ts +1 -0
- package/compiled/connect-history-api-fallback/index.js +1 -0
- package/compiled/connect-history-api-fallback/license +21 -0
- package/compiled/connect-history-api-fallback/package.json +1 -0
- package/compiled/open/index.d.ts +153 -0
- package/compiled/open/index.js +1 -0
- package/compiled/open/license +9 -0
- package/compiled/open/package.json +1 -0
- package/compiled/open/xdg-open +1066 -0
- package/dist/client/hmr.js +418 -0
- package/dist/index.d.ts +1 -1
- package/dist/plugins/index.js +0 -1
- package/dist/plugins/startUrl.js +1 -1
- package/dist/rspack-provider/core/createCompiler.d.ts +1 -1
- package/dist/rspack-provider/core/createCompiler.js +3 -3
- package/dist/rspack-provider/plugins/css.js +3 -10
- package/dist/rspack-provider/plugins/swc.js +1 -1
- package/dist/rspack-provider/provider.js +2 -2
- package/dist/rspack-provider/shared/plugin.js +1 -4
- package/dist/server/dev-middleware/index.d.ts +1 -0
- package/dist/server/dev-middleware/index.js +5 -4
- package/dist/server/devServer.d.ts +2 -2
- package/dist/server/devServer.js +14 -15
- package/dist/server/prodServer.d.ts +1 -1
- package/dist/server/prodServer.js +2 -2
- package/package.json +7 -11
- package/dist/plugins/rem.d.ts +0 -2
- package/dist/plugins/rem.js +0 -103
- package/dist/rspack-provider/plugins/fallback.d.ts +0 -2
- package/dist/rspack-provider/plugins/fallback.js +0 -52
- package/dist/server/dev-middleware/hmr-client/createSocketUrl.js +0 -68
- package/dist/server/dev-middleware/hmr-client/index.js +0 -141
- /package/dist/{server/dev-middleware/hmr-client → client/hmr}/createSocketUrl.d.ts +0 -0
- /package/dist/{server/dev-middleware/hmr-client → client/hmr}/index.d.ts +0 -0
package/dist/server/devServer.js
CHANGED
|
@@ -37,7 +37,7 @@ var import_https = require("https");
|
|
|
37
37
|
var import_url = __toESM(require("url"));
|
|
38
38
|
var import_shared = require("@rsbuild/shared");
|
|
39
39
|
var import_dev_middleware = __toESM(require("./dev-middleware"));
|
|
40
|
-
var import_connect = __toESM(require("connect"));
|
|
40
|
+
var import_connect = __toESM(require("@rsbuild/shared/connect"));
|
|
41
41
|
var import_proxy = require("./proxy");
|
|
42
42
|
var import_middlewares = require("./middlewares");
|
|
43
43
|
var import_path = require("path");
|
|
@@ -121,9 +121,8 @@ class RsbuildDevServer {
|
|
|
121
121
|
})
|
|
122
122
|
);
|
|
123
123
|
if (dev.historyApiFallback) {
|
|
124
|
-
const { default: connectHistoryApiFallback } = await Promise.resolve().then(() => __toESM(require("connect-history-api-fallback")));
|
|
124
|
+
const { default: connectHistoryApiFallback } = await Promise.resolve().then(() => __toESM(require("../../compiled/connect-history-api-fallback")));
|
|
125
125
|
const historyApiFallbackMiddleware = connectHistoryApiFallback(
|
|
126
|
-
// @ts-expect-error
|
|
127
126
|
typeof dev.historyApiFallback === "boolean" ? {} : dev.historyApiFallback
|
|
128
127
|
);
|
|
129
128
|
this.middlewares.use(historyApiFallbackMiddleware);
|
|
@@ -157,7 +156,7 @@ class RsbuildDevServer {
|
|
|
157
156
|
this.app.close();
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
|
-
async function startDevServer(options,
|
|
159
|
+
async function startDevServer(options, createDevMiddleware, {
|
|
161
160
|
open,
|
|
162
161
|
compiler,
|
|
163
162
|
printURLs = true,
|
|
@@ -188,17 +187,8 @@ async function startDevServer(options, startDevCompile, {
|
|
|
188
187
|
options.context.entry,
|
|
189
188
|
(_c = (_b = rsbuildConfig.output) == null ? void 0 : _b.distPath) == null ? void 0 : _c.html
|
|
190
189
|
);
|
|
191
|
-
if (printURLs) {
|
|
192
|
-
if ((0, import_shared.isFunction)(printURLs)) {
|
|
193
|
-
urls = printURLs(urls);
|
|
194
|
-
if (!Array.isArray(urls)) {
|
|
195
|
-
throw new Error("Please return an array in the `printURLs` function.");
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
(0, import_shared.printServerURLs)(urls, routes, logger);
|
|
199
|
-
}
|
|
200
190
|
(0, import_shared.debug)("create dev server");
|
|
201
|
-
const devMiddleware = await
|
|
191
|
+
const devMiddleware = await createDevMiddleware(options, compiler);
|
|
202
192
|
const server = new RsbuildDevServer({
|
|
203
193
|
pwd: options.context.rootPath,
|
|
204
194
|
devMiddleware,
|
|
@@ -211,6 +201,15 @@ async function startDevServer(options, startDevCompile, {
|
|
|
211
201
|
(0, import_shared.debug)("create dev server done");
|
|
212
202
|
await options.context.hooks.onBeforeStartDevServerHook.call();
|
|
213
203
|
const httpServer = await server.createHTTPServer();
|
|
204
|
+
if (printURLs) {
|
|
205
|
+
if ((0, import_shared.isFunction)(printURLs)) {
|
|
206
|
+
urls = printURLs(urls);
|
|
207
|
+
if (!Array.isArray(urls)) {
|
|
208
|
+
throw new Error("Please return an array in the `printURLs` function.");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
(0, import_shared.printServerURLs)(urls, routes, logger);
|
|
212
|
+
}
|
|
214
213
|
await server.onInit(httpServer);
|
|
215
214
|
(0, import_shared.debug)("listen dev server");
|
|
216
215
|
return new Promise((resolve) => {
|
|
@@ -233,7 +232,7 @@ async function startDevServer(options, startDevCompile, {
|
|
|
233
232
|
port,
|
|
234
233
|
urls: urls.map((item) => item.url),
|
|
235
234
|
server: {
|
|
236
|
-
close: () => {
|
|
235
|
+
close: async () => {
|
|
237
236
|
server.close();
|
|
238
237
|
}
|
|
239
238
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { ListenOptions } from 'net';
|
|
4
4
|
import { Server } from 'http';
|
|
5
|
-
import connect from 'connect';
|
|
5
|
+
import connect from '@rsbuild/shared/connect';
|
|
6
6
|
import { Context, RsbuildConfig, StartServerResult, PreviewServerOptions } from '@rsbuild/shared';
|
|
7
7
|
type RsbuildProdServerOptions = {
|
|
8
8
|
pwd: string;
|
|
@@ -33,7 +33,7 @@ __export(prodServer_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(prodServer_exports);
|
|
35
35
|
var import_http = require("http");
|
|
36
|
-
var import_connect = __toESM(require("connect"));
|
|
36
|
+
var import_connect = __toESM(require("@rsbuild/shared/connect"));
|
|
37
37
|
var import_path = require("path");
|
|
38
38
|
var import_sirv = __toESM(require("sirv"));
|
|
39
39
|
var import_shared = require("@rsbuild/shared");
|
|
@@ -130,7 +130,7 @@ async function startProdServer(context, rsbuildConfig, { printURLs = true } = {}
|
|
|
130
130
|
port,
|
|
131
131
|
urls: urls.map((item) => item.url),
|
|
132
132
|
server: {
|
|
133
|
-
close: () => {
|
|
133
|
+
close: async () => {
|
|
134
134
|
server.close();
|
|
135
135
|
}
|
|
136
136
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "Unleash the power of Rspack with the out-of-the-box build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"types": "./dist/server/index.d.ts",
|
|
22
22
|
"default": "./dist/server/index.js"
|
|
23
23
|
},
|
|
24
|
-
"./
|
|
25
|
-
"types": "./dist/
|
|
26
|
-
"default": "./dist/
|
|
24
|
+
"./client/*": {
|
|
25
|
+
"types": "./dist/client/*.d.ts",
|
|
26
|
+
"default": "./dist/client/*.js"
|
|
27
27
|
},
|
|
28
28
|
"./cli": {
|
|
29
29
|
"types": "./dist/cli/index.d.ts",
|
|
@@ -54,12 +54,11 @@
|
|
|
54
54
|
"bin",
|
|
55
55
|
"dist",
|
|
56
56
|
"static",
|
|
57
|
+
"compiled",
|
|
57
58
|
"types.d.ts"
|
|
58
59
|
],
|
|
59
60
|
"dependencies": {
|
|
60
|
-
"@rspack/core": "0.3.
|
|
61
|
-
"connect": "3.7.0",
|
|
62
|
-
"connect-history-api-fallback": "^2.0.0",
|
|
61
|
+
"@rspack/core": "0.3.12",
|
|
63
62
|
"commander": "^10.0.1",
|
|
64
63
|
"core-js": "~3.32.2",
|
|
65
64
|
"gzip-size": "^6.0.0",
|
|
@@ -67,17 +66,14 @@
|
|
|
67
66
|
"http-compression": "1.0.6",
|
|
68
67
|
"http-proxy-middleware": "^2.0.1",
|
|
69
68
|
"jiti": "^1.20.0",
|
|
70
|
-
"open": "^8.4.0",
|
|
71
69
|
"postcss": "8.4.31",
|
|
72
70
|
"rslog": "^1.1.0",
|
|
73
71
|
"semver": "^7.5.4",
|
|
74
72
|
"sirv": "^2.0.3",
|
|
75
73
|
"ws": "^8.2.0",
|
|
76
|
-
"@rsbuild/shared": "0.0.
|
|
74
|
+
"@rsbuild/shared": "0.0.22"
|
|
77
75
|
},
|
|
78
76
|
"devDependencies": {
|
|
79
|
-
"@types/connect": "3.4.35",
|
|
80
|
-
"@types/connect-history-api-fallback": "^1.3.5",
|
|
81
77
|
"@types/node": "^16",
|
|
82
78
|
"@types/ws": "^8.2.0",
|
|
83
79
|
"@types/semver": "^7.5.4",
|
package/dist/plugins/rem.d.ts
DELETED
package/dist/plugins/rem.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var rem_exports = {};
|
|
30
|
-
__export(rem_exports, {
|
|
31
|
-
pluginRem: () => pluginRem
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(rem_exports);
|
|
34
|
-
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
var import_shared2 = require("@rsbuild/shared");
|
|
36
|
-
const defaultOptions = {
|
|
37
|
-
enableRuntime: true,
|
|
38
|
-
rootFontSize: 50
|
|
39
|
-
};
|
|
40
|
-
const pluginRem = () => ({
|
|
41
|
-
name: "plugin-rem",
|
|
42
|
-
pre: ["plugin-css", "plugin-less", "plugin-sass", "plugin-stylus"],
|
|
43
|
-
setup(api) {
|
|
44
|
-
api.modifyBundlerChain(
|
|
45
|
-
async (chain, { CHAIN_ID, isServer, isWebWorker, HtmlPlugin }) => {
|
|
46
|
-
const config = api.getNormalizedConfig();
|
|
47
|
-
const {
|
|
48
|
-
output: { convertToRem }
|
|
49
|
-
} = config;
|
|
50
|
-
if (!convertToRem || isServer || isWebWorker) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const userOptions = {
|
|
54
|
-
...defaultOptions,
|
|
55
|
-
...typeof convertToRem === "boolean" ? {} : convertToRem
|
|
56
|
-
};
|
|
57
|
-
const { default: PxToRemPlugin } = await Promise.resolve().then(() => __toESM(require((0, import_shared.getSharedPkgCompiledPath)("postcss-pxtorem"))));
|
|
58
|
-
const applyRules = [
|
|
59
|
-
CHAIN_ID.RULE.CSS,
|
|
60
|
-
CHAIN_ID.RULE.LESS,
|
|
61
|
-
CHAIN_ID.RULE.SASS,
|
|
62
|
-
CHAIN_ID.RULE.STYLUS
|
|
63
|
-
];
|
|
64
|
-
const getPxToRemPlugin = () => PxToRemPlugin({
|
|
65
|
-
rootValue: userOptions.rootFontSize,
|
|
66
|
-
unitPrecision: 5,
|
|
67
|
-
propList: ["*"],
|
|
68
|
-
...userOptions.pxtorem ? (0, import_shared2.cloneDeep)(userOptions.pxtorem) : {}
|
|
69
|
-
});
|
|
70
|
-
applyRules.forEach((name) => {
|
|
71
|
-
chain.module.rules.has(name) && chain.module.rule(name).use(CHAIN_ID.USE.POSTCSS).tap((options = {}) => {
|
|
72
|
-
var _a;
|
|
73
|
-
return {
|
|
74
|
-
...options,
|
|
75
|
-
postcssOptions: {
|
|
76
|
-
...options.postcssOptions || {},
|
|
77
|
-
plugins: [
|
|
78
|
-
...((_a = options.postcssOptions) == null ? void 0 : _a.plugins) || [],
|
|
79
|
-
getPxToRemPlugin()
|
|
80
|
-
]
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
if (!userOptions.enableRuntime) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const entries = Object.keys(chain.entryPoints.entries() || {});
|
|
89
|
-
const distDir = (0, import_shared.getDistPath)(config.output, "js");
|
|
90
|
-
chain.plugin(CHAIN_ID.PLUGIN.AUTO_SET_ROOT_SIZE).use(import_shared.AutoSetRootFontSizePlugin, [
|
|
91
|
-
userOptions,
|
|
92
|
-
entries,
|
|
93
|
-
HtmlPlugin,
|
|
94
|
-
distDir
|
|
95
|
-
]);
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
101
|
-
0 && (module.exports = {
|
|
102
|
-
pluginRem
|
|
103
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
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 fallback_exports = {};
|
|
20
|
-
__export(fallback_exports, {
|
|
21
|
-
pluginFallback: () => pluginFallback
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(fallback_exports);
|
|
24
|
-
var import_path = require("path");
|
|
25
|
-
var import_shared = require("@rsbuild/shared");
|
|
26
|
-
const pluginFallback = () => ({
|
|
27
|
-
name: "plugin-fallback",
|
|
28
|
-
setup(api) {
|
|
29
|
-
api.modifyRspackConfig((config, { isProd }) => {
|
|
30
|
-
var _a;
|
|
31
|
-
const rsbuildConfig = api.getNormalizedConfig();
|
|
32
|
-
if (!rsbuildConfig.output.enableAssetFallback) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const distDir = (0, import_shared.getDistPath)(rsbuildConfig.output, "media");
|
|
36
|
-
const filename = (0, import_shared.getFilename)(rsbuildConfig.output, "media", isProd);
|
|
37
|
-
(0, import_shared.setConfig)(config, "output.assetModuleFilename", (0, import_path.join)(distDir, filename));
|
|
38
|
-
if (!config.module) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
(0, import_shared.setConfig)(
|
|
42
|
-
config,
|
|
43
|
-
"module.rules",
|
|
44
|
-
(0, import_shared.resourceRuleFallback)((_a = config.module) == null ? void 0 : _a.rules)
|
|
45
|
-
);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
-
0 && (module.exports = {
|
|
51
|
-
pluginFallback
|
|
52
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
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 = "/rsbuild-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
|
-
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var import_format_stats = require("@rsbuild/shared/format-stats");
|
|
3
|
-
var import_createSocketUrl = require("./createSocketUrl");
|
|
4
|
-
const hadRuntimeError = false;
|
|
5
|
-
const socketUrl = (0, import_createSocketUrl.createSocketUrl)(__resourceQuery);
|
|
6
|
-
const connection = new WebSocket(socketUrl);
|
|
7
|
-
connection.onopen = function() {
|
|
8
|
-
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
9
|
-
console.info("[HMR] connected.");
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
connection.onclose = function() {
|
|
13
|
-
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
14
|
-
console.info("[HMR] disconnected. Refresh the page if necessary.");
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
let isFirstCompilation = true;
|
|
18
|
-
let mostRecentCompilationHash = null;
|
|
19
|
-
let hasCompileErrors = false;
|
|
20
|
-
function clearOutdatedErrors() {
|
|
21
|
-
if (typeof console !== "undefined" && typeof console.clear === "function") {
|
|
22
|
-
if (hasCompileErrors) {
|
|
23
|
-
console.clear();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function handleSuccess() {
|
|
28
|
-
clearOutdatedErrors();
|
|
29
|
-
const isHotUpdate = !isFirstCompilation;
|
|
30
|
-
isFirstCompilation = false;
|
|
31
|
-
hasCompileErrors = false;
|
|
32
|
-
if (isHotUpdate) {
|
|
33
|
-
tryApplyUpdates();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function handleWarnings(warnings) {
|
|
37
|
-
clearOutdatedErrors();
|
|
38
|
-
const isHotUpdate = !isFirstCompilation;
|
|
39
|
-
isFirstCompilation = false;
|
|
40
|
-
hasCompileErrors = false;
|
|
41
|
-
function printWarnings() {
|
|
42
|
-
const formatted = (0, import_format_stats.formatStatsMessages)({
|
|
43
|
-
warnings,
|
|
44
|
-
errors: []
|
|
45
|
-
});
|
|
46
|
-
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
47
|
-
for (let i = 0; i < formatted.warnings.length; i++) {
|
|
48
|
-
if (i === 5) {
|
|
49
|
-
console.warn(
|
|
50
|
-
"There were more warnings in other files.\nYou can find a complete log in the terminal."
|
|
51
|
-
);
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
console.warn(formatted.warnings[i]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
printWarnings();
|
|
59
|
-
if (isHotUpdate) {
|
|
60
|
-
tryApplyUpdates();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function handleErrors(errors) {
|
|
64
|
-
clearOutdatedErrors();
|
|
65
|
-
isFirstCompilation = false;
|
|
66
|
-
hasCompileErrors = true;
|
|
67
|
-
const formatted = (0, import_format_stats.formatStatsMessages)({
|
|
68
|
-
errors,
|
|
69
|
-
warnings: []
|
|
70
|
-
});
|
|
71
|
-
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
72
|
-
for (const error of formatted.errors) {
|
|
73
|
-
console.error(error);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function handleAvailableHash(hash) {
|
|
78
|
-
mostRecentCompilationHash = hash;
|
|
79
|
-
}
|
|
80
|
-
connection.onmessage = function(e) {
|
|
81
|
-
const message = JSON.parse(e.data);
|
|
82
|
-
switch (message.type) {
|
|
83
|
-
case "hash":
|
|
84
|
-
handleAvailableHash(message.data);
|
|
85
|
-
break;
|
|
86
|
-
case "still-ok":
|
|
87
|
-
case "ok":
|
|
88
|
-
handleSuccess();
|
|
89
|
-
break;
|
|
90
|
-
case "content-changed":
|
|
91
|
-
window.location.reload();
|
|
92
|
-
break;
|
|
93
|
-
case "warnings":
|
|
94
|
-
handleWarnings(message.data);
|
|
95
|
-
break;
|
|
96
|
-
case "errors":
|
|
97
|
-
handleErrors(message.data);
|
|
98
|
-
break;
|
|
99
|
-
default:
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
function isUpdateAvailable() {
|
|
103
|
-
return mostRecentCompilationHash !== __webpack_hash__;
|
|
104
|
-
}
|
|
105
|
-
function canApplyUpdates() {
|
|
106
|
-
return module.hot.status() === "idle";
|
|
107
|
-
}
|
|
108
|
-
function tryApplyUpdates() {
|
|
109
|
-
if (!module.hot) {
|
|
110
|
-
window.location.reload();
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (!isUpdateAvailable() || !canApplyUpdates()) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
function handleApplyUpdates(err, updatedModules) {
|
|
117
|
-
const wantsForcedReload = err || !updatedModules || hadRuntimeError;
|
|
118
|
-
if (wantsForcedReload) {
|
|
119
|
-
window.location.reload();
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (isUpdateAvailable()) {
|
|
123
|
-
tryApplyUpdates();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const result = module.hot.check(
|
|
127
|
-
/* autoApply */
|
|
128
|
-
true,
|
|
129
|
-
handleApplyUpdates
|
|
130
|
-
);
|
|
131
|
-
if (result == null ? void 0 : result.then) {
|
|
132
|
-
result.then(
|
|
133
|
-
(updatedModules) => {
|
|
134
|
-
handleApplyUpdates(null, updatedModules);
|
|
135
|
-
},
|
|
136
|
-
(err) => {
|
|
137
|
-
handleApplyUpdates(err, null);
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
File without changes
|
|
File without changes
|