@rsbuild/core 0.1.3 → 0.1.4

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.
@@ -2,6 +2,8 @@ import type { RsbuildMode } from '..';
2
2
  export type CommonOptions = {
3
3
  config?: string;
4
4
  open?: boolean;
5
+ host?: string;
6
+ port?: number;
5
7
  };
6
8
  export type BuildOptions = CommonOptions & {
7
9
  watch?: boolean;
@@ -53,6 +53,14 @@ async function init({
53
53
  config.dev || (config.dev = {});
54
54
  config.dev.startUrl = true;
55
55
  }
56
+ if (commonOpts.host) {
57
+ config.server || (config.server = {});
58
+ config.server.host = commonOpts.host;
59
+ }
60
+ if (commonOpts.port) {
61
+ config.server || (config.server = {});
62
+ config.server.port = commonOpts.port;
63
+ }
56
64
  return await createRsbuild({
57
65
  rsbuildConfig: config,
58
66
  provider: config.provider
@@ -66,8 +74,14 @@ async function init({
66
74
  }
67
75
  }
68
76
  function runCli() {
69
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.1.3");
77
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.1.4");
70
78
  import_commander.program.command("dev").option("--open", "open the page in browser on startup").option(
79
+ "--port <port>",
80
+ "specify a port number for Rsbuild Server to listen"
81
+ ).option(
82
+ "--host <host>",
83
+ "specify the host that the Rsbuild Server listens to"
84
+ ).option(
71
85
  "-c --config <config>",
72
86
  "specify the configuration file, can be a relative or absolute path"
73
87
  ).description("starting the dev server").action(async (options) => {
@@ -96,6 +110,12 @@ function runCli() {
96
110
  }
97
111
  });
98
112
  import_commander.program.command("preview").option("--open", "open the page in browser on startup").option(
113
+ "--port <port>",
114
+ "specify a port number for Rsbuild Server to listen"
115
+ ).option(
116
+ "--host <host>",
117
+ "specify the host that the Rsbuild Server listens to"
118
+ ).option(
99
119
  "-c --config <config>",
100
120
  "specify the configuration file, can be a relative or absolute path"
101
121
  ).description("preview the production build locally").action(async (options) => {
@@ -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.1.3"}`}
37
+ import_rslog.logger.greet(` ${`Rsbuild v${"0.1.4"}`}
38
38
  `);
39
39
  }
40
40
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.d.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  * the public API of @rsbuild/core.
4
4
  */
5
5
  export { createRsbuild } from './createRsbuild';
6
- export { mergeRsbuildConfig } from '@rsbuild/shared';
7
6
  export { defineConfig } from './cli/config';
7
+ export { logger, mergeRsbuildConfig } from '@rsbuild/shared';
8
8
  export type { Rspack } from './rspack-provider';
9
9
  export type { RsbuildConfig, NormalizedConfig, RsbuildPlugin, RsbuildPluginAPI } from './types';
10
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/index.js CHANGED
@@ -20,15 +20,17 @@ var src_exports = {};
20
20
  __export(src_exports, {
21
21
  createRsbuild: () => import_createRsbuild.createRsbuild,
22
22
  defineConfig: () => import_config.defineConfig,
23
+ logger: () => import_shared.logger,
23
24
  mergeRsbuildConfig: () => import_shared.mergeRsbuildConfig
24
25
  });
25
26
  module.exports = __toCommonJS(src_exports);
26
27
  var import_createRsbuild = require("./createRsbuild");
27
- var import_shared = require("@rsbuild/shared");
28
28
  var import_config = require("./cli/config");
29
+ var import_shared = require("@rsbuild/shared");
29
30
  // Annotate the CommonJS export names for ESM import in node:
30
31
  0 && (module.exports = {
31
32
  createRsbuild,
32
33
  defineConfig,
34
+ logger,
33
35
  mergeRsbuildConfig
34
36
  });
@@ -42,11 +42,7 @@ const pluginInlineChunk = () => ({
42
42
  return;
43
43
  }
44
44
  const { InlineChunkHtmlPlugin } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared")));
45
- const {
46
- inlineStyles,
47
- // todo: not support inlineScripts in Rspack yet, which will take unknown build error
48
- inlineScripts
49
- } = config.output;
45
+ const { inlineStyles, inlineScripts } = config.output;
50
46
  const scriptTests = [];
51
47
  const styleTests = [];
52
48
  if (inlineScripts) {
@@ -64,7 +64,7 @@ function createContextByConfig(options, bundlerType, sourceConfig = {}, outputCo
64
64
  entry: sourceConfig.entry || // TODO: remove sourceConfig.entries in v0.2.0
65
65
  // compat with previous config
66
66
  sourceConfig.entries || getDefaultEntry(rootPath),
67
- version: "0.1.3",
67
+ version: "0.1.4",
68
68
  target,
69
69
  rootPath,
70
70
  distPath,
@@ -26,7 +26,6 @@ export declare function startDevServer<Options extends {
26
26
  }>(options: Options, createDevMiddleware: (options: Options, compiler: StartDevServerOptions['compiler']) => Promise<CreateDevMiddlewareReturns>, {
27
27
  compiler: customCompiler,
28
28
  printURLs,
29
- strictPort,
30
29
  logger: customLogger,
31
30
  getPortSilently
32
31
  }?: StartDevServerOptions & {
@@ -159,7 +159,6 @@ class RsbuildDevServer {
159
159
  async function startDevServer(options, createDevMiddleware, {
160
160
  compiler: customCompiler,
161
161
  printURLs = true,
162
- strictPort = false,
163
162
  logger: customLogger,
164
163
  getPortSilently
165
164
  } = {}) {
@@ -170,7 +169,6 @@ async function startDevServer(options, createDevMiddleware, {
170
169
  const logger = customLogger ?? import_shared.logger;
171
170
  const { devServerConfig, port, host, https } = await (0, import_shared.getDevOptions)({
172
171
  rsbuildConfig,
173
- strictPort,
174
172
  getPortSilently
175
173
  });
176
174
  options.context.devServer = {
@@ -28,7 +28,6 @@ export declare class RsbuildProdServer {
28
28
  }
29
29
  export declare function startProdServer(context: Context, rsbuildConfig: RsbuildConfig, {
30
30
  printURLs,
31
- strictPort,
32
31
  getPortSilently
33
32
  }?: PreviewServerOptions): Promise<StartServerResult>;
34
33
  export {};
@@ -134,17 +134,12 @@ class RsbuildProdServer {
134
134
  this.app.close();
135
135
  }
136
136
  }
137
- async function startProdServer(context, rsbuildConfig, {
138
- printURLs = true,
139
- strictPort = false,
140
- getPortSilently
141
- } = {}) {
137
+ async function startProdServer(context, rsbuildConfig, { printURLs = true, getPortSilently } = {}) {
142
138
  if (!process.env.NODE_ENV) {
143
139
  process.env.NODE_ENV = "production";
144
140
  }
145
141
  const { serverConfig, port, host, https } = await (0, import_shared.getServerOptions)({
146
142
  rsbuildConfig,
147
- strictPort,
148
143
  getPortSilently
149
144
  });
150
145
  const server = new RsbuildProdServer({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Unleash the power of Rspack with the out-of-the-box build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -58,12 +58,12 @@
58
58
  "types.d.ts"
59
59
  ],
60
60
  "dependencies": {
61
- "@rspack/core": "0.4.0",
61
+ "@rspack/core": "0.4.0-canary-d45e3e0-20231128075052",
62
62
  "core-js": "~3.32.2",
63
63
  "html-webpack-plugin": "npm:html-rspack-plugin@5.5.7",
64
64
  "postcss": "8.4.31",
65
65
  "semver": "^7.5.4",
66
- "@rsbuild/shared": "0.1.3"
66
+ "@rsbuild/shared": "0.1.4"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/node": "^16",