@rsbuild/core 0.2.7 → 0.2.8

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 (102) hide show
  1. package/dist/cli/commands.d.ts +12 -15
  2. package/dist/cli/commands.js +1 -1
  3. package/dist/cli/config.d.ts +12 -12
  4. package/dist/cli/prepare.d.ts +1 -1
  5. package/dist/cli/prepare.js +1 -1
  6. package/dist/client/hmr/createSocketUrl.d.ts +6 -11
  7. package/dist/client/hmr/index.d.ts +1 -1
  8. package/dist/client/hmr.js +236 -33
  9. package/dist/createRsbuild.d.ts +1 -1
  10. package/dist/index.d.ts +2 -2
  11. package/dist/loadEnv.d.ts +6 -9
  12. package/dist/plugins/asset.d.ts +1 -1
  13. package/dist/plugins/basic.d.ts +1 -1
  14. package/dist/plugins/bundleAnalyzer.d.ts +1 -1
  15. package/dist/plugins/cache.d.ts +1 -1
  16. package/dist/plugins/cleanOutput.d.ts +1 -1
  17. package/dist/plugins/define.d.ts +1 -1
  18. package/dist/plugins/entry.d.ts +1 -1
  19. package/dist/plugins/entry.js +7 -2
  20. package/dist/plugins/externals.d.ts +1 -1
  21. package/dist/plugins/fileSize.d.ts +1 -1
  22. package/dist/plugins/html.d.ts +5 -5
  23. package/dist/plugins/index.d.ts +1 -1
  24. package/dist/plugins/inlineChunk.d.ts +1 -1
  25. package/dist/plugins/moment.d.ts +1 -1
  26. package/dist/plugins/networkPerformance.d.ts +1 -1
  27. package/dist/plugins/nodeAddons.d.ts +1 -1
  28. package/dist/plugins/performance.d.ts +1 -1
  29. package/dist/plugins/preloadOrPrefetch.d.ts +1 -1
  30. package/dist/plugins/splitChunks.d.ts +1 -1
  31. package/dist/plugins/startUrl.d.ts +1 -1
  32. package/dist/plugins/target.d.ts +1 -1
  33. package/dist/plugins/toml.d.ts +1 -1
  34. package/dist/plugins/wasm.d.ts +1 -1
  35. package/dist/plugins/yaml.d.ts +1 -1
  36. package/dist/provider/config.d.ts +1 -1
  37. package/dist/provider/core/build.d.ts +10 -14
  38. package/dist/provider/core/createCompiler.d.ts +4 -7
  39. package/dist/provider/core/createContext.d.ts +1 -1
  40. package/dist/provider/core/createContext.js +1 -1
  41. package/dist/provider/core/devMiddleware.d.ts +1 -1
  42. package/dist/provider/core/initConfigs.d.ts +7 -14
  43. package/dist/provider/core/initHooks.d.ts +18 -18
  44. package/dist/provider/core/initPlugins.d.ts +4 -7
  45. package/dist/provider/core/inspectConfig.d.ts +4 -10
  46. package/dist/provider/core/rspackConfig.d.ts +4 -7
  47. package/dist/provider/core/rspackConfig.js +2 -2
  48. package/dist/provider/css-modules-typescript-pre-loader/index.d.ts +3 -3
  49. package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.d.ts +5 -5
  50. package/dist/provider/htmlPluginUtil.d.ts +9 -0
  51. package/dist/provider/htmlPluginUtil.js +47 -0
  52. package/dist/provider/index.d.ts +2 -1
  53. package/dist/provider/index.js +5 -0
  54. package/dist/provider/plugins/css.d.ts +7 -19
  55. package/dist/provider/plugins/hmr.d.ts +1 -1
  56. package/dist/provider/plugins/less.d.ts +1 -1
  57. package/dist/provider/plugins/minimize.d.ts +1 -1
  58. package/dist/provider/plugins/output.d.ts +1 -1
  59. package/dist/provider/plugins/progress.d.ts +1 -1
  60. package/dist/provider/plugins/resolve.d.ts +1 -1
  61. package/dist/provider/plugins/rspackProfile.d.ts +1 -1
  62. package/dist/provider/plugins/sass.d.ts +1 -1
  63. package/dist/provider/plugins/server.d.ts +1 -1
  64. package/dist/provider/plugins/swc.d.ts +1 -1
  65. package/dist/provider/plugins/swc.js +29 -37
  66. package/dist/provider/plugins/transition.d.ts +1 -1
  67. package/dist/provider/provider.d.ts +1 -1
  68. package/dist/provider/shared.d.ts +1 -1
  69. package/dist/rspack/HtmlAppIconPlugin.d.ts +8 -8
  70. package/dist/rspack/HtmlAppIconPlugin.js +15 -18
  71. package/dist/rspack/HtmlBasicPlugin.d.ts +8 -8
  72. package/dist/rspack/HtmlBasicPlugin.js +12 -25
  73. package/dist/rspack/HtmlCrossOriginPlugin.d.ts +6 -6
  74. package/dist/rspack/HtmlCrossOriginPlugin.js +13 -26
  75. package/dist/rspack/HtmlNetworkPerformancePlugin.d.ts +5 -5
  76. package/dist/rspack/HtmlNetworkPerformancePlugin.js +2 -12
  77. package/dist/rspack/HtmlNoncePlugin.d.ts +6 -6
  78. package/dist/rspack/HtmlNoncePlugin.js +8 -21
  79. package/dist/rspack/HtmlTagsPlugin.d.ts +13 -13
  80. package/dist/rspack/HtmlTagsPlugin.js +2 -12
  81. package/dist/rspack/InlineChunkHtmlPlugin.d.ts +39 -49
  82. package/dist/rspack/InlineChunkHtmlPlugin.js +2 -12
  83. package/dist/rspack/RemoveCssSourcemapPlugin.d.ts +4 -4
  84. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +8 -8
  85. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +3 -13
  86. package/dist/rspack/preload/helpers/determineAsValue.d.ts +4 -7
  87. package/dist/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +6 -9
  88. package/dist/rspack/preload/helpers/extractChunks.d.ts +4 -7
  89. package/dist/rspack/preload/helpers/index.d.ts +1 -1
  90. package/dist/rspack/preload/helpers/type.d.ts +10 -10
  91. package/dist/server/compilerDevMiddleware.d.ts +15 -19
  92. package/dist/server/devServer.d.ts +7 -15
  93. package/dist/server/getDevMiddlewares.d.ts +10 -10
  94. package/dist/server/httpServer.d.ts +3 -3
  95. package/dist/server/index.d.ts +1 -1
  96. package/dist/server/middlewares.d.ts +4 -4
  97. package/dist/server/prodServer.d.ts +16 -19
  98. package/dist/server/proxy.d.ts +3 -3
  99. package/dist/server/restart.d.ts +3 -5
  100. package/dist/server/socketServer.d.ts +17 -17
  101. package/dist/types.d.ts +11 -11
  102. package/package.json +3 -3
@@ -1,25 +1,22 @@
1
1
  import type { RsbuildMode } from '..';
2
2
  export type CommonOptions = {
3
- config?: string;
4
- open?: boolean;
5
- host?: string;
6
- port?: number;
3
+ config?: string;
4
+ open?: boolean;
5
+ host?: string;
6
+ port?: number;
7
7
  };
8
8
  export type BuildOptions = CommonOptions & {
9
- watch?: boolean;
9
+ watch?: boolean;
10
10
  };
11
11
  export type InspectOptions = CommonOptions & {
12
- env: RsbuildMode;
13
- output: string;
14
- verbose?: boolean;
12
+ env: RsbuildMode;
13
+ output: string;
14
+ verbose?: boolean;
15
15
  };
16
16
  export type DevOptions = CommonOptions;
17
17
  export type PreviewOptions = CommonOptions;
18
- export declare function init({
19
- cliOptions,
20
- isRestart
21
- }: {
22
- cliOptions?: CommonOptions;
23
- isRestart?: boolean;
18
+ export declare function init({ cliOptions, isRestart, }: {
19
+ cliOptions?: CommonOptions;
20
+ isRestart?: boolean;
24
21
  }): Promise<import("@rsbuild/shared").RsbuildInstance | undefined>;
25
- export declare function runCli(): void;
22
+ export declare function runCli(): void;
@@ -83,7 +83,7 @@ async function init({
83
83
  }
84
84
  }
85
85
  function runCli() {
86
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.2.7");
86
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.2.8");
87
87
  import_commander.program.command("dev").option("--open", "open the page in browser on startup").option(
88
88
  "--port <port>",
89
89
  "specify a port number for Rsbuild Server to listen"
@@ -1,20 +1,20 @@
1
1
  import { type RsbuildConfig } from '@rsbuild/shared';
2
2
  export type ConfigParams = {
3
- env: string;
4
- command: string;
3
+ env: string;
4
+ command: string;
5
5
  };
6
- export type RsbuildConfigFn = (env: ConfigParams) => RsbuildConfig | Promise<RsbuildConfig>;
7
- export type RsbuildConfigExport = RsbuildConfig | RsbuildConfigFn;
6
+ export type RsbuildConfigAsyncFn = (env: ConfigParams) => Promise<RsbuildConfig>;
7
+ export type RsbuildConfigSyncFn = (env: ConfigParams) => RsbuildConfig;
8
+ export type RsbuildConfigExport = RsbuildConfig | RsbuildConfigSyncFn | RsbuildConfigAsyncFn;
8
9
  /**
9
10
  * This function helps you to autocomplete configuration types.
10
11
  * It accepts a Rsbuild config object, or a function that returns a config.
11
12
  */
12
13
  export declare function defineConfig(config: RsbuildConfig): RsbuildConfig;
13
- export declare function defineConfig(config: RsbuildConfigFn): RsbuildConfigFn;
14
- export declare function loadConfig({
15
- cwd,
16
- path
17
- }: {
18
- cwd: string;
19
- path?: string;
20
- }): Promise<RsbuildConfig>;
14
+ export declare function defineConfig(config: RsbuildConfigSyncFn): RsbuildConfigSyncFn;
15
+ export declare function defineConfig(config: RsbuildConfigAsyncFn): RsbuildConfigAsyncFn;
16
+ export declare function defineConfig(config: RsbuildConfigExport): RsbuildConfigExport;
17
+ export declare function loadConfig({ cwd, path, }: {
18
+ cwd: string;
19
+ path?: string;
20
+ }): Promise<RsbuildConfig>;
@@ -1 +1 @@
1
- export declare function prepareCli(): void;
1
+ export declare function prepareCli(): void;
@@ -34,7 +34,7 @@ function prepareCli() {
34
34
  if (!npm_execpath || npm_execpath.includes("npx-cli.js")) {
35
35
  console.log();
36
36
  }
37
- import_rslog.logger.greet(` ${`Rsbuild v${"0.2.7"}`}
37
+ import_rslog.logger.greet(` ${`Rsbuild v${"0.2.8"}`}
38
38
  `);
39
39
  }
40
40
  // Annotate the CommonJS export names for ESM import in node:
@@ -3,14 +3,9 @@
3
3
  */
4
4
  export declare const HMR_SOCK_PATH = "/rsbuild-hmr";
5
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;
6
+ export declare function formatURL({ port, protocol, hostname, pathname, }: {
7
+ port: string;
8
+ protocol: string;
9
+ hostname: string;
10
+ pathname: string;
11
+ }): string;
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -7,6 +7,35 @@ function _array_like_to_array(arr, len) {
7
7
  function _array_with_holes(arr) {
8
8
  if (Array.isArray(arr)) return arr;
9
9
  }
10
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
11
+ try {
12
+ var info = gen[key](arg);
13
+ var value = info.value;
14
+ } catch (error) {
15
+ reject(error);
16
+ return;
17
+ }
18
+ if (info.done) {
19
+ resolve(value);
20
+ } else {
21
+ Promise.resolve(value).then(_next, _throw);
22
+ }
23
+ }
24
+ function _async_to_generator(fn) {
25
+ return function() {
26
+ var self1 = this, args = arguments;
27
+ return new Promise(function(resolve, reject) {
28
+ var gen = fn.apply(self1, args);
29
+ function _next(value) {
30
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
31
+ }
32
+ function _throw(err) {
33
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
34
+ }
35
+ _next(undefined);
36
+ });
37
+ };
38
+ }
10
39
  function _iterable_to_array_limit(arr, i) {
11
40
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
12
41
  if (_i == null) return;
@@ -45,6 +74,101 @@ function _unsupported_iterable_to_array(o, minLen) {
45
74
  if (n === "Map" || n === "Set") return Array.from(n);
46
75
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
47
76
  }
77
+ function _ts_generator(thisArg, body) {
78
+ var f, y, t, g, _ = {
79
+ label: 0,
80
+ sent: function() {
81
+ if (t[0] & 1) throw t[1];
82
+ return t[1];
83
+ },
84
+ trys: [],
85
+ ops: []
86
+ };
87
+ return g = {
88
+ next: verb(0),
89
+ "throw": verb(1),
90
+ "return": verb(2)
91
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
92
+ return this;
93
+ }), g;
94
+ function verb(n) {
95
+ return function(v) {
96
+ return step([
97
+ n,
98
+ v
99
+ ]);
100
+ };
101
+ }
102
+ function step(op) {
103
+ if (f) throw new TypeError("Generator is already executing.");
104
+ while(_)try {
105
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
106
+ if (y = 0, t) op = [
107
+ op[0] & 2,
108
+ t.value
109
+ ];
110
+ switch(op[0]){
111
+ case 0:
112
+ case 1:
113
+ t = op;
114
+ break;
115
+ case 4:
116
+ _.label++;
117
+ return {
118
+ value: op[1],
119
+ done: false
120
+ };
121
+ case 5:
122
+ _.label++;
123
+ y = op[1];
124
+ op = [
125
+ 0
126
+ ];
127
+ continue;
128
+ case 7:
129
+ op = _.ops.pop();
130
+ _.trys.pop();
131
+ continue;
132
+ default:
133
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
134
+ _ = 0;
135
+ continue;
136
+ }
137
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
138
+ _.label = op[1];
139
+ break;
140
+ }
141
+ if (op[0] === 6 && _.label < t[1]) {
142
+ _.label = t[1];
143
+ t = op;
144
+ break;
145
+ }
146
+ if (t && _.label < t[2]) {
147
+ _.label = t[2];
148
+ _.ops.push(op);
149
+ break;
150
+ }
151
+ if (t[2]) _.ops.pop();
152
+ _.trys.pop();
153
+ continue;
154
+ }
155
+ op = body.call(thisArg, _);
156
+ } catch (e) {
157
+ op = [
158
+ 6,
159
+ e
160
+ ];
161
+ y = 0;
162
+ } finally{
163
+ f = t = 0;
164
+ }
165
+ if (op[0] & 5) throw op[1];
166
+ return {
167
+ value: op[0] ? op[1] : void 0,
168
+ done: true
169
+ };
170
+ }
171
+ }
48
172
  var __create = Object.create;
49
173
  var __defProp = Object.defineProperty;
50
174
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -272,17 +396,6 @@ function getSocketUrl(urlParts, location) {
272
396
  // src/client/hmr/index.ts
273
397
  var hadRuntimeError = false;
274
398
  var socketUrl = createSocketUrl(__resourceQuery);
275
- var connection = new WebSocket(socketUrl);
276
- connection.onopen = function() {
277
- if (typeof console !== "undefined" && typeof console.info === "function") {
278
- console.info("[HMR] connected.");
279
- }
280
- };
281
- connection.onclose = function() {
282
- if (typeof console !== "undefined" && typeof console.info === "function") {
283
- console.info("[HMR] disconnected. Refresh the page if necessary.");
284
- }
285
- };
286
399
  var isFirstCompilation = true;
287
400
  var mostRecentCompilationHash = null;
288
401
  var hasCompileErrors = false;
@@ -361,28 +474,6 @@ function handleErrors(errors) {
361
474
  function handleAvailableHash(hash) {
362
475
  mostRecentCompilationHash = hash;
363
476
  }
364
- connection.onmessage = function(e) {
365
- var message = JSON.parse(e.data);
366
- switch(message.type){
367
- case "hash":
368
- handleAvailableHash(message.data);
369
- break;
370
- case "still-ok":
371
- case "ok":
372
- handleSuccess();
373
- break;
374
- case "content-changed":
375
- window.location.reload();
376
- break;
377
- case "warnings":
378
- handleWarnings(message.data);
379
- break;
380
- case "errors":
381
- handleErrors(message.data);
382
- break;
383
- default:
384
- }
385
- };
386
477
  function isUpdateAvailable() {
387
478
  return mostRecentCompilationHash !== __webpack_hash__;
388
479
  }
@@ -416,3 +507,115 @@ function tryApplyUpdates() {
416
507
  });
417
508
  }
418
509
  }
510
+ var MAX_RETRIES = 100;
511
+ var connection = null;
512
+ var retry_counter = 0;
513
+ function onOpen() {
514
+ if (typeof console !== "undefined" && typeof console.info === "function") {
515
+ console.info("[HMR] connected.");
516
+ }
517
+ }
518
+ function onMessage(e) {
519
+ var message = JSON.parse(e.data);
520
+ switch(message.type){
521
+ case "hash":
522
+ handleAvailableHash(message.data);
523
+ break;
524
+ case "still-ok":
525
+ case "ok":
526
+ handleSuccess();
527
+ break;
528
+ case "content-changed":
529
+ window.location.reload();
530
+ break;
531
+ case "warnings":
532
+ handleWarnings(message.data);
533
+ break;
534
+ case "errors":
535
+ handleErrors(message.data);
536
+ break;
537
+ default:
538
+ }
539
+ }
540
+ function sleep() {
541
+ return _sleep.apply(this, arguments);
542
+ }
543
+ function _sleep() {
544
+ _sleep = _async_to_generator(function() {
545
+ var msec;
546
+ var _arguments = arguments;
547
+ return _ts_generator(this, function(_state) {
548
+ msec = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : 1e3;
549
+ return [
550
+ 2,
551
+ new Promise(function(resolve) {
552
+ setTimeout(resolve, msec);
553
+ })
554
+ ];
555
+ });
556
+ });
557
+ return _sleep.apply(this, arguments);
558
+ }
559
+ function onClose() {
560
+ return _onClose.apply(this, arguments);
561
+ }
562
+ function _onClose() {
563
+ _onClose = _async_to_generator(function() {
564
+ return _ts_generator(this, function(_state) {
565
+ switch(_state.label){
566
+ case 0:
567
+ if (typeof console !== "undefined" && typeof console.info === "function") {
568
+ console.info("[HMR] disconnected. Attempting to reconnect.");
569
+ }
570
+ removeListeners();
571
+ return [
572
+ 4,
573
+ sleep(1e3)
574
+ ];
575
+ case 1:
576
+ _state.sent();
577
+ retry_counter++;
578
+ if (connection && (connection.readyState === connection.CONNECTING || connection.readyState === connection.OPEN)) {
579
+ retry_counter = 0;
580
+ return [
581
+ 2
582
+ ];
583
+ }
584
+ if (retry_counter > MAX_RETRIES) {
585
+ if (typeof console !== "undefined" && typeof console.info === "function") {
586
+ console.info("[HMR] Unable to establish a connection after exceeding the maximum retry attempts.");
587
+ }
588
+ retry_counter = 0;
589
+ return [
590
+ 2
591
+ ];
592
+ }
593
+ reconnect();
594
+ return [
595
+ 2
596
+ ];
597
+ }
598
+ });
599
+ });
600
+ return _onClose.apply(this, arguments);
601
+ }
602
+ function connect() {
603
+ connection = new WebSocket(socketUrl);
604
+ connection.addEventListener("open", onOpen);
605
+ connection.addEventListener("close", onClose);
606
+ connection.addEventListener("message", onMessage);
607
+ }
608
+ function removeListeners() {
609
+ if (connection) {
610
+ connection.removeEventListener("open", onOpen);
611
+ connection.removeEventListener("close", onClose);
612
+ connection.removeEventListener("message", onMessage);
613
+ }
614
+ }
615
+ function reconnect() {
616
+ if (connection) {
617
+ connection = null;
618
+ }
619
+ connect();
620
+ }
621
+ connect();
@@ -1,2 +1,2 @@
1
1
  import { type RsbuildInstance, type CreateRsbuildOptions } from '@rsbuild/shared';
2
- export declare function createRsbuild(options: CreateRsbuildOptions): Promise<RsbuildInstance>;
2
+ export declare function createRsbuild(options: CreateRsbuildOptions): Promise<RsbuildInstance>;
package/dist/index.d.ts CHANGED
@@ -6,5 +6,5 @@ export { createRsbuild } from './createRsbuild';
6
6
  export { loadConfig, defineConfig } from './cli/config';
7
7
  export { logger, mergeRsbuildConfig } from '@rsbuild/shared';
8
8
  export type { Rspack } from './provider';
9
- export type { RsbuildConfig, NormalizedConfig, RsbuildPlugin, RsbuildPluginAPI } from './types';
10
- export type { Context as RsbuildContext, RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildInstance, CreateRsbuildOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn } from '@rsbuild/shared';
9
+ export type { RsbuildConfig, NormalizedConfig, RsbuildPlugin, RsbuildPluginAPI, } from './types';
10
+ export type { Context as RsbuildContext, RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildInstance, CreateRsbuildOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnBeforeCreateCompilerFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn, } from '@rsbuild/shared';
package/dist/loadEnv.d.ts CHANGED
@@ -1,11 +1,8 @@
1
1
  export declare const getEnvFiles: () => string[];
2
- export declare function loadEnv({
3
- cwd,
4
- prefixes
5
- }?: {
6
- cwd?: string;
7
- prefixes?: string[];
2
+ export declare function loadEnv({ cwd, prefixes, }?: {
3
+ cwd?: string;
4
+ prefixes?: string[];
8
5
  }): Promise<{
9
- parsed: Record<string, string>;
10
- publicVars: Record<string, string>;
11
- }>;
6
+ parsed: Record<string, string>;
7
+ publicVars: Record<string, string>;
8
+ }>;
@@ -1,3 +1,3 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
2
  export declare function getRegExpForExts(exts: string[]): RegExp;
3
- export declare const pluginAsset: () => RsbuildPlugin;
3
+ export declare const pluginAsset: () => RsbuildPlugin;
@@ -2,4 +2,4 @@ import type { RsbuildPlugin } from '../types';
2
2
  /**
3
3
  * Provide some basic configs of rspack
4
4
  */
5
- export declare const pluginBasic: () => RsbuildPlugin;
5
+ export declare const pluginBasic: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare function pluginBundleAnalyzer(): RsbuildPlugin;
2
+ export declare function pluginBundleAnalyzer(): RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginCache: () => RsbuildPlugin;
2
+ export declare const pluginCache: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginCleanOutput: () => RsbuildPlugin;
2
+ export declare const pluginCleanOutput: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginDefine: () => RsbuildPlugin;
2
+ export declare const pluginDefine: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginEntry: () => RsbuildPlugin;
2
+ export declare const pluginEntry: () => RsbuildPlugin;
@@ -25,12 +25,17 @@ var import_shared = require("@rsbuild/shared");
25
25
  const pluginEntry = () => ({
26
26
  name: "rsbuild:entry",
27
27
  setup(api) {
28
- api.modifyBundlerChain(async (chain) => {
28
+ api.modifyBundlerChain(async (chain, { isServer, isServiceWorker }) => {
29
29
  const { entry } = api.context;
30
- const { preEntry } = api.getNormalizedConfig().source;
30
+ const config = api.getNormalizedConfig();
31
+ const { preEntry } = config.source;
32
+ const injectCoreJsEntry = config.output.polyfill === "entry" && !isServer && !isServiceWorker;
31
33
  Object.keys(entry).forEach((entryName) => {
32
34
  const appendEntry = (file) => chain.entry(entryName).add(file);
33
35
  preEntry.forEach(appendEntry);
36
+ if (injectCoreJsEntry) {
37
+ appendEntry((0, import_shared.createVirtualModule)('import "core-js";'));
38
+ }
34
39
  (0, import_shared.castArray)(entry[entryName]).forEach(appendEntry);
35
40
  });
36
41
  });
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare function pluginExternals(): RsbuildPlugin;
2
+ export declare function pluginExternals(): RsbuildPlugin;
@@ -1,4 +1,4 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
2
  /** Filter source map and license files */
3
3
  export declare const filterAsset: (asset: string) => boolean;
4
- export declare const pluginFileSize: () => RsbuildPlugin;
4
+ export declare const pluginFileSize: () => RsbuildPlugin;
@@ -3,14 +3,14 @@ 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
5
  export declare function getTemplate(entryName: string, config: NormalizedConfig, rootPath: string): Promise<{
6
- templatePath: string;
7
- templateContent?: string;
6
+ templatePath: string;
7
+ templateContent?: string;
8
8
  }>;
9
9
  export declare function getFavicon(entryName: string, config: {
10
- html: HtmlConfig;
10
+ html: HtmlConfig;
11
11
  }): string;
12
12
  export declare function getMetaTags(entryName: string, config: {
13
- html: HtmlConfig;
13
+ html: HtmlConfig;
14
14
  }, templateContent?: string): import("@rsbuild/shared").MetaOptions;
15
15
  export declare const applyInjectTags: (api: RsbuildPluginAPI) => void;
16
- export declare const pluginHtml: () => RsbuildPlugin;
16
+ export declare const pluginHtml: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { Plugins } from '@rsbuild/shared';
2
- export declare const plugins: Plugins;
2
+ export declare const plugins: Plugins;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginInlineChunk: () => RsbuildPlugin;
2
+ export declare const pluginInlineChunk: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginMoment: () => RsbuildPlugin;
2
+ export declare const pluginMoment: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginNetworkPerformance: () => RsbuildPlugin;
2
+ export declare const pluginNetworkPerformance: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginNodeAddons: () => RsbuildPlugin;
2
+ export declare const pluginNodeAddons: () => RsbuildPlugin;
@@ -2,4 +2,4 @@ import type { RsbuildPlugin } from '../types';
2
2
  /**
3
3
  * Apply some configs of Rsbuild performance
4
4
  */
5
- export declare const pluginPerformance: () => RsbuildPlugin;
5
+ export declare const pluginPerformance: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginPreloadOrPrefetch: () => RsbuildPlugin;
2
+ export declare const pluginPreloadOrPrefetch: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare function pluginSplitChunks(): RsbuildPlugin;
2
+ export declare function pluginSplitChunks(): RsbuildPlugin;
@@ -9,4 +9,4 @@ import type { RsbuildPlugin } from '../types';
9
9
  */
10
10
  export declare function openBrowser(url: string): Promise<boolean>;
11
11
  export declare const replacePlaceholder: (url: string, port: number) => string;
12
- export declare function pluginStartUrl(): RsbuildPlugin;
12
+ export declare function pluginStartUrl(): RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginTarget: () => RsbuildPlugin;
2
+ export declare const pluginTarget: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginToml: () => RsbuildPlugin;
2
+ export declare const pluginToml: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginWasm: () => RsbuildPlugin;
2
+ export declare const pluginWasm: () => RsbuildPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { RsbuildPlugin } from '../types';
2
- export declare const pluginYaml: () => RsbuildPlugin;
2
+ export declare const pluginYaml: () => RsbuildPlugin;
@@ -6,4 +6,4 @@ export declare const withDefaultConfig: (config: RsbuildConfig) => RsbuildConfig
6
6
  * 2. Object value that should not be empty.
7
7
  * 3. Meaningful and can be filled by constant value.
8
8
  */
9
- export declare const normalizeConfig: (config: RsbuildConfig) => NormalizedConfig;
9
+ export declare const normalizeConfig: (config: RsbuildConfig) => NormalizedConfig;