@rsbuild/core 0.2.18 → 0.3.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 (65) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/commands.js +5 -5
  3. package/dist/cli/prepare.js +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/plugins/asset.js +1 -1
  6. package/dist/plugins/basic.js +27 -21
  7. package/dist/plugins/entry.js +2 -2
  8. package/dist/plugins/fileSize.js +1 -2
  9. package/dist/plugins/html.js +6 -4
  10. package/dist/plugins/index.js +0 -2
  11. package/dist/plugins/moment.js +6 -0
  12. package/dist/plugins/networkPerformance.js +1 -1
  13. package/dist/plugins/preloadOrPrefetch.js +1 -1
  14. package/dist/plugins/server.js +1 -1
  15. package/dist/plugins/toml.d.ts +0 -2
  16. package/dist/plugins/toml.js +0 -35
  17. package/dist/plugins/yaml.d.ts +0 -2
  18. package/dist/plugins/yaml.js +0 -35
  19. package/dist/provider/core/build.d.ts +3 -15
  20. package/dist/provider/core/build.js +20 -25
  21. package/dist/provider/core/createCompiler.js +3 -3
  22. package/dist/provider/core/createContext.d.ts +1 -1
  23. package/dist/provider/core/createContext.js +1 -1
  24. package/dist/provider/core/initConfigs.js +3 -3
  25. package/dist/provider/core/initHooks.d.ts +15 -15
  26. package/dist/provider/core/initHooks.js +15 -15
  27. package/dist/provider/core/initPlugins.js +16 -16
  28. package/dist/provider/core/rspackConfig.js +1 -1
  29. package/dist/provider/css-modules-typescript-pre-loader/index.d.ts +1 -1
  30. package/dist/provider/css-modules-typescript-pre-loader/index.js +1 -1
  31. package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.js +0 -1
  32. package/dist/provider/plugins/swc.js +6 -0
  33. package/dist/provider/plugins/transition.js +1 -14
  34. package/dist/provider/provider.js +15 -18
  35. package/dist/provider/shared.d.ts +3 -3
  36. package/dist/provider/shared.js +3 -5
  37. package/dist/rspack/HtmlAppIconPlugin.js +8 -0
  38. package/dist/rspack/HtmlBasicPlugin.js +7 -0
  39. package/dist/rspack/HtmlCrossOriginPlugin.js +13 -6
  40. package/dist/rspack/HtmlNetworkPerformancePlugin.js +7 -0
  41. package/dist/rspack/HtmlNoncePlugin.js +10 -1
  42. package/dist/rspack/HtmlTagsPlugin.js +17 -5
  43. package/dist/rspack/InlineChunkHtmlPlugin.js +10 -0
  44. package/dist/rspack/RemoveCssSourcemapPlugin.js +6 -0
  45. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +9 -1
  46. package/dist/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +1 -1
  47. package/dist/rspack/preload/helpers/extractChunks.d.ts +1 -1
  48. package/dist/rspack/preload/helpers/extractChunks.js +2 -1
  49. package/dist/server/compilerDevMiddleware.js +10 -0
  50. package/dist/server/devServer.d.ts +2 -2
  51. package/dist/server/devServer.js +10 -24
  52. package/dist/server/getDevMiddlewares.js +1 -1
  53. package/dist/server/helper.d.ts +3 -4
  54. package/dist/server/helper.js +47 -29
  55. package/dist/server/middlewares.js +4 -5
  56. package/dist/server/prodServer.d.ts +1 -1
  57. package/dist/server/prodServer.js +13 -6
  58. package/dist/server/socketServer.js +10 -2
  59. package/package.json +5 -4
  60. package/compiled/toml-loader/index.d.ts +0 -1
  61. package/compiled/toml-loader/index.js +0 -1
  62. package/compiled/toml-loader/license +0 -22
  63. package/compiled/toml-loader/package.json +0 -1
  64. package/dist/provider/plugins/hmr.d.ts +0 -2
  65. package/dist/provider/plugins/hmr.js +0 -38
@@ -59,7 +59,7 @@ async function processCss(inputSource, {
59
59
  postcssICSSExtractPlugin(parserOptions)
60
60
  ]);
61
61
  await pipeline.process(inputSource, {
62
- from: `/fake-css-modules-loader`,
62
+ from: "/fake-css-modules-loader",
63
63
  to: void 0
64
64
  });
65
65
  return {
@@ -40,7 +40,6 @@ const getExportLocalsConvention = (name, exportLocalsConventionType) => {
40
40
  case "dashesOnly": {
41
41
  return [dashesCamelCase(name)];
42
42
  }
43
- case "asIs":
44
43
  default:
45
44
  return [name];
46
45
  }
@@ -75,6 +75,12 @@ const pluginSwc = () => ({
75
75
  );
76
76
  applyTransformImport(swcConfig, config.source.transformImport);
77
77
  applyDecorator(swcConfig, config.output.enableLatestDecorators);
78
+ if (swcConfig.jsc?.externalHelpers) {
79
+ chain.resolve.alias.set(
80
+ "@swc/helpers",
81
+ import_path.default.dirname(require.resolve("@swc/helpers/package.json"))
82
+ );
83
+ }
78
84
  if ((0, import_shared.isWebTarget)(target)) {
79
85
  const polyfillMode = config.output.polyfill;
80
86
  if (polyfillMode === "off" || polyfillMode === "ua") {
@@ -21,23 +21,10 @@ __export(transition_exports, {
21
21
  pluginTransition: () => pluginTransition
22
22
  });
23
23
  module.exports = __toCommonJS(transition_exports);
24
- var import_shared = require("@rsbuild/shared");
25
24
  const pluginTransition = () => ({
26
25
  name: "rsbuild:transition",
27
- setup(api) {
26
+ setup() {
28
27
  process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
29
- api.modifyBundlerChain(async (chain, { isProd }) => {
30
- if (isProd) {
31
- chain.optimization.chunkIds("deterministic");
32
- }
33
- });
34
- api.modifyRspackConfig((config) => {
35
- (0, import_shared.setConfig)(
36
- config,
37
- "experiments.rspackFuture.disableApplyEntryLazily",
38
- true
39
- );
40
- });
41
28
  }
42
29
  });
43
30
  // Annotate the CommonJS export names for ESM import in node:
@@ -45,25 +45,26 @@ const rspackProvider = async ({
45
45
  const context = await (0, import_createContext.createContext)(rsbuildOptions, rsbuildConfig, "rspack");
46
46
  const pluginAPI = (0, import_initPlugins.getPluginAPI)({ context, pluginStore });
47
47
  context.pluginAPI = pluginAPI;
48
+ const createCompiler = async () => {
49
+ const { createCompiler: createCompiler2 } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
50
+ const { rspackConfigs } = await (0, import_initConfigs.initConfigs)({
51
+ context,
52
+ pluginStore,
53
+ rsbuildOptions
54
+ });
55
+ return createCompiler2({
56
+ context,
57
+ rspackConfigs
58
+ });
59
+ };
48
60
  return {
49
61
  bundler: "rspack",
50
62
  pluginAPI,
63
+ createCompiler,
51
64
  publicContext: (0, import_createContext.createPublicContext)(context),
52
65
  async applyDefaultPlugins() {
53
66
  pluginStore.addPlugins(await (0, import_shared2.applyDefaultPlugins)(plugins));
54
67
  },
55
- async createCompiler() {
56
- const { createCompiler } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
57
- const { rspackConfigs } = await (0, import_initConfigs.initConfigs)({
58
- context,
59
- pluginStore,
60
- rsbuildOptions
61
- });
62
- return createCompiler({
63
- context,
64
- rspackConfigs
65
- });
66
- },
67
68
  async getServerAPIs(options) {
68
69
  const { getServerAPIs } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
69
70
  const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
@@ -90,12 +91,8 @@ const rspackProvider = async ({
90
91
  return startProdServer(context, context.config, options);
91
92
  },
92
93
  async build(options) {
93
- const { build: buildImpl, rspackBuild } = await Promise.resolve().then(() => __toESM(require("./core/build")));
94
- return buildImpl(
95
- { context, pluginStore, rsbuildOptions },
96
- options,
97
- rspackBuild
98
- );
94
+ const { build } = await Promise.resolve().then(() => __toESM(require("./core/build")));
95
+ return build({ context, pluginStore, rsbuildOptions }, options);
99
96
  },
100
97
  async initConfigs() {
101
98
  const { rspackConfigs } = await (0, import_initConfigs.initConfigs)({
@@ -1,7 +1,7 @@
1
- import { RsbuildPlugin } from '../types';
1
+ import type { RsbuildPlugin } from '../types';
2
2
  import { type Plugins } from '@rsbuild/shared';
3
3
  export declare const applyDefaultPlugins: (plugins: Plugins) => import("@rsbuild/shared").AwaitableGetter<RsbuildPlugin>;
4
- export declare const rspackMinVersion = "0.4.0";
5
- export declare const isSatisfyRspackVersion: (version: string) => Promise<boolean>;
4
+ export declare const rspackMinVersion = "0.5.0";
5
+ export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
6
6
  export declare const getCompiledPath: (packageName: string) => string;
7
7
  export declare const BUILTIN_LOADER = "builtin:";
@@ -60,12 +60,9 @@ const applyDefaultPlugins = (plugins) => (0, import_shared3.awaitableGetter)([
60
60
  Promise.resolve().then(() => __toESM(require("./plugins/less"))).then((m) => m.pluginLess()),
61
61
  Promise.resolve().then(() => __toESM(require("./plugins/sass"))).then((m) => m.pluginSass()),
62
62
  Promise.resolve().then(() => __toESM(require("./plugins/minimize"))).then((m) => m.pluginMinimize()),
63
- Promise.resolve().then(() => __toESM(require("./plugins/hmr"))).then((m) => m.pluginHMR()),
64
63
  Promise.resolve().then(() => __toESM(require("./plugins/progress"))).then((m) => m.pluginProgress()),
65
64
  Promise.resolve().then(() => __toESM(require("./plugins/swc"))).then((m) => m.pluginSwc()),
66
65
  plugins.externals(),
67
- plugins.toml(),
68
- plugins.yaml(),
69
66
  plugins.splitChunks(),
70
67
  plugins.startUrl(),
71
68
  plugins.inlineChunk(),
@@ -76,7 +73,7 @@ const applyDefaultPlugins = (plugins) => (0, import_shared3.awaitableGetter)([
76
73
  plugins.server(),
77
74
  Promise.resolve().then(() => __toESM(require("./plugins/rspackProfile"))).then((m) => m.pluginRspackProfile())
78
75
  ]);
79
- const rspackMinVersion = "0.4.0";
76
+ const rspackMinVersion = "0.5.0";
80
77
  const compareSemver = (version1, version2) => {
81
78
  const parts1 = version1.split(".").map(Number);
82
79
  const parts2 = version2.split(".").map(Number);
@@ -93,7 +90,8 @@ const compareSemver = (version1, version2) => {
93
90
  }
94
91
  return 0;
95
92
  };
96
- const isSatisfyRspackVersion = async (version) => {
93
+ const isSatisfyRspackVersion = async (originalVersion) => {
94
+ let version = originalVersion;
97
95
  if (version.includes("-canary")) {
98
96
  version = version.split("-canary")[0];
99
97
  }
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
9
  var __export = (target, all) => {
9
10
  for (var name in all)
10
11
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -26,6 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  mod
27
28
  ));
28
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var __publicField = (obj, key, value) => {
31
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
+ return value;
33
+ };
29
34
  var HtmlAppIconPlugin_exports = {};
30
35
  __export(HtmlAppIconPlugin_exports, {
31
36
  HtmlAppIconPlugin: () => HtmlAppIconPlugin
@@ -38,6 +43,9 @@ var import_shared = require("@rsbuild/shared");
38
43
  var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
39
44
  class HtmlAppIconPlugin {
40
45
  constructor(options) {
46
+ __publicField(this, "name");
47
+ __publicField(this, "distDir");
48
+ __publicField(this, "iconPath");
41
49
  this.name = "HtmlAppIconPlugin";
42
50
  this.distDir = options.distDir;
43
51
  this.iconPath = options.iconPath;
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
19
24
  var HtmlBasicPlugin_exports = {};
20
25
  __export(HtmlBasicPlugin_exports, {
21
26
  HtmlBasicPlugin: () => HtmlBasicPlugin,
@@ -26,6 +31,8 @@ var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
26
31
  const hasTitle = (html) => html ? /<title/i.test(html) && /<\/title/i.test(html) : false;
27
32
  class HtmlBasicPlugin {
28
33
  constructor(options) {
34
+ __publicField(this, "name");
35
+ __publicField(this, "options");
29
36
  this.name = "HtmlBasicPlugin";
30
37
  this.options = options;
31
38
  }
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
19
24
  var HtmlCrossOriginPlugin_exports = {};
20
25
  __export(HtmlCrossOriginPlugin_exports, {
21
26
  HtmlCrossOriginPlugin: () => HtmlCrossOriginPlugin
@@ -24,6 +29,8 @@ module.exports = __toCommonJS(HtmlCrossOriginPlugin_exports);
24
29
  var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
25
30
  class HtmlCrossOriginPlugin {
26
31
  constructor(options) {
32
+ __publicField(this, "name");
33
+ __publicField(this, "crossOrigin");
27
34
  const { crossOrigin } = options;
28
35
  this.name = "HtmlCrossOriginPlugin";
29
36
  this.crossOrigin = crossOrigin;
@@ -39,12 +46,12 @@ class HtmlCrossOriginPlugin {
39
46
  const {
40
47
  assetTags: { scripts, styles }
41
48
  } = alterAssetTags;
42
- scripts.forEach(
43
- (script) => script.attributes.crossorigin = this.crossOrigin
44
- );
45
- styles.forEach(
46
- (style) => style.attributes.crossorigin = this.crossOrigin
47
- );
49
+ scripts.forEach((script) => {
50
+ script.attributes.crossorigin = this.crossOrigin;
51
+ });
52
+ styles.forEach((style) => {
53
+ style.attributes.crossorigin = this.crossOrigin;
54
+ });
48
55
  return alterAssetTags;
49
56
  });
50
57
  });
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
19
24
  var HtmlNetworkPerformancePlugin_exports = {};
20
25
  __export(HtmlNetworkPerformancePlugin_exports, {
21
26
  HtmlNetworkPerformancePlugin: () => HtmlNetworkPerformancePlugin
@@ -40,6 +45,8 @@ function generateLinks(options, type) {
40
45
  }
41
46
  class HtmlNetworkPerformancePlugin {
42
47
  constructor(options, type) {
48
+ __publicField(this, "options");
49
+ __publicField(this, "type");
43
50
  this.options = options;
44
51
  this.type = type;
45
52
  }
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
19
24
  var HtmlNoncePlugin_exports = {};
20
25
  __export(HtmlNoncePlugin_exports, {
21
26
  HtmlNoncePlugin: () => HtmlNoncePlugin
@@ -24,6 +29,8 @@ module.exports = __toCommonJS(HtmlNoncePlugin_exports);
24
29
  var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
25
30
  class HtmlNoncePlugin {
26
31
  constructor(options) {
32
+ __publicField(this, "name");
33
+ __publicField(this, "nonce");
27
34
  const { nonce } = options;
28
35
  this.name = "HtmlNoncePlugin";
29
36
  this.nonce = nonce;
@@ -37,7 +44,9 @@ class HtmlNoncePlugin {
37
44
  const {
38
45
  assetTags: { scripts }
39
46
  } = alterAssetTags;
40
- scripts.forEach((script) => script.attributes.nonce = this.nonce);
47
+ scripts.forEach((script) => {
48
+ script.attributes.nonce = this.nonce;
49
+ });
41
50
  return alterAssetTags;
42
51
  });
43
52
  });
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
19
24
  var HtmlTagsPlugin_exports = {};
20
25
  __export(HtmlTagsPlugin_exports, {
21
26
  FILE_ATTRS: () => FILE_ATTRS,
@@ -60,8 +65,9 @@ const FILE_ATTRS = {
60
65
  const withHash = (url, hash) => `${url}?${hash}`;
61
66
  class HtmlTagsPlugin {
62
67
  constructor(opts) {
63
- this.name = "HtmlTagsPlugin";
64
- this.meta = { plugin: this.name };
68
+ __publicField(this, "name", "HtmlTagsPlugin");
69
+ __publicField(this, "meta", { plugin: this.name });
70
+ __publicField(this, "ctx");
65
71
  this.ctx = {
66
72
  append: true,
67
73
  ...opts
@@ -106,11 +112,17 @@ class HtmlTagsPlugin {
106
112
  }
107
113
  const optHash = tag.hash ?? this.ctx.hash;
108
114
  if (typeof optHash === "function") {
109
- compilationHash.length && (filename = optHash(filename, compilationHash));
115
+ if (compilationHash.length) {
116
+ filename = optHash(filename, compilationHash);
117
+ }
110
118
  } else if (typeof optHash === "string") {
111
- optHash.length && (filename = withHash(filename, optHash));
119
+ if (optHash.length) {
120
+ filename = withHash(filename, optHash);
121
+ }
112
122
  } else if (optHash === true) {
113
- compilationHash.length && (filename = withHash(filename, compilationHash));
123
+ if (compilationHash.length) {
124
+ filename = withHash(filename, compilationHash);
125
+ }
114
126
  }
115
127
  attrs[filenameTag] = filename;
116
128
  }
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
19
24
  var InlineChunkHtmlPlugin_exports = {};
20
25
  __export(InlineChunkHtmlPlugin_exports, {
21
26
  InlineChunkHtmlPlugin: () => InlineChunkHtmlPlugin
@@ -30,6 +35,11 @@ class InlineChunkHtmlPlugin {
30
35
  scriptTests,
31
36
  distPath
32
37
  }) {
38
+ __publicField(this, "name");
39
+ __publicField(this, "styleTests");
40
+ __publicField(this, "scriptTests");
41
+ __publicField(this, "distPath");
42
+ __publicField(this, "inlinedAssets");
33
43
  this.name = "InlineChunkHtmlPlugin";
34
44
  this.styleTests = styleTests;
35
45
  this.scriptTests = scriptTests;
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
19
24
  var RemoveCssSourcemapPlugin_exports = {};
20
25
  __export(RemoveCssSourcemapPlugin_exports, {
21
26
  RemoveCssSourcemapPlugin: () => RemoveCssSourcemapPlugin
@@ -23,6 +28,7 @@ __export(RemoveCssSourcemapPlugin_exports, {
23
28
  module.exports = __toCommonJS(RemoveCssSourcemapPlugin_exports);
24
29
  class RemoveCssSourcemapPlugin {
25
30
  constructor() {
31
+ __publicField(this, "name");
26
32
  this.name = "RemoveCssSourcemapPlugin";
27
33
  }
28
34
  apply(compiler) {
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => {
21
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
+ return value;
23
+ };
19
24
  var HtmlPreloadOrPrefetchPlugin_exports = {};
20
25
  __export(HtmlPreloadOrPrefetchPlugin_exports, {
21
26
  HtmlPreloadOrPrefetchPlugin: () => HtmlPreloadOrPrefetchPlugin
@@ -119,7 +124,10 @@ function generateLinks(options, type, compilation, htmlPluginData, HTMLCount) {
119
124
  }
120
125
  class HtmlPreloadOrPrefetchPlugin {
121
126
  constructor(options, type, HTMLCount) {
122
- this.resourceHints = [];
127
+ __publicField(this, "options");
128
+ __publicField(this, "resourceHints", []);
129
+ __publicField(this, "type");
130
+ __publicField(this, "HTMLCount");
123
131
  this.options = {
124
132
  ...defaultOptions,
125
133
  ...typeof options === "boolean" ? {} : options
@@ -17,7 +17,7 @@
17
17
  import type { Compilation } from '@rspack/core';
18
18
  import type { Chunk } from 'webpack';
19
19
  import type { PreloadOrPreFetchOption } from '@rsbuild/shared';
20
- import { BeforeAssetTagGenerationHtmlPluginData } from './type';
20
+ import type { BeforeAssetTagGenerationHtmlPluginData } from './type';
21
21
  interface DoesChunkBelongToHtmlOptions {
22
22
  chunk: Chunk;
23
23
  compilation?: Compilation;
@@ -14,7 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { Chunk, Compilation } from 'webpack';
17
+ import type { Chunk, Compilation } from 'webpack';
18
18
  import type { PreloadIncludeType } from '@rsbuild/shared';
19
19
  export type ChunkGroup = Compilation['chunkGroups'][0];
20
20
  interface ExtractChunks {
@@ -40,7 +40,8 @@ module.exports = __toCommonJS(extractChunks_exports);
40
40
  function isAsync(chunk) {
41
41
  if ("canBeInitial" in chunk) {
42
42
  return !chunk.canBeInitial();
43
- } else if ("isInitial" in chunk) {
43
+ }
44
+ if ("isInitial" in chunk) {
44
45
  return !chunk.isInitial();
45
46
  }
46
47
  return !chunk.initial;
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
9
  var __export = (target, all) => {
9
10
  for (var name in all)
10
11
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -26,6 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  mod
27
28
  ));
28
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var __publicField = (obj, key, value) => {
31
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
+ return value;
33
+ };
29
34
  var compilerDevMiddleware_exports = {};
30
35
  __export(compilerDevMiddleware_exports, {
31
36
  CompilerDevMiddleware: () => CompilerDevMiddleware
@@ -44,6 +49,11 @@ function getHMRClientPath(client) {
44
49
  }
45
50
  class CompilerDevMiddleware {
46
51
  constructor({ dev, devMiddleware, publicPaths }) {
52
+ __publicField(this, "middleware");
53
+ __publicField(this, "devOptions");
54
+ __publicField(this, "devMiddleware");
55
+ __publicField(this, "publicPaths");
56
+ __publicField(this, "socketServer");
47
57
  this.devOptions = dev;
48
58
  this.publicPaths = publicPaths;
49
59
  this.socketServer = new import_socketServer.SocketServer(dev);
@@ -1,4 +1,4 @@
1
- import { StartServerResult, type DevServerAPIs, type StartDevServerOptions, type CreateDevMiddlewareReturns } from '@rsbuild/shared';
1
+ import { type DevServerAPIs, type StartServerResult, type StartDevServerOptions, type CreateDevMiddlewareReturns } from '@rsbuild/shared';
2
2
  import type { InternalContext } from '../types';
3
3
  export declare function getServerAPIs<Options extends {
4
4
  context: InternalContext;
@@ -7,6 +7,6 @@ export declare function getServerAPIs<Options extends {
7
7
  }): Promise<DevServerAPIs>;
8
8
  export declare function startDevServer<Options extends {
9
9
  context: InternalContext;
10
- }>(options: Options, createDevMiddleware: (options: Options, compiler: StartDevServerOptions['compiler']) => Promise<CreateDevMiddlewareReturns>, { compiler, printURLs, logger: customLogger, getPortSilently, }?: StartDevServerOptions & {
10
+ }>(options: Options, createDevMiddleware: (options: Options, compiler: StartDevServerOptions['compiler']) => Promise<CreateDevMiddlewareReturns>, { compiler, getPortSilently, }?: StartDevServerOptions & {
11
11
  defaultPort?: number;
12
12
  }): Promise<StartServerResult>;
@@ -64,10 +64,10 @@ async function getServerAPIs(options, createDevMiddleware, {
64
64
  return {
65
65
  config: { devServerConfig, port, host, https, defaultRoutes },
66
66
  beforeStart: async () => {
67
- await options.context.hooks.onBeforeStartDevServerHook.call();
67
+ await options.context.hooks.onBeforeStartDevServer.call();
68
68
  },
69
69
  afterStart: async (params = {}) => {
70
- await options.context.hooks.onAfterStartDevServerHook.call({
70
+ await options.context.hooks.onAfterStartDevServer.call({
71
71
  port: params.port || port,
72
72
  routes: params.routes || defaultRoutes
73
73
  });
@@ -112,21 +112,16 @@ async function getServerAPIs(options, createDevMiddleware, {
112
112
  }
113
113
  async function startDevServer(options, createDevMiddleware, {
114
114
  compiler,
115
- printURLs = true,
116
- logger: customLogger,
117
115
  getPortSilently
118
116
  } = {}) {
119
117
  (0, import_shared.debug)("create dev server");
120
118
  const serverAPIs = await getServerAPIs(options, createDevMiddleware, {
121
119
  compiler,
122
- printURLs,
123
- logger: customLogger,
124
120
  getPortSilently
125
121
  });
126
122
  const {
127
123
  config: { devServerConfig, port, host, https, defaultRoutes }
128
124
  } = serverAPIs;
129
- const logger = customLogger ?? import_shared.logger;
130
125
  const middlewares = (0, import_connect.default)();
131
126
  const httpServer = await (0, import_httpServer.createHttpServer)({
132
127
  https: devServerConfig.https,
@@ -134,23 +129,14 @@ async function startDevServer(options, createDevMiddleware, {
134
129
  });
135
130
  (0, import_shared.debug)("create dev server done");
136
131
  const protocol = https ? "https" : "http";
137
- let urls = (0, import_shared.getAddressUrls)(protocol, port, host);
138
- if (printURLs) {
139
- if ((0, import_shared.isFunction)(printURLs)) {
140
- urls = printURLs(urls);
141
- if (!Array.isArray(urls)) {
142
- throw new Error("Please return an array in the `printURLs` function.");
143
- }
144
- }
145
- (0, import_helper.printServerURLs)({
146
- urls,
147
- port,
148
- routes: defaultRoutes,
149
- logger,
150
- protocol,
151
- printUrls: devServerConfig.printUrls
152
- });
153
- }
132
+ const urls = (0, import_shared.getAddressUrls)({ protocol, port, host });
133
+ (0, import_helper.printServerURLs)({
134
+ urls,
135
+ port,
136
+ routes: defaultRoutes,
137
+ protocol,
138
+ printUrls: devServerConfig.printUrls
139
+ });
154
140
  const compileMiddlewareAPI = await serverAPIs.startCompile();
155
141
  const devMiddlewares = await serverAPIs.getMiddlewares({
156
142
  compileMiddlewareAPI
@@ -99,7 +99,7 @@ const applyDefaultMiddlewares = async ({
99
99
  compileMiddlewareAPI.onUpgrade.bind(compileMiddlewareAPI)
100
100
  );
101
101
  }
102
- if (dev.publicDir && dev.publicDir.name) {
102
+ if (dev.publicDir !== false && dev.publicDir?.name) {
103
103
  const { default: sirv } = await Promise.resolve().then(() => __toESM(require("../../compiled/sirv")));
104
104
  const { name } = dev.publicDir;
105
105
  const publicDir = (0, import_path.isAbsolute)(name) ? name : (0, import_path.join)(pwd, name);
@@ -1,17 +1,16 @@
1
1
  /// <reference types="node" />
2
- import type { Logger, Routes, DevConfig, PrintUrls, RsbuildEntry, RsbuildConfig, OutputStructure } from '@rsbuild/shared';
2
+ import type { Routes, DevConfig, PrintUrls, RsbuildEntry, RsbuildConfig, OutputStructure } from '@rsbuild/shared';
3
3
  export declare const formatRoutes: (entry: RsbuildEntry, prefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
4
- export declare function printServerURLs({ urls, port, routes, protocol, printUrls, logger, }: {
4
+ export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, }: {
5
5
  urls: Array<{
6
6
  url: string;
7
7
  label: string;
8
8
  }>;
9
9
  port: number;
10
10
  routes: Routes;
11
- logger?: Logger;
12
11
  protocol: string;
13
12
  printUrls?: PrintUrls;
14
- }): void;
13
+ }): string | undefined;
15
14
  /**
16
15
  * hmr socket connect path
17
16
  */