@rsbuild/core 0.4.14 → 0.5.0

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 (47) hide show
  1. package/dist/cli/commands.js +1 -1
  2. package/dist/cli/prepare.js +2 -2
  3. package/dist/client/hmr.mjs +449 -230
  4. package/dist/createRsbuild.js +2 -2
  5. package/dist/index.js +1 -1
  6. package/dist/loadEnv.js +7 -7
  7. package/dist/mergeConfig.js +2 -2
  8. package/dist/pluginManager.js +19 -15
  9. package/dist/plugins/basic.js +2 -0
  10. package/dist/plugins/entry.js +2 -2
  11. package/dist/plugins/externals.js +2 -2
  12. package/dist/plugins/fileSize.js +2 -2
  13. package/dist/plugins/html.d.ts +1 -2
  14. package/dist/plugins/html.js +18 -38
  15. package/dist/plugins/moduleFederation.js +2 -2
  16. package/dist/plugins/rsdoctor.js +2 -2
  17. package/dist/plugins/splitChunks.js +4 -4
  18. package/dist/plugins/target.js +10 -12
  19. package/dist/provider/config.js +0 -1
  20. package/dist/provider/createContext.js +1 -1
  21. package/dist/provider/plugins/less.js +2 -2
  22. package/dist/provider/plugins/minimize.js +1 -2
  23. package/dist/provider/plugins/resolve.js +1 -4
  24. package/dist/provider/plugins/sass.js +2 -2
  25. package/dist/provider/plugins/transition.js +9 -1
  26. package/dist/provider/provider.js +6 -9
  27. package/dist/rspack/HtmlBasicPlugin.d.ts +25 -2
  28. package/dist/rspack/HtmlBasicPlugin.js +155 -25
  29. package/dist/rspack/HtmlCrossOriginPlugin.js +4 -8
  30. package/dist/rspack/HtmlNoncePlugin.js +2 -2
  31. package/dist/rspack/InlineChunkHtmlPlugin.js +2 -2
  32. package/dist/rspack/RemoveCssSourcemapPlugin.js +2 -2
  33. package/dist/server/devServer.d.ts +3 -10
  34. package/dist/server/devServer.js +108 -115
  35. package/dist/server/getDevMiddlewares.js +9 -7
  36. package/dist/server/helper.js +2 -2
  37. package/dist/server/index.d.ts +1 -1
  38. package/dist/server/index.js +2 -4
  39. package/dist/server/prodServer.js +2 -2
  40. package/dist/server/socketServer.js +6 -6
  41. package/package.json +5 -5
  42. package/dist/plugins/toml.d.ts +0 -0
  43. package/dist/plugins/toml.js +0 -1
  44. package/dist/plugins/yaml.d.ts +0 -0
  45. package/dist/plugins/yaml.js +0 -1
  46. package/dist/rspack/HtmlTagsPlugin.d.ts +0 -24
  47. package/dist/rspack/HtmlTagsPlugin.js +0 -186
@@ -55,7 +55,7 @@ async function createRsbuild(options) {
55
55
  initConfigs,
56
56
  inspectConfig,
57
57
  createCompiler,
58
- getServerAPIs,
58
+ createDevServer,
59
59
  startDevServer,
60
60
  applyDefaultPlugins
61
61
  } = await provider({
@@ -89,7 +89,7 @@ async function createRsbuild(options) {
89
89
  createCompiler,
90
90
  initConfigs,
91
91
  inspectConfig,
92
- getServerAPIs,
92
+ createDevServer,
93
93
  startDevServer,
94
94
  context: publicContext
95
95
  };
package/dist/index.js CHANGED
@@ -38,7 +38,7 @@ var import_config = require("./config");
38
38
  var import_shared = require("@rsbuild/shared");
39
39
  var import_mergeConfig = require("./mergeConfig");
40
40
  var import_constants = require("./constants");
41
- const version = "0.4.14";
41
+ const version = "0.5.0";
42
42
  // Annotate the CommonJS export names for ESM import in node:
43
43
  0 && (module.exports = {
44
44
  PLUGIN_CSS_NAME,
package/dist/loadEnv.js CHANGED
@@ -54,30 +54,30 @@ function loadEnv({
54
54
  ];
55
55
  const filePaths = filenames.map((filename) => (0, import_node_path.join)(cwd, filename)).filter(import_shared.isFileSync);
56
56
  const parsed = {};
57
- filePaths.forEach((envPath) => {
57
+ for (const envPath of filePaths) {
58
58
  Object.assign(parsed, (0, import_dotenv.parse)(import_node_fs.default.readFileSync(envPath)));
59
- });
59
+ }
60
60
  (0, import_dotenv_expand.expand)({ parsed });
61
61
  const publicVars = {};
62
- Object.keys(process.env).forEach((key) => {
62
+ for (const key of Object.keys(process.env)) {
63
63
  const val = process.env[key];
64
64
  if (val && prefixes.some((prefix) => key.startsWith(prefix))) {
65
65
  publicVars[`process.env.${key}`] = JSON.stringify(val);
66
66
  }
67
- });
67
+ }
68
68
  let cleaned = false;
69
69
  const cleanup = () => {
70
70
  if (cleaned) {
71
71
  return;
72
72
  }
73
- Object.keys(parsed).forEach((key) => {
73
+ for (const key of Object.keys(parsed)) {
74
74
  if (key === "NODE_ENV") {
75
- return;
75
+ continue;
76
76
  }
77
77
  if (process.env[key] === parsed[key]) {
78
78
  delete process.env[key];
79
79
  }
80
- });
80
+ }
81
81
  cleaned = true;
82
82
  };
83
83
  return {
@@ -55,10 +55,10 @@ const merge = (x, y, path = "") => {
55
55
  }
56
56
  const merged = {};
57
57
  const keys = /* @__PURE__ */ new Set([...Object.keys(x), ...Object.keys(y)]);
58
- keys.forEach((key) => {
58
+ for (const key of keys) {
59
59
  const childPath = path ? `${path}.${key}` : key;
60
60
  merged[key] = merge(x[key], y[key], childPath);
61
- });
61
+ }
62
62
  return merged;
63
63
  };
64
64
  const mergeRsbuildConfig = (...configs) => {
@@ -63,9 +63,9 @@ function createPluginManager() {
63
63
  let plugins = [];
64
64
  const addPlugins = (newPlugins, options) => {
65
65
  const { before } = options || {};
66
- newPlugins.forEach((newPlugin) => {
66
+ for (const newPlugin of newPlugins) {
67
67
  if (!newPlugin) {
68
- return;
68
+ continue;
69
69
  }
70
70
  validatePlugin(newPlugin);
71
71
  if (plugins.find((item) => item.name === newPlugin.name)) {
@@ -83,7 +83,7 @@ function createPluginManager() {
83
83
  } else {
84
84
  plugins.push(newPlugin);
85
85
  }
86
- });
86
+ }
87
87
  };
88
88
  const removePlugins = (pluginNames) => {
89
89
  plugins = plugins.filter((plugin) => !pluginNames.includes(plugin.name));
@@ -107,18 +107,22 @@ const pluginDagSort = (plugins) => {
107
107
  }
108
108
  return target;
109
109
  }
110
- plugins.forEach((plugin) => {
111
- plugin.pre?.forEach((pre) => {
112
- if (pre && plugins.some((item) => item.name === pre)) {
113
- allLines.push([pre, plugin.name]);
110
+ for (const plugin of plugins) {
111
+ if (plugin.pre) {
112
+ for (const pre of plugin.pre) {
113
+ if (pre && plugins.some((item) => item.name === pre)) {
114
+ allLines.push([pre, plugin.name]);
115
+ }
114
116
  }
115
- });
116
- plugin.post?.forEach((post) => {
117
- if (post && plugins.some((item) => item.name === post)) {
118
- allLines.push([plugin.name, post]);
117
+ }
118
+ if (plugin.post) {
119
+ for (const post of plugin.post) {
120
+ if (post && plugins.some((item) => item.name === post)) {
121
+ allLines.push([plugin.name, post]);
122
+ }
119
123
  }
120
- });
121
- });
124
+ }
125
+ }
122
126
  let zeroEndPoints = plugins.filter(
123
127
  (item) => !allLines.find((l) => l[1] === item.name)
124
128
  );
@@ -136,10 +140,10 @@ const pluginDagSort = (plugins) => {
136
140
  }
137
141
  if (allLines.length) {
138
142
  const restInRingPoints = {};
139
- allLines.forEach((l) => {
143
+ for (const l of allLines) {
140
144
  restInRingPoints[l[0]] = true;
141
145
  restInRingPoints[l[1]] = true;
142
- });
146
+ }
143
147
  throw new Error(
144
148
  `plugins dependencies has loop: ${Object.keys(restInRingPoints).join(
145
149
  ","
@@ -55,6 +55,8 @@ const pluginBasic = () => ({
55
55
  exportsPresence: "error"
56
56
  }
57
57
  });
58
+ const isMinimize = isProd && config.output.minify !== false;
59
+ chain.optimization.minimize(isMinimize);
58
60
  const usingHMR = (0, import_shared.isUsingHMR)(config, { target, isProd });
59
61
  if (usingHMR) {
60
62
  chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin);
@@ -43,7 +43,7 @@ const pluginEntry = () => ({
43
43
  const { preEntry } = config.source;
44
44
  const entry = target === "web" ? api.context.entry : getEntryObject(config, target);
45
45
  const injectCoreJsEntry = config.output.polyfill === "entry" && !isServer && !isServiceWorker;
46
- Object.keys(entry).forEach((entryName) => {
46
+ for (const entryName of Object.keys(entry)) {
47
47
  const entryPoint = chain.entry(entryName);
48
48
  const addEntry = (item) => {
49
49
  entryPoint.add(item);
@@ -53,7 +53,7 @@ const pluginEntry = () => ({
53
53
  addEntry((0, import_shared.createVirtualModule)('import "core-js";'));
54
54
  }
55
55
  (0, import_shared.castArray)(entry[entryName]).forEach(addEntry);
56
- });
56
+ }
57
57
  }
58
58
  );
59
59
  api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
@@ -32,12 +32,12 @@ function pluginExternals() {
32
32
  }
33
33
  });
34
34
  api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
35
- bundlerConfigs.forEach((config) => {
35
+ for (const config of bundlerConfigs) {
36
36
  const isWebWorker = Array.isArray(config.target) ? config.target.includes("webworker") : config.target === "webworker";
37
37
  if (isWebWorker && config.externals) {
38
38
  delete config.externals;
39
39
  }
40
- });
40
+ }
41
41
  });
42
42
  }
43
43
  };
@@ -130,7 +130,7 @@ async function printFileSizes(config, stats, rootPath) {
130
130
  }
131
131
  let totalSize = 0;
132
132
  let totalGzipSize = 0;
133
- assets.forEach((asset) => {
133
+ for (const asset of assets) {
134
134
  let { sizeLabel } = asset;
135
135
  const { name, folder, gzipSizeLabel } = asset;
136
136
  const fileNameLength = (folder + import_node_path.default.sep + name).length;
@@ -149,7 +149,7 @@ async function printFileSizes(config, stats, rootPath) {
149
149
  }
150
150
  import_shared2.logger.log(` ${fileNameLabel} ${sizeLabel} ${gzipSizeLabel}`);
151
151
  }
152
- });
152
+ }
153
153
  if (config.total !== false) {
154
154
  const totalSizeLabel = `${import_shared2.color.bold(
155
155
  import_shared2.color.blue("Total size:")
@@ -1,4 +1,4 @@
1
- import type { HtmlConfig, RsbuildPluginAPI, NormalizedConfig } from '@rsbuild/shared';
1
+ import type { HtmlConfig, NormalizedConfig } 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;
@@ -12,5 +12,4 @@ export declare function getFavicon(entryName: string, config: {
12
12
  export declare function getMetaTags(entryName: string, config: {
13
13
  html: HtmlConfig;
14
14
  }, templateContent?: string): import("@rsbuild/shared").MetaOptions;
15
- export declare const applyInjectTags: (api: RsbuildPluginAPI) => void;
16
15
  export declare const pluginHtml: () => RsbuildPlugin;
@@ -28,7 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var html_exports = {};
30
30
  __export(html_exports, {
31
- applyInjectTags: () => applyInjectTags,
32
31
  getFavicon: () => getFavicon,
33
32
  getInject: () => getInject,
34
33
  getMetaTags: () => getMetaTags,
@@ -144,39 +143,18 @@ function getChunks(entryName, entryValue) {
144
143
  }
145
144
  return [entryName];
146
145
  }
147
- const applyInjectTags = (api) => {
148
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
149
- const config = api.getNormalizedConfig();
150
- const tags = (0, import_shared.castArray)(config.html.tags).filter(Boolean);
151
- const tagsByEntries = config.html.tagsByEntries || {};
152
- Object.keys(tagsByEntries).forEach((key) => {
153
- tagsByEntries[key] = (0, import_shared.castArray)(tagsByEntries[key]).filter(Boolean);
154
- });
155
- const shouldByEntries = Object.values(tagsByEntries).some(
156
- (entry) => Array.isArray(entry) && entry.length > 0
157
- );
158
- if (!tags.length && !shouldByEntries) {
159
- return;
160
- }
161
- const { HtmlTagsPlugin } = await Promise.resolve().then(() => __toESM(require("../rspack/HtmlTagsPlugin")));
162
- const sharedOptions = {
163
- append: true,
164
- hash: false,
165
- publicPath: true,
166
- tags
167
- };
168
- if (tags.length && !shouldByEntries) {
169
- chain.plugin(CHAIN_ID.PLUGIN.HTML_TAGS).use(HtmlTagsPlugin, [sharedOptions]);
170
- return;
171
- }
172
- for (const [entry, filename] of Object.entries(api.getHTMLPaths())) {
173
- const opts = { ...sharedOptions, includes: [filename] };
174
- if (entry in tagsByEntries) {
175
- opts.tags = tagsByEntries[entry];
176
- }
177
- chain.plugin(`${CHAIN_ID.PLUGIN.HTML_TAGS}#${entry}`).use(HtmlTagsPlugin, [opts]);
178
- }
179
- });
146
+ const getTagConfig = (api) => {
147
+ const config = api.getNormalizedConfig();
148
+ const tags = (0, import_shared.castArray)(config.html.tags).filter(Boolean);
149
+ if (!tags.length) {
150
+ return void 0;
151
+ }
152
+ return {
153
+ append: true,
154
+ hash: false,
155
+ publicPath: true,
156
+ tags
157
+ };
180
158
  };
181
159
  const pluginHtml = () => ({
182
160
  name: "rsbuild:html",
@@ -230,6 +208,10 @@ const pluginHtml = () => ({
230
208
  if (templateContent) {
231
209
  htmlInfo.templateContent = templateContent;
232
210
  }
211
+ const tagConfig = getTagConfig(api);
212
+ if (tagConfig) {
213
+ htmlInfo.tagConfig = tagConfig;
214
+ }
233
215
  pluginOptions.title = getTitle(entryName, config);
234
216
  const favicon = getFavicon(entryName, config);
235
217
  if (favicon) {
@@ -241,7 +223,7 @@ const pluginHtml = () => ({
241
223
  }
242
224
  const finalOptions = (0, import_shared.mergeChainedOptions)({
243
225
  defaults: pluginOptions,
244
- options: config.tools.htmlPlugin,
226
+ options: typeof config.tools.htmlPlugin === "boolean" ? {} : config.tools.htmlPlugin,
245
227
  utils: {
246
228
  entryName,
247
229
  entryValue
@@ -251,7 +233,7 @@ const pluginHtml = () => ({
251
233
  })
252
234
  );
253
235
  const { HtmlBasicPlugin } = await Promise.resolve().then(() => __toESM(require("../rspack/HtmlBasicPlugin")));
254
- chain.plugin(CHAIN_ID.PLUGIN.HTML_BASIC).use(HtmlBasicPlugin, [{ info: htmlInfoMap }]);
236
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_BASIC).use(HtmlBasicPlugin, [htmlInfoMap]);
255
237
  if (config.security) {
256
238
  const { nonce } = config.security;
257
239
  if (nonce) {
@@ -278,12 +260,10 @@ const pluginHtml = () => ({
278
260
  }
279
261
  }
280
262
  );
281
- applyInjectTags(api);
282
263
  }
283
264
  });
284
265
  // Annotate the CommonJS export names for ESM import in node:
285
266
  0 && (module.exports = {
286
- applyInjectTags,
287
267
  getFavicon,
288
268
  getInject,
289
269
  getMetaTags,
@@ -89,9 +89,9 @@ class PatchSplitChunksPlugin {
89
89
  if (!cacheGroups) {
90
90
  return;
91
91
  }
92
- Object.keys(cacheGroups).forEach((cacheGroupKey) => {
92
+ for (const cacheGroupKey of Object.keys(cacheGroups)) {
93
93
  applyPatch(cacheGroups[cacheGroupKey]);
94
- });
94
+ }
95
95
  }
96
96
  }
97
97
  function pluginModuleFederation() {
@@ -58,7 +58,7 @@ const pluginRsdoctor = () => ({
58
58
  return;
59
59
  }
60
60
  let isAutoRegister = false;
61
- bundlerConfigs.forEach((config) => {
61
+ for (const config of bundlerConfigs) {
62
62
  const registered = config.plugins?.some(
63
63
  (plugin) => plugin?.constructor?.name === pluginName
64
64
  );
@@ -68,7 +68,7 @@ const pluginRsdoctor = () => ({
68
68
  config.plugins || (config.plugins = []);
69
69
  config.plugins.push(new module2[pluginName]());
70
70
  isAutoRegister = true;
71
- });
71
+ }
72
72
  if (isAutoRegister) {
73
73
  import_shared.logger.info(`${import_shared.color.bold(import_shared.color.yellow(packageName))} enabled.`);
74
74
  }
@@ -40,7 +40,7 @@ function getUserDefinedCacheGroups(forceSplitting) {
40
40
  const pairs = Array.isArray(forceSplitting) ? forceSplitting.map(
41
41
  (regexp, index) => [`force-split-${index}`, regexp]
42
42
  ) : Object.entries(forceSplitting);
43
- pairs.forEach(([key, regexp]) => {
43
+ for (const [key, regexp] of pairs) {
44
44
  cacheGroups[key] = {
45
45
  test: regexp,
46
46
  name: key,
@@ -48,7 +48,7 @@ function getUserDefinedCacheGroups(forceSplitting) {
48
48
  // Ignore minimum size, minimum chunks and maximum requests and always create chunks for user defined cache group.
49
49
  enforce: true
50
50
  };
51
- });
51
+ }
52
52
  return cacheGroups;
53
53
  }
54
54
  function splitByExperience(ctx) {
@@ -66,7 +66,7 @@ function splitByExperience(ctx) {
66
66
  "@swc/helpers"
67
67
  );
68
68
  }
69
- Object.entries(packageRegExps).forEach(([name, test]) => {
69
+ for (const [name, test] of Object.entries(packageRegExps)) {
70
70
  const key = `lib-${name}`;
71
71
  experienceCacheGroup[key] = {
72
72
  test,
@@ -74,7 +74,7 @@ function splitByExperience(ctx) {
74
74
  name: key,
75
75
  reuseExistingChunk: true
76
76
  };
77
- });
77
+ }
78
78
  return {
79
79
  ...defaultConfig,
80
80
  ...override,
@@ -30,20 +30,18 @@ const pluginTarget = () => ({
30
30
  chain.target("node");
31
31
  return;
32
32
  }
33
- if (target === "service-worker") {
34
- chain.target("webworker");
33
+ const config = api.getNormalizedConfig();
34
+ const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
35
+ api.context.rootPath,
36
+ config,
37
+ target
38
+ );
39
+ const esVersion = (0, import_shared.browserslistToESVersion)(browserslist);
40
+ if (target === "web-worker" || target === "service-worker") {
41
+ chain.target(["webworker", `es${esVersion}`]);
35
42
  return;
36
43
  }
37
- if (target === "web-worker") {
38
- chain.target(["webworker", "es5"]);
39
- return;
40
- }
41
- const browserslist = await (0, import_shared.getBrowserslist)(api.context.rootPath);
42
- if (browserslist) {
43
- chain.merge({ target: ["web", "browserslist"] });
44
- } else {
45
- chain.merge({ target: ["web", "es5"] });
46
- }
44
+ chain.target(["web", `es${esVersion}`]);
47
45
  });
48
46
  }
49
47
  });
@@ -110,7 +110,6 @@ const getDefaultOutputConfig = () => ({
110
110
  },
111
111
  legalComments: "linked",
112
112
  injectStyles: false,
113
- disableMinimize: false,
114
113
  minify: true,
115
114
  sourceMap: {
116
115
  js: void 0,
@@ -44,7 +44,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
44
44
  const context = {
45
45
  entry: (0, import_entry.getEntryObject)(config, "web"),
46
46
  targets: config.output?.targets || [],
47
- version: "0.4.14",
47
+ version: "0.5.0",
48
48
  rootPath,
49
49
  distPath,
50
50
  cachePath,
@@ -45,9 +45,9 @@ function pluginLess() {
45
45
  config.output.sourceMap.css,
46
46
  api.context.rootPath
47
47
  );
48
- excludes.forEach((item) => {
48
+ for (const item of excludes) {
49
49
  rule.exclude.add(item);
50
- });
50
+ }
51
51
  await applyBaseCSSRule({
52
52
  rule,
53
53
  utils,
@@ -37,8 +37,7 @@ const pluginMinimize = () => ({
37
37
  setup(api) {
38
38
  api.modifyBundlerChain(async (chain, { isProd }) => {
39
39
  const config = api.getNormalizedConfig();
40
- const isMinimize = isProd && config.output.minify && !config.output.disableMinimize;
41
- chain.optimization.minimize(isMinimize);
40
+ const isMinimize = isProd && config.output.minify !== false;
42
41
  if (!isMinimize) {
43
42
  return;
44
43
  }
@@ -26,16 +26,13 @@ const pluginResolve = () => ({
26
26
  name: "rsbuild:resolve",
27
27
  setup(api) {
28
28
  (0, import_shared.applyResolvePlugin)(api);
29
- api.modifyRspackConfig(async (rspackConfig, { isServer }) => {
29
+ api.modifyRspackConfig(async (rspackConfig) => {
30
30
  const isTsProject = Boolean(api.context.tsconfigPath);
31
31
  const config = api.getNormalizedConfig();
32
32
  rspackConfig.resolve || (rspackConfig.resolve = {});
33
33
  if (isTsProject && config.source.aliasStrategy === "prefer-tsconfig") {
34
34
  rspackConfig.resolve.tsConfigPath = api.context.tsconfigPath;
35
35
  }
36
- if (isServer) {
37
- rspackConfig.resolve.conditionNames = ["require", "node"];
38
- }
39
36
  });
40
37
  }
41
38
  });
@@ -49,9 +49,9 @@ function pluginSass() {
49
49
  true
50
50
  );
51
51
  const rule = chain.module.rule(utils.CHAIN_ID.RULE.SASS).test(import_shared.SASS_REGEX);
52
- excludes.forEach((item) => {
52
+ for (const item of excludes) {
53
53
  rule.exclude.add(item);
54
- });
54
+ }
55
55
  await applyBaseCSSRule({
56
56
  rule,
57
57
  utils,
@@ -23,10 +23,18 @@ __export(transition_exports, {
23
23
  module.exports = __toCommonJS(transition_exports);
24
24
  const pluginTransition = () => ({
25
25
  name: "rsbuild:transition",
26
- setup() {
26
+ setup(api) {
27
27
  var _a;
28
28
  process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
29
29
  (_a = process.env).WATCHPACK_WATCHER_LIMIT || (_a.WATCHPACK_WATCHER_LIMIT = "20");
30
+ api.modifyRspackConfig((config, { isProd }) => {
31
+ var _a2;
32
+ if (isProd) {
33
+ config.experiments || (config.experiments = {});
34
+ (_a2 = config.experiments).rspackFuture || (_a2.rspackFuture = {});
35
+ config.experiments.rspackFuture.newTreeshaking = true;
36
+ }
37
+ });
30
38
  }
31
39
  });
32
40
  // Annotate the CommonJS export names for ESM import in node:
@@ -65,25 +65,22 @@ const rspackProvider = async ({
65
65
  async applyDefaultPlugins() {
66
66
  pluginManager.addPlugins(await (0, import_shared2.applyDefaultPlugins)(plugins));
67
67
  },
68
- async getServerAPIs(options) {
69
- const { getServerAPIs } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
68
+ async createDevServer(options) {
69
+ const { createDevServer } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
70
70
  const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./createCompiler")));
71
71
  await (0, import_initConfigs.initRsbuildConfig)({ context, pluginManager });
72
- return getServerAPIs(
72
+ return createDevServer(
73
73
  { context, pluginManager, rsbuildOptions },
74
74
  createDevMiddleware,
75
75
  options
76
76
  );
77
77
  },
78
78
  async startDevServer(options) {
79
- const { startDevServer } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
79
+ const { createDevServer } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
80
80
  const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./createCompiler")));
81
81
  await (0, import_initConfigs.initRsbuildConfig)({ context, pluginManager });
82
- return startDevServer(
83
- { context, pluginManager, rsbuildOptions },
84
- createDevMiddleware,
85
- options
86
- );
82
+ const server = await createDevServer({ context, pluginManager, rsbuildOptions }, createDevMiddleware, options);
83
+ return server.listen();
87
84
  },
88
85
  async preview(options) {
89
86
  const { startProdServer } = await Promise.resolve().then(() => __toESM(require("../server/prodServer")));
@@ -1,10 +1,33 @@
1
+ import type HtmlWebpackPlugin from 'html-webpack-plugin';
2
+ import type { HtmlTagObject } from 'html-webpack-plugin';
1
3
  import type { Compiler } from '@rspack/core';
4
+ import { type HtmlTag, type HtmlTagDescriptor } from '@rsbuild/shared';
5
+ export type TagConfig = {
6
+ tags?: HtmlTagDescriptor[];
7
+ hash?: HtmlTag['hash'];
8
+ append?: HtmlTag['append'];
9
+ publicPath?: HtmlTag['publicPath'];
10
+ };
11
+ /** @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Void_element} */
12
+ export declare const VOID_TAGS: string[];
13
+ /** @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head#see_also} */
14
+ export declare const HEAD_TAGS: string[];
15
+ export declare const FILE_ATTRS: {
16
+ link: string;
17
+ script: string;
18
+ };
2
19
  export type HtmlInfo = {
3
20
  favicon?: string;
21
+ tagConfig?: TagConfig;
4
22
  templateContent?: string;
5
23
  };
6
- export type HtmlBasicPluginOptions = {
7
- info: Record<string, HtmlInfo>;
24
+ export type HtmlBasicPluginOptions = Record<string, HtmlInfo>;
25
+ export type AlterAssetTagGroupsData = {
26
+ headTags: HtmlTagObject[];
27
+ bodyTags: HtmlTagObject[];
28
+ outputName: string;
29
+ publicPath: string;
30
+ plugin: HtmlWebpackPlugin;
8
31
  };
9
32
  export declare const hasTitle: (html?: string) => boolean;
10
33
  export declare class HtmlBasicPlugin {