@rsbuild/core 0.0.21 → 0.0.23
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 +1 -1
- package/compiled/commander/index.js +1 -0
- package/compiled/commander/license +22 -0
- package/compiled/commander/package.json +1 -0
- package/compiled/commander/typings/index.d.ts +889 -0
- 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/http-compression/index.d.ts +1 -0
- package/compiled/http-compression/index.js +1 -0
- package/compiled/http-compression/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/cli/commands.js +1 -1
- package/dist/cli/config.d.ts +2 -8
- package/dist/cli/config.js +0 -18
- package/dist/cli/run.d.ts +1 -1
- package/dist/cli/run.js +0 -2
- package/dist/client/hmr.js +418 -0
- package/dist/createRsbuild.js +0 -1
- package/dist/index.d.ts +2 -2
- package/dist/plugins/fileSize.js +2 -2
- package/dist/plugins/html.js +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/core/createContext.js +3 -2
- package/dist/rspack-provider/core/rspackConfig.js +1 -1
- package/dist/rspack-provider/index.d.ts +1 -1
- package/dist/rspack-provider/plugins/css.js +3 -10
- package/dist/rspack-provider/plugins/{rspack-profile.js → rspackProfile.js} +3 -3
- package/dist/rspack-provider/plugins/swc.js +1 -1
- package/dist/rspack-provider/provider.js +6 -5
- package/dist/rspack-provider/shared/plugin.js +1 -4
- package/dist/rspack-provider/types/plugin.d.ts +1 -1
- package/dist/server/dev-middleware/index.d.ts +2 -0
- package/dist/server/dev-middleware/index.js +10 -9
- package/dist/server/devServer.d.ts +2 -2
- package/dist/server/devServer.js +16 -16
- package/dist/server/prodServer.d.ts +1 -1
- package/dist/server/prodServer.js +2 -2
- package/package.json +7 -15
- 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/rspack-provider/plugins/{rspack-profile.d.ts → rspackProfile.d.ts} +0 -0
package/dist/cli/commands.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(commands_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(commands_exports);
|
|
24
24
|
var import_path = require("path");
|
|
25
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
|
-
var import_commander = require("commander");
|
|
26
|
+
var import_commander = require("../../compiled/commander");
|
|
27
27
|
function setupProgram(rsbuild) {
|
|
28
28
|
const pkgJson = (0, import_path.join)(__dirname, "../../package.json");
|
|
29
29
|
const { version } = import_shared.fse.readJSONSync(pkgJson);
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RsbuildPlugin, RsbuildConfig as BaseRsbuildConfig } from '@rsbuild/shared';
|
|
2
2
|
export type RsbuildConfig = BaseRsbuildConfig & {
|
|
3
|
-
source?: {
|
|
4
|
-
entries?: RsbuildEntry;
|
|
5
|
-
};
|
|
6
3
|
plugins?: RsbuildPlugin[];
|
|
7
4
|
/**
|
|
8
5
|
* @private only for testing
|
|
@@ -10,7 +7,4 @@ export type RsbuildConfig = BaseRsbuildConfig & {
|
|
|
10
7
|
provider?: any;
|
|
11
8
|
};
|
|
12
9
|
export declare const defineConfig: (config: RsbuildConfig) => RsbuildConfig;
|
|
13
|
-
export declare function loadConfig(): Promise<ReturnType<typeof defineConfig>>;
|
|
14
|
-
export declare function getDefaultEntries(): {
|
|
15
|
-
index: string;
|
|
16
|
-
};
|
|
10
|
+
export declare function loadConfig(): Promise<ReturnType<typeof defineConfig>>;
|
package/dist/cli/config.js
CHANGED
|
@@ -29,14 +29,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var config_exports = {};
|
|
30
30
|
__export(config_exports, {
|
|
31
31
|
defineConfig: () => defineConfig,
|
|
32
|
-
getDefaultEntries: () => getDefaultEntries,
|
|
33
32
|
loadConfig: () => loadConfig
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(config_exports);
|
|
36
35
|
var import_fs = __toESM(require("fs"));
|
|
37
36
|
var import_jiti = __toESM(require("jiti"));
|
|
38
37
|
var import_path = require("path");
|
|
39
|
-
var import_shared = require("@rsbuild/shared");
|
|
40
38
|
var import_restart = require("../server/restart");
|
|
41
39
|
const defineConfig = (config) => config;
|
|
42
40
|
const resolveConfigPath = () => {
|
|
@@ -84,24 +82,8 @@ async function loadConfig() {
|
|
|
84
82
|
}
|
|
85
83
|
return {};
|
|
86
84
|
}
|
|
87
|
-
function getDefaultEntries() {
|
|
88
|
-
const cwd = process.cwd();
|
|
89
|
-
const files = ["ts", "tsx", "js", "jsx"].map(
|
|
90
|
-
(ext) => (0, import_path.join)(cwd, `src/index.${ext}`)
|
|
91
|
-
);
|
|
92
|
-
const entryFile = (0, import_shared.findExists)(files);
|
|
93
|
-
if (entryFile) {
|
|
94
|
-
return {
|
|
95
|
-
index: entryFile
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
throw new Error(
|
|
99
|
-
"Could not find the entry file, please make sure that `src/index.(js|ts|tsx|jsx)` exists, or customize entry through the `source.entries` configuration."
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
103
86
|
0 && (module.exports = {
|
|
104
87
|
defineConfig,
|
|
105
|
-
getDefaultEntries,
|
|
106
88
|
loadConfig
|
|
107
89
|
});
|
package/dist/cli/run.d.ts
CHANGED
package/dist/cli/run.js
CHANGED
|
@@ -25,11 +25,9 @@ var import__ = require("..");
|
|
|
25
25
|
var import_commands = require("./commands");
|
|
26
26
|
var import_config = require("./config");
|
|
27
27
|
async function runCli(options = {}) {
|
|
28
|
-
var _a;
|
|
29
28
|
const config = await (0, import_config.loadConfig)();
|
|
30
29
|
const rsbuild = await (0, import__.createRsbuild)({
|
|
31
30
|
rsbuildConfig: config,
|
|
32
|
-
entry: ((_a = config.source) == null ? void 0 : _a.entries) || (0, import_config.getDefaultEntries)(),
|
|
33
31
|
provider: config.provider
|
|
34
32
|
});
|
|
35
33
|
if (options.defaultPlugins) {
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _iterable_to_array_limit(arr, i) {
|
|
11
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
12
|
+
if (_i == null) return;
|
|
13
|
+
var _arr = [];
|
|
14
|
+
var _n = true;
|
|
15
|
+
var _d = false;
|
|
16
|
+
var _s, _e;
|
|
17
|
+
try {
|
|
18
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
19
|
+
_arr.push(_s.value);
|
|
20
|
+
if (i && _arr.length === i) break;
|
|
21
|
+
}
|
|
22
|
+
} catch (err) {
|
|
23
|
+
_d = true;
|
|
24
|
+
_e = err;
|
|
25
|
+
} finally{
|
|
26
|
+
try {
|
|
27
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
28
|
+
} finally{
|
|
29
|
+
if (_d) throw _e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return _arr;
|
|
33
|
+
}
|
|
34
|
+
function _non_iterable_rest() {
|
|
35
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
36
|
+
}
|
|
37
|
+
function _sliced_to_array(arr, i) {
|
|
38
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
39
|
+
}
|
|
40
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
41
|
+
if (!o) return;
|
|
42
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
43
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
44
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
45
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
46
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
47
|
+
}
|
|
48
|
+
var createSocketUrl = function createSocketUrl(resourceQuery) {
|
|
49
|
+
var searchParams = resourceQuery.substr(1).split("&");
|
|
50
|
+
var options = {};
|
|
51
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
52
|
+
try {
|
|
53
|
+
for(var _iterator = searchParams[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
54
|
+
var pair = _step.value;
|
|
55
|
+
var ary = pair.split("=");
|
|
56
|
+
options[ary[0]] = decodeURIComponent(ary[1]);
|
|
57
|
+
}
|
|
58
|
+
} catch (err) {
|
|
59
|
+
_didIteratorError = true;
|
|
60
|
+
_iteratorError = err;
|
|
61
|
+
} finally{
|
|
62
|
+
try {
|
|
63
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
64
|
+
_iterator.return();
|
|
65
|
+
}
|
|
66
|
+
} finally{
|
|
67
|
+
if (_didIteratorError) {
|
|
68
|
+
throw _iteratorError;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
var currentLocation = self.location;
|
|
73
|
+
return getSocketUrl(options, currentLocation);
|
|
74
|
+
};
|
|
75
|
+
var formatURL = function formatURL(param) {
|
|
76
|
+
var port = param.port, protocol = param.protocol, hostname = param.hostname, pathname = param.pathname;
|
|
77
|
+
if (window.URL) {
|
|
78
|
+
var url = new URL("http://localhost");
|
|
79
|
+
url.port = port;
|
|
80
|
+
url.hostname = hostname;
|
|
81
|
+
url.protocol = protocol;
|
|
82
|
+
url.pathname = pathname;
|
|
83
|
+
return url.toString();
|
|
84
|
+
}
|
|
85
|
+
var colon = protocol.indexOf(":") === -1 ? ":" : "";
|
|
86
|
+
return "".concat(protocol).concat(colon, "//").concat(hostname, ":").concat(port).concat(pathname);
|
|
87
|
+
};
|
|
88
|
+
var getSocketUrl = function getSocketUrl(urlParts, location) {
|
|
89
|
+
var host = urlParts.host, port = urlParts.port, path = urlParts.path, protocol = urlParts.protocol;
|
|
90
|
+
return formatURL({
|
|
91
|
+
protocol: protocol || (location.protocol === "https:" ? "wss" : "ws"),
|
|
92
|
+
hostname: host || location.hostname,
|
|
93
|
+
port: port || location.port,
|
|
94
|
+
pathname: path || HMR_SOCK_PATH
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
var clearOutdatedErrors = function clearOutdatedErrors() {
|
|
98
|
+
if (typeof console !== "undefined" && typeof console.clear === "function") {
|
|
99
|
+
if (hasCompileErrors) {
|
|
100
|
+
console.clear();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var handleSuccess = function handleSuccess() {
|
|
105
|
+
clearOutdatedErrors();
|
|
106
|
+
var isHotUpdate = !isFirstCompilation;
|
|
107
|
+
isFirstCompilation = false;
|
|
108
|
+
hasCompileErrors = false;
|
|
109
|
+
if (isHotUpdate) {
|
|
110
|
+
tryApplyUpdates();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var handleWarnings = function handleWarnings(warnings) {
|
|
114
|
+
clearOutdatedErrors();
|
|
115
|
+
var isHotUpdate = !isFirstCompilation;
|
|
116
|
+
isFirstCompilation = false;
|
|
117
|
+
hasCompileErrors = false;
|
|
118
|
+
function printWarnings() {
|
|
119
|
+
var formatted = (0, import_format_stats.formatStatsMessages)({
|
|
120
|
+
warnings: warnings,
|
|
121
|
+
errors: []
|
|
122
|
+
});
|
|
123
|
+
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
124
|
+
for(var i = 0; i < formatted.warnings.length; i++){
|
|
125
|
+
if (i === 5) {
|
|
126
|
+
console.warn("There were more warnings in other files.\nYou can find a complete log in the terminal.");
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
console.warn(formatted.warnings[i]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
printWarnings();
|
|
134
|
+
if (isHotUpdate) {
|
|
135
|
+
tryApplyUpdates();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var handleErrors = function handleErrors(errors) {
|
|
139
|
+
clearOutdatedErrors();
|
|
140
|
+
isFirstCompilation = false;
|
|
141
|
+
hasCompileErrors = true;
|
|
142
|
+
var formatted = (0, import_format_stats.formatStatsMessages)({
|
|
143
|
+
errors: errors,
|
|
144
|
+
warnings: []
|
|
145
|
+
});
|
|
146
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
147
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
148
|
+
try {
|
|
149
|
+
for(var _iterator = formatted.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
150
|
+
var error = _step.value;
|
|
151
|
+
console.error(error);
|
|
152
|
+
}
|
|
153
|
+
} catch (err) {
|
|
154
|
+
_didIteratorError = true;
|
|
155
|
+
_iteratorError = err;
|
|
156
|
+
} finally{
|
|
157
|
+
try {
|
|
158
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
159
|
+
_iterator.return();
|
|
160
|
+
}
|
|
161
|
+
} finally{
|
|
162
|
+
if (_didIteratorError) {
|
|
163
|
+
throw _iteratorError;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var handleAvailableHash = function handleAvailableHash(hash) {
|
|
170
|
+
mostRecentCompilationHash = hash;
|
|
171
|
+
};
|
|
172
|
+
var isUpdateAvailable = function isUpdateAvailable() {
|
|
173
|
+
return mostRecentCompilationHash !== __webpack_hash__;
|
|
174
|
+
};
|
|
175
|
+
var canApplyUpdates = function canApplyUpdates() {
|
|
176
|
+
return module.hot.status() === "idle";
|
|
177
|
+
};
|
|
178
|
+
var __create = Object.create;
|
|
179
|
+
var __defProp = Object.defineProperty;
|
|
180
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
181
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
182
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
183
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
184
|
+
var __commonJS = function(cb, mod) {
|
|
185
|
+
return function __require() {
|
|
186
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = {
|
|
187
|
+
exports: {}
|
|
188
|
+
}).exports, mod), mod.exports;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
var __copyProps = function(to, from, except, desc) {
|
|
192
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
193
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
194
|
+
try {
|
|
195
|
+
var _loop = function() {
|
|
196
|
+
var key = _step.value;
|
|
197
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
198
|
+
get: function() {
|
|
199
|
+
return from[key];
|
|
200
|
+
},
|
|
201
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
205
|
+
} catch (err) {
|
|
206
|
+
_didIteratorError = true;
|
|
207
|
+
_iteratorError = err;
|
|
208
|
+
} finally{
|
|
209
|
+
try {
|
|
210
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
211
|
+
_iterator.return();
|
|
212
|
+
}
|
|
213
|
+
} finally{
|
|
214
|
+
if (_didIteratorError) {
|
|
215
|
+
throw _iteratorError;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return to;
|
|
221
|
+
};
|
|
222
|
+
var __toESM = function(mod, isNodeMode, target) {
|
|
223
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
224
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
225
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
226
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
227
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
228
|
+
value: mod,
|
|
229
|
+
enumerable: true
|
|
230
|
+
}) : target, mod);
|
|
231
|
+
};
|
|
232
|
+
// ../shared/dist/formatStats.js
|
|
233
|
+
var require_formatStats = __commonJS({
|
|
234
|
+
"../shared/dist/formatStats.js": function(exports2, module2) {
|
|
235
|
+
"use strict";
|
|
236
|
+
var isLikelyASyntaxError = function isLikelyASyntaxError(message) {
|
|
237
|
+
return message.includes(friendlySyntaxErrorLabel);
|
|
238
|
+
};
|
|
239
|
+
var formatMessage = function formatMessage(stats) {
|
|
240
|
+
var lines = [];
|
|
241
|
+
var message;
|
|
242
|
+
if (typeof stats === "object") {
|
|
243
|
+
var fileName = stats.moduleName ? "File: ".concat(stats.moduleName, "\n") : "";
|
|
244
|
+
var mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
|
|
245
|
+
var details = stats.details ? "\nDetails: ".concat(stats.details, "\n") : "";
|
|
246
|
+
var stack = stats.stack ? "\n".concat(stats.stack) : "";
|
|
247
|
+
message = "".concat(fileName).concat(mainMessage).concat(details).concat(stack);
|
|
248
|
+
} else {
|
|
249
|
+
message = stats;
|
|
250
|
+
}
|
|
251
|
+
lines = message.split("\n");
|
|
252
|
+
lines = lines.map(function(line) {
|
|
253
|
+
var parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
|
|
254
|
+
if (!parsingError) {
|
|
255
|
+
return line;
|
|
256
|
+
}
|
|
257
|
+
var _parsingError = _sliced_to_array(parsingError, 4), errorLine = _parsingError[1], errorColumn = _parsingError[2], errorMessage = _parsingError[3];
|
|
258
|
+
return "".concat(friendlySyntaxErrorLabel, " ").concat(errorMessage, " (").concat(errorLine, ":").concat(errorColumn, ")");
|
|
259
|
+
});
|
|
260
|
+
message = lines.join("\n");
|
|
261
|
+
message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, "".concat(friendlySyntaxErrorLabel, " $3 ($1:$2)\n"));
|
|
262
|
+
lines = message.split("\n");
|
|
263
|
+
if (lines.length > 2 && lines[1].trim() === "") {
|
|
264
|
+
lines.splice(1, 1);
|
|
265
|
+
}
|
|
266
|
+
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
|
|
267
|
+
if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
|
|
268
|
+
lines[1] = lines[1].replace("Error: ", "");
|
|
269
|
+
}
|
|
270
|
+
lines = lines.filter(function(line, index, arr) {
|
|
271
|
+
return index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim();
|
|
272
|
+
});
|
|
273
|
+
message = lines.join("\n");
|
|
274
|
+
return message.trim();
|
|
275
|
+
};
|
|
276
|
+
var formatStatsMessages2 = function formatStatsMessages2(json) {
|
|
277
|
+
var _a, _b, _c;
|
|
278
|
+
var formattedErrors = (_a = json == null ? void 0 : json.errors) == null ? void 0 : _a.map(formatMessage);
|
|
279
|
+
var formattedWarnings = (_b = json == null ? void 0 : json.warnings) == null ? void 0 : _b.map(formatMessage);
|
|
280
|
+
var result = {
|
|
281
|
+
errors: formattedErrors || [],
|
|
282
|
+
warnings: formattedWarnings || [],
|
|
283
|
+
errorTips: []
|
|
284
|
+
};
|
|
285
|
+
if ((_c = result.errors) == null ? void 0 : _c.some(isLikelyASyntaxError)) {
|
|
286
|
+
result.errors = result.errors.filter(isLikelyASyntaxError);
|
|
287
|
+
}
|
|
288
|
+
if (result.errors.length > 1) {
|
|
289
|
+
result.errors.length = 1;
|
|
290
|
+
}
|
|
291
|
+
return result;
|
|
292
|
+
};
|
|
293
|
+
var __defProp2 = Object.defineProperty;
|
|
294
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
295
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
296
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
297
|
+
var __export = function(target, all) {
|
|
298
|
+
for(var name in all)__defProp2(target, name, {
|
|
299
|
+
get: all[name],
|
|
300
|
+
enumerable: true
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
var __copyProps2 = function(to, from, except, desc) {
|
|
304
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
305
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
306
|
+
try {
|
|
307
|
+
var _loop = function() {
|
|
308
|
+
var key = _step.value;
|
|
309
|
+
if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, {
|
|
310
|
+
get: function() {
|
|
311
|
+
return from[key];
|
|
312
|
+
},
|
|
313
|
+
enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
|
|
314
|
+
});
|
|
315
|
+
};
|
|
316
|
+
for(var _iterator = __getOwnPropNames2(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
317
|
+
} catch (err) {
|
|
318
|
+
_didIteratorError = true;
|
|
319
|
+
_iteratorError = err;
|
|
320
|
+
} finally{
|
|
321
|
+
try {
|
|
322
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
323
|
+
_iterator.return();
|
|
324
|
+
}
|
|
325
|
+
} finally{
|
|
326
|
+
if (_didIteratorError) {
|
|
327
|
+
throw _iteratorError;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return to;
|
|
333
|
+
};
|
|
334
|
+
var __toCommonJS = function(mod) {
|
|
335
|
+
return __copyProps2(__defProp2({}, "__esModule", {
|
|
336
|
+
value: true
|
|
337
|
+
}), mod);
|
|
338
|
+
};
|
|
339
|
+
var formatStats_exports = {};
|
|
340
|
+
__export(formatStats_exports, {
|
|
341
|
+
formatStatsMessages: function() {
|
|
342
|
+
return formatStatsMessages2;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
module2.exports = __toCommonJS(formatStats_exports);
|
|
346
|
+
var friendlySyntaxErrorLabel = "SyntaxError:";
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
// src/client/hmr/index.ts
|
|
350
|
+
var import_format_stats = __toESM(require_formatStats());
|
|
351
|
+
// src/client/hmr/createSocketUrl.ts
|
|
352
|
+
var HMR_SOCK_PATH = "/rsbuild-hmr";
|
|
353
|
+
// src/client/hmr/index.ts
|
|
354
|
+
var hadRuntimeError = false;
|
|
355
|
+
var socketUrl = createSocketUrl(__resourceQuery);
|
|
356
|
+
var connection = new WebSocket(socketUrl);
|
|
357
|
+
connection.onopen = function() {
|
|
358
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
359
|
+
console.info("[HMR] connected.");
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
connection.onclose = function() {
|
|
363
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
364
|
+
console.info("[HMR] disconnected. Refresh the page if necessary.");
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
var isFirstCompilation = true;
|
|
368
|
+
var mostRecentCompilationHash = null;
|
|
369
|
+
var hasCompileErrors = false;
|
|
370
|
+
connection.onmessage = function(e) {
|
|
371
|
+
var message = JSON.parse(e.data);
|
|
372
|
+
switch(message.type){
|
|
373
|
+
case "hash":
|
|
374
|
+
handleAvailableHash(message.data);
|
|
375
|
+
break;
|
|
376
|
+
case "still-ok":
|
|
377
|
+
case "ok":
|
|
378
|
+
handleSuccess();
|
|
379
|
+
break;
|
|
380
|
+
case "content-changed":
|
|
381
|
+
window.location.reload();
|
|
382
|
+
break;
|
|
383
|
+
case "warnings":
|
|
384
|
+
handleWarnings(message.data);
|
|
385
|
+
break;
|
|
386
|
+
case "errors":
|
|
387
|
+
handleErrors(message.data);
|
|
388
|
+
break;
|
|
389
|
+
default:
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
function tryApplyUpdates() {
|
|
393
|
+
if (!module.hot) {
|
|
394
|
+
window.location.reload();
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (!isUpdateAvailable() || !canApplyUpdates()) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
function handleApplyUpdates(err, updatedModules) {
|
|
401
|
+
var wantsForcedReload = err || !updatedModules || hadRuntimeError;
|
|
402
|
+
if (wantsForcedReload) {
|
|
403
|
+
window.location.reload();
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
if (isUpdateAvailable()) {
|
|
407
|
+
tryApplyUpdates();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
var result = module.hot.check(/* autoApply */ true, handleApplyUpdates);
|
|
411
|
+
if (result === null || result === void 0 ? void 0 : result.then) {
|
|
412
|
+
result.then(function(updatedModules) {
|
|
413
|
+
handleApplyUpdates(null, updatedModules);
|
|
414
|
+
}, function(err) {
|
|
415
|
+
handleApplyUpdates(err, null);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
package/dist/createRsbuild.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createRsbuild, getCreateRsbuildDefaultOptions } from './createRsbuild';
|
|
2
2
|
export { mergeRsbuildConfig } from '@rsbuild/shared';
|
|
3
3
|
export { defineConfig } from './cli';
|
|
4
|
-
export type {
|
|
5
|
-
export type { RsbuildMode, RsbuildEntry, RsbuildTarget,
|
|
4
|
+
export type { Rspack, RsbuildConfig, RsbuildPlugin, RsbuildPluginAPI } from './rspack-provider';
|
|
5
|
+
export type { Context, RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildInstance, CreateRsbuildOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn } from '@rsbuild/shared';
|
package/dist/plugins/fileSize.js
CHANGED
|
@@ -35,7 +35,6 @@ module.exports = __toCommonJS(fileSize_exports);
|
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
36
|
var import_shared = require("@rsbuild/shared");
|
|
37
37
|
var import_shared2 = require("@rsbuild/shared");
|
|
38
|
-
var import_gzip_size = __toESM(require("gzip-size"));
|
|
39
38
|
const filterAsset = (asset) => !/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
|
|
40
39
|
const getAssetColor = (size) => {
|
|
41
40
|
if (size > 300 * 1e3) {
|
|
@@ -63,10 +62,11 @@ const calcFileSize = (len) => {
|
|
|
63
62
|
return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
|
|
64
63
|
};
|
|
65
64
|
async function printFileSizes(stats, distPath) {
|
|
65
|
+
const { default: gzipSize } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/gzip-size")));
|
|
66
66
|
const formatAsset = (asset) => {
|
|
67
67
|
const contents = import_shared.fse.readFileSync(import_path.default.join(distPath, asset.name));
|
|
68
68
|
const size = contents.length;
|
|
69
|
-
const gzippedSize =
|
|
69
|
+
const gzippedSize = gzipSize.sync(contents);
|
|
70
70
|
return {
|
|
71
71
|
size,
|
|
72
72
|
folder: import_path.default.join(import_path.default.basename(distPath), import_path.default.dirname(asset.name)),
|
package/dist/plugins/html.js
CHANGED
|
@@ -178,7 +178,7 @@ const pluginHtml = () => ({
|
|
|
178
178
|
const htmlPaths = api.getHTMLPaths();
|
|
179
179
|
const htmlInfoMap = {};
|
|
180
180
|
await Promise.all(
|
|
181
|
-
entryNames.map(async (entryName
|
|
181
|
+
entryNames.map(async (entryName) => {
|
|
182
182
|
const entryValue = entries[entryName].values();
|
|
183
183
|
const chunks = getChunks(entryName, entryValue);
|
|
184
184
|
const inject = getInject(entryName, config);
|
package/dist/plugins/index.js
CHANGED
|
@@ -46,7 +46,6 @@ const plugins = {
|
|
|
46
46
|
inlineChunk: () => Promise.resolve().then(() => __toESM(require("./inlineChunk"))).then((m) => m.pluginInlineChunk()),
|
|
47
47
|
bundleAnalyzer: () => Promise.resolve().then(() => __toESM(require("./bundleAnalyzer"))).then((m) => m.pluginBundleAnalyzer()),
|
|
48
48
|
asset: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset()),
|
|
49
|
-
rem: () => Promise.resolve().then(() => __toESM(require("./rem"))).then((m) => m.pluginRem()),
|
|
50
49
|
wasm: () => Promise.resolve().then(() => __toESM(require("./wasm"))).then((m) => m.pluginWasm()),
|
|
51
50
|
moment: () => Promise.resolve().then(() => __toESM(require("./moment"))).then((m) => m.pluginMoment()),
|
|
52
51
|
nodeAddons: () => Promise.resolve().then(() => __toESM(require("./nodeAddons"))).then((m) => m.pluginNodeAddons()),
|
package/dist/plugins/startUrl.js
CHANGED
|
@@ -80,7 +80,7 @@ async function openBrowser(url) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
try {
|
|
83
|
-
const { default: open } = await Promise.resolve().then(() => __toESM(require("open")));
|
|
83
|
+
const { default: open } = await Promise.resolve().then(() => __toESM(require("../../compiled/open")));
|
|
84
84
|
await open(url);
|
|
85
85
|
return true;
|
|
86
86
|
} catch (err) {
|
|
@@ -9,4 +9,4 @@ export declare function createCompiler({
|
|
|
9
9
|
context: Context;
|
|
10
10
|
rspackConfigs: RspackConfig[];
|
|
11
11
|
}): Promise<import("@rspack/core").MultiCompiler>;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function createDevMiddleware(options: InitConfigsOptions, customCompiler?: RspackCompiler | RspackMultiCompiler): Promise<import("@rsbuild/shared").DevMiddleware>;
|
|
@@ -29,7 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var createCompiler_exports = {};
|
|
30
30
|
__export(createCompiler_exports, {
|
|
31
31
|
createCompiler: () => createCompiler,
|
|
32
|
-
|
|
32
|
+
createDevMiddleware: () => createDevMiddleware
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(createCompiler_exports);
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
@@ -82,7 +82,7 @@ async function createCompiler({
|
|
|
82
82
|
(0, import_shared.debug)("create compiler done");
|
|
83
83
|
return compiler;
|
|
84
84
|
}
|
|
85
|
-
async function
|
|
85
|
+
async function createDevMiddleware(options, customCompiler) {
|
|
86
86
|
let compiler;
|
|
87
87
|
if (customCompiler) {
|
|
88
88
|
compiler = customCompiler;
|
|
@@ -98,5 +98,5 @@ async function startDevCompile(options, customCompiler) {
|
|
|
98
98
|
// Annotate the CommonJS export names for ESM import in node:
|
|
99
99
|
0 && (module.exports = {
|
|
100
100
|
createCompiler,
|
|
101
|
-
|
|
101
|
+
createDevMiddleware
|
|
102
102
|
});
|
|
@@ -29,8 +29,9 @@ async function createContext(options, userRsbuildConfig) {
|
|
|
29
29
|
const rsbuildConfig = (0, import_defaults.withDefaultConfig)(userRsbuildConfig);
|
|
30
30
|
const context = (0, import_shared.createContextByConfig)(
|
|
31
31
|
options,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
"rspack",
|
|
33
|
+
rsbuildConfig.source,
|
|
34
|
+
rsbuildConfig.output
|
|
34
35
|
);
|
|
35
36
|
const tsconfigPath = (0, import_path.join)(context.rootPath, import_shared.TS_CONFIG_FILE);
|
|
36
37
|
return {
|
|
@@ -53,7 +53,7 @@ async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
|
53
53
|
}
|
|
54
54
|
async function getConfigUtils(config, chainUtils) {
|
|
55
55
|
const { merge } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/webpack-merge")));
|
|
56
|
-
const
|
|
56
|
+
const rspack = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
57
57
|
return {
|
|
58
58
|
...chainUtils,
|
|
59
59
|
rspack,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getRspackVersion } from './shared/rspackVersion';
|
|
2
2
|
export { rspackProvider } from './provider';
|
|
3
3
|
export type { RspackProvider } from './provider';
|
|
4
|
-
export type { RsbuildConfig, NormalizedConfig, RsbuildPluginAPI } from './types';
|
|
4
|
+
export type { RsbuildConfig, NormalizedConfig, RsbuildPlugin, RsbuildPluginAPI } from './types';
|
|
5
5
|
export type { Rspack, RspackConfig } from '@rsbuild/shared';
|
|
@@ -90,11 +90,7 @@ async function applyBaseCSSRule({
|
|
|
90
90
|
rule.use(CHAIN_ID.USE.CSS).loader((0, import_shared2.getCompiledPath)("css-loader")).options(cssLoaderOptions).end();
|
|
91
91
|
} else {
|
|
92
92
|
if (!isServer && !isWebWorker && enableCSSModuleTS) {
|
|
93
|
-
const { cssModules
|
|
94
|
-
const cssModulesAuto = (0, import_shared.getCssModulesAutoRule)(
|
|
95
|
-
cssModules,
|
|
96
|
-
disableCssModuleExtension
|
|
97
|
-
);
|
|
93
|
+
const { cssModules } = config.output;
|
|
98
94
|
rule.use(CHAIN_ID.USE.CSS_MODULES_TS).loader(
|
|
99
95
|
import_path.default.resolve(
|
|
100
96
|
__dirname,
|
|
@@ -103,7 +99,7 @@ async function applyBaseCSSRule({
|
|
|
103
99
|
).options({
|
|
104
100
|
modules: {
|
|
105
101
|
exportLocalsConvention: cssModules.exportLocalsConvention,
|
|
106
|
-
auto:
|
|
102
|
+
auto: cssModules.auto
|
|
107
103
|
}
|
|
108
104
|
}).end();
|
|
109
105
|
}
|
|
@@ -129,10 +125,7 @@ const applyCSSModuleRule = (rules, ruleTest, config) => {
|
|
|
129
125
|
if (ruleIndex === -1) {
|
|
130
126
|
return;
|
|
131
127
|
}
|
|
132
|
-
const cssModulesAuto =
|
|
133
|
-
config.output.cssModules,
|
|
134
|
-
config.output.disableCssModuleExtension
|
|
135
|
-
);
|
|
128
|
+
const cssModulesAuto = config.output.cssModules.auto;
|
|
136
129
|
if (!cssModulesAuto) {
|
|
137
130
|
return;
|
|
138
131
|
}
|