@rsbuild/core 0.2.6 → 0.2.7

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.
@@ -83,7 +83,7 @@ async function init({
83
83
  }
84
84
  }
85
85
  function runCli() {
86
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.2.6");
86
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.2.7");
87
87
  import_commander.program.command("dev").option("--open", "open the page in browser on startup").option(
88
88
  "--port <port>",
89
89
  "specify a port number for Rsbuild Server to listen"
@@ -34,7 +34,7 @@ function prepareCli() {
34
34
  if (!npm_execpath || npm_execpath.includes("npx-cli.js")) {
35
35
  console.log();
36
36
  }
37
- import_rslog.logger.greet(` ${`Rsbuild v${"0.2.6"}`}
37
+ import_rslog.logger.greet(` ${`Rsbuild v${"0.2.7"}`}
38
38
  `);
39
39
  }
40
40
  // Annotate the CommonJS export names for ESM import in node:
@@ -52,7 +52,8 @@ function getInject(entryName, config) {
52
52
  defaults: "head",
53
53
  options: config.html.inject,
54
54
  utils: { entryName },
55
- useObjectParam: true
55
+ useObjectParam: true,
56
+ isFalsy: import_shared.isNil
56
57
  });
57
58
  }
58
59
  const existTemplatePath = [];
@@ -223,10 +224,7 @@ const pluginHtml = () => ({
223
224
  if (templateContent) {
224
225
  htmlInfo.templateContent = templateContent;
225
226
  }
226
- const title = getTitle(entryName, config);
227
- if (title) {
228
- pluginOptions.title = title;
229
- }
227
+ pluginOptions.title = getTitle(entryName, config);
230
228
  const favicon = getFavicon(entryName, config);
231
229
  if (favicon) {
232
230
  if ((0, import_shared.isURL)(favicon)) {
@@ -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.2.6",
62
+ version: "0.2.7",
63
63
  rootPath,
64
64
  distPath,
65
65
  cachePath,
@@ -83,7 +83,9 @@ async function getConfigUtils(config, chainUtils) {
83
83
  },
84
84
  removePlugin(pluginName) {
85
85
  if (config.plugins) {
86
- config.plugins = config.plugins.filter((p) => p.name !== pluginName);
86
+ config.plugins = config.plugins.filter(
87
+ (p) => p && p.name !== pluginName
88
+ );
87
89
  }
88
90
  }
89
91
  };
@@ -110,7 +110,9 @@ const applyCSSModuleRule = (rules, ruleTest, config) => {
110
110
  if (!rules || !enableNativeCss(config)) {
111
111
  return;
112
112
  }
113
- const ruleIndex = rules.findIndex((r) => r !== "..." && r.test === ruleTest);
113
+ const ruleIndex = rules.findIndex(
114
+ (r) => r && r !== "..." && r.test === ruleTest
115
+ );
114
116
  if (ruleIndex === -1) {
115
117
  return;
116
118
  }
@@ -40,13 +40,6 @@ function pluginLess() {
40
40
  const config = api.getNormalizedConfig();
41
41
  const { applyBaseCSSRule } = await Promise.resolve().then(() => __toESM(require("./css")));
42
42
  const rule = chain.module.rule(utils.CHAIN_ID.RULE.LESS).test(import_shared.LESS_REGEX);
43
- await applyBaseCSSRule({
44
- rule,
45
- utils,
46
- config,
47
- context: api.context,
48
- importLoaders: 2
49
- });
50
43
  const { excludes, options } = (0, import_shared.getLessLoaderOptions)(
51
44
  config.tools.less,
52
45
  config.output.sourceMap.css
@@ -58,7 +51,8 @@ function pluginLess() {
58
51
  rule,
59
52
  utils,
60
53
  config,
61
- context: api.context
54
+ context: api.context,
55
+ importLoaders: 2
62
56
  });
63
57
  rule.use(utils.CHAIN_ID.USE.LESS).loader((0, import_shared.getSharedPkgCompiledPath)("less-loader")).options(options);
64
58
  });
@@ -32,33 +32,6 @@ __export(minimize_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(minimize_exports);
34
34
  var import_shared = require("@rsbuild/shared");
35
- const getJsMinimizerOptions = (config) => {
36
- const options = {};
37
- const { removeConsole } = config.performance;
38
- if (removeConsole === true) {
39
- options.dropConsole = true;
40
- } else if (Array.isArray(removeConsole)) {
41
- const pureFuncs = removeConsole.map((method) => `console.${method}`);
42
- options.pureFuncs = pureFuncs;
43
- }
44
- switch (config.output.legalComments) {
45
- case "inline":
46
- options.comments = "some";
47
- options.extractComments = false;
48
- break;
49
- case "linked":
50
- options.extractComments = true;
51
- break;
52
- case "none":
53
- options.comments = false;
54
- options.extractComments = false;
55
- break;
56
- default:
57
- break;
58
- }
59
- options.asciiOnly = config.output.charset === "ascii";
60
- return options;
61
- };
62
35
  const pluginMinimize = () => ({
63
36
  name: "rsbuild:minimize",
64
37
  setup(api) {
@@ -70,7 +43,7 @@ const pluginMinimize = () => ({
70
43
  return;
71
44
  }
72
45
  const { SwcJsMinimizerRspackPlugin, SwcCssMinimizerRspackPlugin } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
73
- chain.optimization.minimizer(import_shared.CHAIN_ID.MINIMIZER.JS).use(SwcJsMinimizerRspackPlugin, [getJsMinimizerOptions(config)]).end().minimizer(import_shared.CHAIN_ID.MINIMIZER.CSS).use(SwcCssMinimizerRspackPlugin, []).end();
46
+ chain.optimization.minimizer(import_shared.CHAIN_ID.MINIMIZER.JS).use(SwcJsMinimizerRspackPlugin, [(0, import_shared.getSwcMinimizerOptions)(config)]).end().minimizer(import_shared.CHAIN_ID.MINIMIZER.CSS).use(SwcCssMinimizerRspackPlugin, []).end();
74
47
  });
75
48
  }
76
49
  });
@@ -40,16 +40,14 @@ class HtmlBasicPlugin {
40
40
  this.options = options;
41
41
  }
42
42
  apply(compiler) {
43
- const addTitleTag = (headTags, title) => {
44
- if (title) {
45
- headTags.unshift({
46
- tagName: "title",
47
- innerHTML: title,
48
- attributes: {},
49
- voidTag: false,
50
- meta: {}
51
- });
52
- }
43
+ const addTitleTag = (headTags, title = "") => {
44
+ headTags.unshift({
45
+ tagName: "title",
46
+ innerHTML: title,
47
+ attributes: {},
48
+ voidTag: false,
49
+ meta: {}
50
+ });
53
51
  };
54
52
  const addFavicon = (headTags, entryName) => {
55
53
  const { favicon } = this.options.info[entryName];
@@ -132,7 +132,6 @@ async function startDevServer(options, createDevMiddleware, {
132
132
  middlewares
133
133
  });
134
134
  (0, import_shared.debug)("create dev server done");
135
- await serverAPIs.beforeStart();
136
135
  const protocol = https ? "https" : "http";
137
136
  let urls = (0, import_shared.getAddressUrls)(protocol, port, host);
138
137
  if (printURLs) {
@@ -150,6 +149,7 @@ async function startDevServer(options, createDevMiddleware, {
150
149
  });
151
150
  devMiddlewares.middlewares.forEach((m) => middlewares.use(m));
152
151
  middlewares.use(import_middlewares.notFoundMiddleware);
152
+ await serverAPIs.beforeStart();
153
153
  (0, import_shared.debug)("listen dev server");
154
154
  httpServer.on("upgrade", devMiddlewares.onUpgrade);
155
155
  return new Promise((resolve) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
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": {
@@ -60,7 +60,7 @@
60
60
  "core-js": "~3.32.2",
61
61
  "html-webpack-plugin": "npm:html-rspack-plugin@5.5.7",
62
62
  "postcss": "8.4.31",
63
- "@rsbuild/shared": "0.2.6"
63
+ "@rsbuild/shared": "0.2.7"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@types/node": "16.x",