@rsbuild/core 0.3.0 → 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.
@@ -86,7 +86,7 @@ async function init({
86
86
  }
87
87
  }
88
88
  function runCli() {
89
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.0");
89
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.1");
90
90
  import_commander.program.command("dev").option("-o --open [url]", "open the page in browser on startup").option(
91
91
  "--port <port>",
92
92
  "specify a port number for Rsbuild Server to listen"
@@ -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.3.0"}`}
37
+ import_rslog.logger.greet(` ${`Rsbuild v${"0.3.1"}`}
38
38
  `);
39
39
  }
40
40
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var import_loadEnv = require("./loadEnv");
31
31
  var import_createRsbuild = require("./createRsbuild");
32
32
  var import_config = require("./cli/config");
33
33
  var import_shared = require("@rsbuild/shared");
34
- const version = "0.3.0";
34
+ const version = "0.3.1";
35
35
  // Annotate the CommonJS export names for ESM import in node:
36
36
  0 && (module.exports = {
37
37
  createRsbuild,
@@ -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 moment_exports = {};
20
25
  __export(moment_exports, {
21
26
  pluginMoment: () => pluginMoment
@@ -23,6 +28,7 @@ __export(moment_exports, {
23
28
  module.exports = __toCommonJS(moment_exports);
24
29
  class IgnorePlugin {
25
30
  constructor(options) {
31
+ __publicField(this, "options");
26
32
  this.options = options;
27
33
  this.checkIgnore = this.checkIgnore.bind(this);
28
34
  }
@@ -1,3 +1,3 @@
1
- import { InitConfigsOptions } from './initConfigs';
1
+ import { type InitConfigsOptions } from './initConfigs';
2
2
  import type { BuildOptions } from '@rsbuild/shared';
3
3
  export declare const build: (initOptions: InitConfigsOptions, { mode, watch, compiler: customCompiler }?: BuildOptions) => Promise<void>;
@@ -1,4 +1,4 @@
1
- import { RsbuildConfig, type BundlerType, type RsbuildContext, type NormalizedConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
1
+ import { type BundlerType, type RsbuildConfig, type RsbuildContext, type NormalizedConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
2
2
  import type { InternalContext } from '../../types';
3
3
  /**
4
4
  * Create context by config.
@@ -59,7 +59,7 @@ function createContextByConfig(options, bundlerType, config = {}) {
59
59
  const context = {
60
60
  entry: config.source?.entry || getDefaultEntry(rootPath),
61
61
  targets: config.output?.targets || [],
62
- version: "0.3.0",
62
+ version: "0.3.1",
63
63
  rootPath,
64
64
  distPath,
65
65
  cachePath,
@@ -1,4 +1,4 @@
1
- import { CssModules } from '@rsbuild/shared';
1
+ import { type CssModules } from '@rsbuild/shared';
2
2
  import type { LoaderContext } from '@rspack/core';
3
3
  export default function (this: LoaderContext<{
4
4
  modules: Required<CssModules>;
@@ -1,4 +1,4 @@
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
4
  export declare const rspackMinVersion = "0.5.0";
@@ -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;
@@ -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;
@@ -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
@@ -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 {
@@ -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;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
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, }: {
4
+ export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, }: {
5
5
  urls: Array<{
6
6
  url: string;
7
7
  label: string;
@@ -34,8 +34,34 @@ const formatRoutes = (entry, prefix, outputStructure) => {
34
34
  (name === "index" && outputStructure !== "nested" ? "" : name)
35
35
  })).sort((a) => a.name === "index" ? -1 : 1);
36
36
  };
37
+ function getURLMessages(urls, routes) {
38
+ if (routes.length === 1) {
39
+ return urls.map(
40
+ ({ label, url }) => ` ${`> ${label.padEnd(10)}`}${import_shared.color.cyan(
41
+ (0, import_shared.normalizeUrl)(`${url}/${routes[0].route}`)
42
+ )}
43
+ `
44
+ ).join("");
45
+ }
46
+ let message = "";
47
+ const maxNameLength = Math.max(...routes.map((r) => r.name.length));
48
+ urls.forEach(({ label, url }, index) => {
49
+ if (index > 0) {
50
+ message += "\n";
51
+ }
52
+ message += ` ${`> ${label}`}
53
+ `;
54
+ routes.forEach((r) => {
55
+ message += ` ${import_shared.color.dim("-")} ${import_shared.color.dim(
56
+ r.name.padEnd(maxNameLength + 4)
57
+ )}${import_shared.color.cyan((0, import_shared.normalizeUrl)(`${url}/${r.route}`))}
58
+ `;
59
+ });
60
+ });
61
+ return message;
62
+ }
37
63
  function printServerURLs({
38
- urls,
64
+ urls: originalUrls,
39
65
  port,
40
66
  routes,
41
67
  protocol,
@@ -44,38 +70,30 @@ function printServerURLs({
44
70
  if (printUrls === false) {
45
71
  return;
46
72
  }
73
+ let urls = originalUrls;
47
74
  if ((0, import_shared.isFunction)(printUrls)) {
48
- printUrls({
75
+ const newUrls = printUrls({
49
76
  urls: urls.map((item) => item.url),
50
77
  port,
51
78
  protocol
52
79
  });
53
- return;
80
+ if (!newUrls) {
81
+ return;
82
+ }
83
+ if (!Array.isArray(newUrls)) {
84
+ throw new Error(
85
+ `"server.printUrls" must return an array, but got ${typeof newUrls}.`
86
+ );
87
+ }
88
+ urls = newUrls.map((url) => ({
89
+ url,
90
+ label: (0, import_shared.getUrlLabel)(url)
91
+ }));
54
92
  }
55
- let message = "";
56
- if (routes.length === 1) {
57
- message = urls.map(
58
- ({ label, url }) => ` ${`> ${label.padEnd(10)}`}${import_shared.color.cyan(
59
- (0, import_shared.normalizeUrl)(`${url}/${routes[0].route}`)
60
- )}
61
- `
62
- ).join("");
63
- } else {
64
- const maxNameLength = Math.max(...routes.map((r) => r.name.length));
65
- urls.forEach(({ label, url }, index) => {
66
- if (index > 0) {
67
- message += "\n";
68
- }
69
- message += ` ${`> ${label}`}
70
- `;
71
- routes.forEach((r) => {
72
- message += ` ${import_shared.color.dim("-")} ${import_shared.color.dim(
73
- r.name.padEnd(maxNameLength + 4)
74
- )}${import_shared.color.cyan((0, import_shared.normalizeUrl)(`${url}/${r.route}`))}
75
- `;
76
- });
77
- });
93
+ if (urls.length === 0) {
94
+ return;
78
95
  }
96
+ const message = getURLMessages(urls, routes);
79
97
  import_shared.logger.log(message);
80
98
  return message;
81
99
  }
@@ -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 prodServer_exports = {};
30
35
  __export(prodServer_exports, {
31
36
  RsbuildProdServer: () => RsbuildProdServer,
@@ -41,7 +46,9 @@ var import_middlewares = require("./middlewares");
41
46
  var import_httpServer = require("./httpServer");
42
47
  class RsbuildProdServer {
43
48
  constructor(options) {
44
- this.middlewares = (0, import_connect.default)();
49
+ __publicField(this, "app");
50
+ __publicField(this, "options");
51
+ __publicField(this, "middlewares", (0, import_connect.default)());
45
52
  this.options = options;
46
53
  }
47
54
  // Complete the preparation of services
@@ -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 socketServer_exports = {};
30
35
  __export(socketServer_exports, {
31
36
  SocketServer: () => SocketServer
@@ -35,8 +40,11 @@ var import_ws = __toESM(require("../../compiled/ws"));
35
40
  var import_shared = require("@rsbuild/shared");
36
41
  class SocketServer {
37
42
  constructor(options) {
38
- this.sockets = [];
39
- this.timer = null;
43
+ __publicField(this, "wsServer");
44
+ __publicField(this, "sockets", []);
45
+ __publicField(this, "options");
46
+ __publicField(this, "stats");
47
+ __publicField(this, "timer", null);
40
48
  this.options = options;
41
49
  }
42
50
  upgrade(req, sock, head) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -61,7 +61,7 @@
61
61
  "core-js": "~3.32.2",
62
62
  "html-webpack-plugin": "npm:html-rspack-plugin@5.5.7",
63
63
  "postcss": "8.4.31",
64
- "@rsbuild/shared": "0.3.0"
64
+ "@rsbuild/shared": "0.3.1"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/node": "16.x",