@rsbuild/core 0.0.28 → 0.1.1

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.
Files changed (64) hide show
  1. package/compiled/dotenv/index.js +1 -0
  2. package/compiled/dotenv/lib/main.d.ts +156 -0
  3. package/compiled/dotenv/license +23 -0
  4. package/compiled/dotenv/package.json +1 -0
  5. package/compiled/dotenv-expand/index.js +1 -0
  6. package/compiled/dotenv-expand/lib/main.d.ts +29 -0
  7. package/compiled/dotenv-expand/license +24 -0
  8. package/compiled/dotenv-expand/package.json +1 -0
  9. package/dist/cli/commands.d.ts +7 -1
  10. package/dist/cli/commands.js +37 -24
  11. package/dist/cli/config.js +28 -16
  12. package/dist/cli/prepare.js +1 -1
  13. package/dist/client/hmr.js +187 -187
  14. package/dist/loadEnv.d.ts +5 -0
  15. package/dist/loadEnv.js +58 -0
  16. package/dist/plugins/asset.js +1 -1
  17. package/dist/plugins/bundleAnalyzer.js +1 -1
  18. package/dist/plugins/cache.js +1 -1
  19. package/dist/plugins/cleanOutput.js +1 -1
  20. package/dist/plugins/define.js +1 -1
  21. package/dist/plugins/devtool.js +1 -1
  22. package/dist/plugins/entry.js +1 -1
  23. package/dist/plugins/externals.js +1 -1
  24. package/dist/plugins/fileSize.js +5 -4
  25. package/dist/plugins/html.d.ts +6 -4
  26. package/dist/plugins/html.js +39 -27
  27. package/dist/plugins/inlineChunk.js +8 -12
  28. package/dist/plugins/moment.js +1 -1
  29. package/dist/plugins/nodeAddons.js +1 -1
  30. package/dist/plugins/performance.js +1 -1
  31. package/dist/plugins/splitChunks.js +1 -1
  32. package/dist/plugins/startUrl.js +1 -1
  33. package/dist/plugins/target.js +1 -1
  34. package/dist/plugins/toml.js +1 -1
  35. package/dist/plugins/wasm.js +1 -1
  36. package/dist/plugins/yaml.js +1 -1
  37. package/dist/rspack-plugins/HtmlBasicPlugin.d.ts +2 -2
  38. package/dist/rspack-plugins/HtmlBasicPlugin.js +9 -17
  39. package/dist/rspack-provider/core/createContext.js +1 -1
  40. package/dist/rspack-provider/plugins/basic.js +1 -1
  41. package/dist/rspack-provider/plugins/css.js +1 -1
  42. package/dist/rspack-provider/plugins/hmr.js +1 -1
  43. package/dist/rspack-provider/plugins/less.js +1 -1
  44. package/dist/rspack-provider/plugins/minimize.js +1 -1
  45. package/dist/rspack-provider/plugins/output.js +1 -1
  46. package/dist/rspack-provider/plugins/progress.js +1 -1
  47. package/dist/rspack-provider/plugins/resolve.js +1 -1
  48. package/dist/rspack-provider/plugins/rspackProfile.d.ts +1 -0
  49. package/dist/rspack-provider/plugins/rspackProfile.js +1 -1
  50. package/dist/rspack-provider/plugins/sass.js +1 -1
  51. package/dist/rspack-provider/plugins/swc.js +3 -4
  52. package/dist/rspack-provider/plugins/transition.js +1 -5
  53. package/dist/server/dev-middleware/index.d.ts +5 -2
  54. package/dist/server/dev-middleware/index.js +24 -5
  55. package/dist/server/devServer.js +11 -12
  56. package/dist/server/middlewares.d.ts +2 -2
  57. package/dist/server/middlewares.js +19 -12
  58. package/dist/server/prodServer.d.ts +6 -3
  59. package/dist/server/prodServer.js +52 -11
  60. package/dist/server/proxy.d.ts +4 -3
  61. package/dist/server/restart.js +4 -1
  62. package/package.json +4 -4
  63. package/dist/server/https.d.ts +0 -6
  64. package/dist/server/https.js +0 -50
@@ -45,136 +45,6 @@ function _unsupported_iterable_to_array(o, minLen) {
45
45
  if (n === "Map" || n === "Set") return Array.from(n);
46
46
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
47
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
48
  var __create = Object.create;
179
49
  var __defProp = Object.defineProperty;
180
50
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -233,63 +103,6 @@ var __toESM = function(mod, isNodeMode, target) {
233
103
  var require_formatStats = __commonJS({
234
104
  "../shared/dist/formatStats.js": function(exports2, module2) {
235
105
  "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
106
  var __defProp2 = Object.defineProperty;
294
107
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
295
108
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -344,12 +157,118 @@ var require_formatStats = __commonJS({
344
157
  });
345
158
  module2.exports = __toCommonJS(formatStats_exports);
346
159
  var friendlySyntaxErrorLabel = "SyntaxError:";
160
+ function isLikelyASyntaxError(message) {
161
+ return message.includes(friendlySyntaxErrorLabel);
162
+ }
163
+ function formatMessage(stats) {
164
+ var lines = [];
165
+ var message;
166
+ if (typeof stats === "object") {
167
+ var fileName = stats.moduleName ? "File: ".concat(stats.moduleName, "\n") : "";
168
+ var mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
169
+ var details = stats.details ? "\nDetails: ".concat(stats.details, "\n") : "";
170
+ var stack = stats.stack ? "\n".concat(stats.stack) : "";
171
+ message = "".concat(fileName).concat(mainMessage).concat(details).concat(stack);
172
+ } else {
173
+ message = stats;
174
+ }
175
+ lines = message.split("\n");
176
+ lines = lines.map(function(line) {
177
+ var parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
178
+ if (!parsingError) {
179
+ return line;
180
+ }
181
+ var _parsingError = _sliced_to_array(parsingError, 4), errorLine = _parsingError[1], errorColumn = _parsingError[2], errorMessage = _parsingError[3];
182
+ return "".concat(friendlySyntaxErrorLabel, " ").concat(errorMessage, " (").concat(errorLine, ":").concat(errorColumn, ")");
183
+ });
184
+ message = lines.join("\n");
185
+ message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, "".concat(friendlySyntaxErrorLabel, " $3 ($1:$2)\n"));
186
+ lines = message.split("\n");
187
+ if (lines.length > 2 && lines[1].trim() === "") {
188
+ lines.splice(1, 1);
189
+ }
190
+ lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
191
+ if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
192
+ lines[1] = lines[1].replace("Error: ", "");
193
+ }
194
+ lines = lines.filter(function(line, index, arr) {
195
+ return index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim();
196
+ });
197
+ message = lines.join("\n");
198
+ return message.trim();
199
+ }
200
+ function formatStatsMessages2(json) {
201
+ var _a, _b, _c;
202
+ var formattedErrors = (_a = json == null ? void 0 : json.errors) == null ? void 0 : _a.map(formatMessage);
203
+ var formattedWarnings = (_b = json == null ? void 0 : json.warnings) == null ? void 0 : _b.map(formatMessage);
204
+ var result = {
205
+ errors: formattedErrors || [],
206
+ warnings: formattedWarnings || [],
207
+ errorTips: []
208
+ };
209
+ if ((_c = result.errors) == null ? void 0 : _c.some(isLikelyASyntaxError)) {
210
+ result.errors = result.errors.filter(isLikelyASyntaxError);
211
+ }
212
+ if (result.errors.length > 1) {
213
+ result.errors.length = 1;
214
+ }
215
+ return result;
216
+ }
347
217
  }
348
218
  });
349
219
  // src/client/hmr/index.ts
350
220
  var import_format_stats = __toESM(require_formatStats());
351
221
  // src/client/hmr/createSocketUrl.ts
352
222
  var HMR_SOCK_PATH = "/rsbuild-hmr";
223
+ function createSocketUrl(resourceQuery) {
224
+ var searchParams = resourceQuery.substr(1).split("&");
225
+ var options = {};
226
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
227
+ try {
228
+ for(var _iterator = searchParams[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
229
+ var pair = _step.value;
230
+ var ary = pair.split("=");
231
+ options[ary[0]] = decodeURIComponent(ary[1]);
232
+ }
233
+ } catch (err) {
234
+ _didIteratorError = true;
235
+ _iteratorError = err;
236
+ } finally{
237
+ try {
238
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
239
+ _iterator.return();
240
+ }
241
+ } finally{
242
+ if (_didIteratorError) {
243
+ throw _iteratorError;
244
+ }
245
+ }
246
+ }
247
+ var currentLocation = self.location;
248
+ return getSocketUrl(options, currentLocation);
249
+ }
250
+ function formatURL(param) {
251
+ var port = param.port, protocol = param.protocol, hostname = param.hostname, pathname = param.pathname;
252
+ if (window.URL) {
253
+ var url = new URL("http://localhost");
254
+ url.port = port;
255
+ url.hostname = hostname;
256
+ url.protocol = protocol;
257
+ url.pathname = pathname;
258
+ return url.toString();
259
+ }
260
+ var colon = protocol.indexOf(":") === -1 ? ":" : "";
261
+ return "".concat(protocol).concat(colon, "//").concat(hostname, ":").concat(port).concat(pathname);
262
+ }
263
+ function getSocketUrl(urlParts, location) {
264
+ var host = urlParts.host, port = urlParts.port, path = urlParts.path, protocol = urlParts.protocol;
265
+ return formatURL({
266
+ protocol: protocol || (location.protocol === "https:" ? "wss" : "ws"),
267
+ hostname: host || location.hostname,
268
+ port: port || location.port,
269
+ pathname: path || HMR_SOCK_PATH
270
+ });
271
+ }
353
272
  // src/client/hmr/index.ts
354
273
  var hadRuntimeError = false;
355
274
  var socketUrl = createSocketUrl(__resourceQuery);
@@ -367,6 +286,81 @@ connection.onclose = function() {
367
286
  var isFirstCompilation = true;
368
287
  var mostRecentCompilationHash = null;
369
288
  var hasCompileErrors = false;
289
+ function clearOutdatedErrors() {
290
+ if (typeof console !== "undefined" && typeof console.clear === "function") {
291
+ if (hasCompileErrors) {
292
+ console.clear();
293
+ }
294
+ }
295
+ }
296
+ function handleSuccess() {
297
+ clearOutdatedErrors();
298
+ var isHotUpdate = !isFirstCompilation;
299
+ isFirstCompilation = false;
300
+ hasCompileErrors = false;
301
+ if (isHotUpdate) {
302
+ tryApplyUpdates();
303
+ }
304
+ }
305
+ function handleWarnings(warnings) {
306
+ clearOutdatedErrors();
307
+ var isHotUpdate = !isFirstCompilation;
308
+ isFirstCompilation = false;
309
+ hasCompileErrors = false;
310
+ function printWarnings() {
311
+ var formatted = (0, import_format_stats.formatStatsMessages)({
312
+ warnings: warnings,
313
+ errors: []
314
+ });
315
+ if (typeof console !== "undefined" && typeof console.warn === "function") {
316
+ for(var i = 0; i < formatted.warnings.length; i++){
317
+ if (i === 5) {
318
+ console.warn("There were more warnings in other files.\nYou can find a complete log in the terminal.");
319
+ break;
320
+ }
321
+ console.warn(formatted.warnings[i]);
322
+ }
323
+ }
324
+ }
325
+ printWarnings();
326
+ if (isHotUpdate) {
327
+ tryApplyUpdates();
328
+ }
329
+ }
330
+ function handleErrors(errors) {
331
+ clearOutdatedErrors();
332
+ isFirstCompilation = false;
333
+ hasCompileErrors = true;
334
+ var formatted = (0, import_format_stats.formatStatsMessages)({
335
+ errors: errors,
336
+ warnings: []
337
+ });
338
+ if (typeof console !== "undefined" && typeof console.error === "function") {
339
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
340
+ try {
341
+ for(var _iterator = formatted.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
342
+ var error = _step.value;
343
+ console.error(error);
344
+ }
345
+ } catch (err) {
346
+ _didIteratorError = true;
347
+ _iteratorError = err;
348
+ } finally{
349
+ try {
350
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
351
+ _iterator.return();
352
+ }
353
+ } finally{
354
+ if (_didIteratorError) {
355
+ throw _iteratorError;
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
361
+ function handleAvailableHash(hash) {
362
+ mostRecentCompilationHash = hash;
363
+ }
370
364
  connection.onmessage = function(e) {
371
365
  var message = JSON.parse(e.data);
372
366
  switch(message.type){
@@ -389,6 +383,12 @@ connection.onmessage = function(e) {
389
383
  default:
390
384
  }
391
385
  };
386
+ function isUpdateAvailable() {
387
+ return mostRecentCompilationHash !== __webpack_hash__;
388
+ }
389
+ function canApplyUpdates() {
390
+ return module.hot.status() === "idle";
391
+ }
392
392
  function tryApplyUpdates() {
393
393
  if (!module.hot) {
394
394
  window.location.reload();
@@ -0,0 +1,5 @@
1
+ export declare function loadEnv({
2
+ dir
3
+ }?: {
4
+ dir?: string;
5
+ }): Promise<Record<string, string>>;
@@ -0,0 +1,58 @@
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 loadEnv_exports = {};
30
+ __export(loadEnv_exports, {
31
+ loadEnv: () => loadEnv
32
+ });
33
+ module.exports = __toCommonJS(loadEnv_exports);
34
+ var import_fs = __toESM(require("fs"));
35
+ var import_path = require("path");
36
+ var import_shared = require("@rsbuild/shared");
37
+ async function loadEnv({ dir = process.cwd() } = {}) {
38
+ const { parse } = await Promise.resolve().then(() => __toESM(require("../compiled/dotenv")));
39
+ const { expand } = await Promise.resolve().then(() => __toESM(require("../compiled/dotenv-expand")));
40
+ const { NODE_ENV } = process.env;
41
+ const files = [
42
+ ".env",
43
+ ".env.local",
44
+ `.env.${NODE_ENV}`,
45
+ `.env.${NODE_ENV}.local`
46
+ ];
47
+ const envPaths = files.map((filename) => (0, import_path.join)(dir, filename)).filter(import_shared.isFileSync);
48
+ const parsed = {};
49
+ envPaths.forEach((envPath) => {
50
+ Object.assign(parsed, parse(import_fs.default.readFileSync(envPath)));
51
+ });
52
+ expand({ parsed });
53
+ return parsed;
54
+ }
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ loadEnv
58
+ });
@@ -42,7 +42,7 @@ function getRegExpForExts(exts) {
42
42
  );
43
43
  }
44
44
  const pluginAsset = () => ({
45
- name: "plugin-asset",
45
+ name: "rsbuild:asset",
46
46
  setup(api) {
47
47
  api.modifyBundlerChain((chain, { isProd }) => {
48
48
  const config = api.getNormalizedConfig();
@@ -33,7 +33,7 @@ __export(bundleAnalyzer_exports, {
33
33
  module.exports = __toCommonJS(bundleAnalyzer_exports);
34
34
  function pluginBundleAnalyzer() {
35
35
  return {
36
- name: "plugin-bundle-analyzer",
36
+ name: "rsbuild:bundle-analyzer",
37
37
  setup(api) {
38
38
  api.modifyBundlerChain(async (chain, { CHAIN_ID, target }) => {
39
39
  const config = api.getNormalizedConfig();
@@ -81,7 +81,7 @@ async function getBuildDependencies(context) {
81
81
  return buildDependencies;
82
82
  }
83
83
  const pluginCache = () => ({
84
- name: "plugin-cache",
84
+ name: "rsbuild:cache",
85
85
  setup(api) {
86
86
  api.modifyBundlerChain(async (chain, { target, env }) => {
87
87
  const { buildCache } = api.getNormalizedConfig().performance;
@@ -28,7 +28,7 @@ const emptyDir = async (dir) => {
28
28
  }
29
29
  };
30
30
  const pluginCleanOutput = () => ({
31
- name: "plugin-clean-output",
31
+ name: "rsbuild:clean-output",
32
32
  setup(api) {
33
33
  const clean = async () => {
34
34
  const config = api.getNormalizedConfig();
@@ -23,7 +23,7 @@ __export(define_exports, {
23
23
  module.exports = __toCommonJS(define_exports);
24
24
  var import_shared = require("@rsbuild/shared");
25
25
  const pluginDefine = () => ({
26
- name: "plugin-define",
26
+ name: "rsbuild:define",
27
27
  setup(api) {
28
28
  api.modifyBundlerChain((chain, { CHAIN_ID, bundler }) => {
29
29
  const config = api.getNormalizedConfig();
@@ -23,7 +23,7 @@ __export(devtool_exports, {
23
23
  module.exports = __toCommonJS(devtool_exports);
24
24
  var import_shared = require("@rsbuild/shared");
25
25
  const pluginDevtool = () => ({
26
- name: "plugin-devtool",
26
+ name: "rsbuild:devtool",
27
27
  setup(api) {
28
28
  api.modifyBundlerChain((chain, { isProd, isServer }) => {
29
29
  const config = api.getNormalizedConfig();
@@ -23,7 +23,7 @@ __export(entry_exports, {
23
23
  module.exports = __toCommonJS(entry_exports);
24
24
  var import_shared = require("@rsbuild/shared");
25
25
  const pluginEntry = () => ({
26
- name: "plugin-entry",
26
+ name: "rsbuild:entry",
27
27
  setup(api) {
28
28
  api.modifyBundlerChain(async (chain) => {
29
29
  const { entry } = api.context;
@@ -23,7 +23,7 @@ __export(externals_exports, {
23
23
  module.exports = __toCommonJS(externals_exports);
24
24
  function pluginExternals() {
25
25
  return {
26
- name: "plugin-externals",
26
+ name: "rsbuild:externals",
27
27
  setup(api) {
28
28
  api.modifyBundlerChain((chain) => {
29
29
  const { externals } = api.getNormalizedConfig().output;
@@ -64,13 +64,14 @@ const calcFileSize = (len) => {
64
64
  async function printFileSizes(stats, distPath) {
65
65
  const { default: gzipSize } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/gzip-size")));
66
66
  const formatAsset = (asset) => {
67
- const contents = import_shared.fse.readFileSync(import_path.default.join(distPath, asset.name));
67
+ const fileName = asset.name.split("?")[0];
68
+ const contents = import_shared.fse.readFileSync(import_path.default.join(distPath, fileName));
68
69
  const size = contents.length;
69
70
  const gzippedSize = gzipSize.sync(contents);
70
71
  return {
71
72
  size,
72
- folder: import_path.default.join(import_path.default.basename(distPath), import_path.default.dirname(asset.name)),
73
- name: import_path.default.basename(asset.name),
73
+ folder: import_path.default.join(import_path.default.basename(distPath), import_path.default.dirname(fileName)),
74
+ name: import_path.default.basename(fileName),
74
75
  gzippedSize,
75
76
  sizeLabel: calcFileSize(size),
76
77
  gzipSizeLabel: getAssetColor(gzippedSize)(calcFileSize(gzippedSize))
@@ -136,7 +137,7 @@ async function printFileSizes(stats, distPath) {
136
137
  `);
137
138
  }
138
139
  const pluginFileSize = () => ({
139
- name: "plugin-file-size",
140
+ name: "rsbuild:file-size",
140
141
  setup(api) {
141
142
  api.onAfterBuild(async ({ stats }) => {
142
143
  const config = api.getNormalizedConfig();
@@ -1,15 +1,17 @@
1
- import type { MetaAttrs, HtmlConfig, MetaOptions, NormalizedConfig, SharedRsbuildPluginAPI, NormalizedOutputConfig } from '@rsbuild/shared';
1
+ import type { HtmlConfig, NormalizedConfig, SharedRsbuildPluginAPI, NormalizedOutputConfig } from '@rsbuild/shared';
2
2
  import type { RsbuildPlugin } from '../types';
3
3
  export declare function getTitle(entryName: string, config: NormalizedConfig): string;
4
4
  export declare function getInject(entryName: string, config: NormalizedConfig): import("@rsbuild/shared").ScriptInject;
5
- export declare function getTemplatePath(entryName: string, config: NormalizedConfig): string;
5
+ export declare function getTemplate(entryName: string, config: NormalizedConfig, rootPath: string): Promise<{
6
+ templatePath: string;
7
+ templateContent?: string;
8
+ }>;
6
9
  export declare function getFavicon(entryName: string, config: {
7
10
  html: HtmlConfig;
8
11
  }): string;
9
- export declare const generateMetaTags: (metaOptions?: MetaOptions) => MetaAttrs[];
10
12
  export declare function getMetaTags(entryName: string, config: {
11
13
  html: HtmlConfig;
12
14
  output: NormalizedOutputConfig;
13
- }): Promise<MetaAttrs[]>;
15
+ }): Promise<import("@rsbuild/shared").MetaOptions>;
14
16
  export declare const applyInjectTags: (api: SharedRsbuildPluginAPI) => void;
15
17
  export declare const pluginHtml: () => RsbuildPlugin;