@rsbuild/core 0.3.6 → 0.3.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.
Files changed (38) hide show
  1. package/dist/cli/commands.js +5 -5
  2. package/dist/cli/config.js +6 -6
  3. package/dist/cli/prepare.js +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/loadEnv.js +9 -4
  6. package/dist/plugins/asset.js +3 -3
  7. package/dist/plugins/basic.js +2 -2
  8. package/dist/plugins/cache.js +9 -9
  9. package/dist/plugins/fileSize.js +7 -7
  10. package/dist/plugins/html.js +4 -4
  11. package/dist/plugins/nodeAddons.js +3 -3
  12. package/dist/plugins/server.js +2 -2
  13. package/dist/plugins/splitChunks.js +2 -2
  14. package/dist/plugins/startUrl.js +5 -5
  15. package/dist/plugins/wasm.js +2 -2
  16. package/dist/provider/config.js +5 -11
  17. package/dist/provider/core/createContext.js +4 -4
  18. package/dist/provider/core/inspectConfig.js +3 -3
  19. package/dist/provider/plugins/css.js +9 -5
  20. package/dist/provider/plugins/output.js +3 -3
  21. package/dist/provider/plugins/resolve.js +3 -7
  22. package/dist/provider/plugins/rspackProfile.d.ts +1 -1
  23. package/dist/provider/plugins/rspackProfile.js +7 -7
  24. package/dist/provider/plugins/swc.js +3 -3
  25. package/dist/provider/shared.js +2 -2
  26. package/dist/rspack/HtmlAppIconPlugin.js +5 -5
  27. package/dist/rspack/InlineChunkHtmlPlugin.js +2 -2
  28. package/dist/rspack/preload/helpers/determineAsValue.js +11 -27
  29. package/dist/server/compilerDevMiddleware.d.ts +2 -2
  30. package/dist/server/getDevMiddlewares.js +5 -5
  31. package/dist/server/httpServer.js +2 -2
  32. package/dist/server/middlewares.js +8 -8
  33. package/dist/server/prodServer.d.ts +1 -1
  34. package/dist/server/prodServer.js +2 -2
  35. package/dist/server/restart.js +2 -2
  36. package/dist/server/socketServer.d.ts +2 -2
  37. package/package.json +2 -2
  38. package/types.d.ts +24 -0
@@ -32,8 +32,8 @@ __export(commands_exports, {
32
32
  runCli: () => runCli
33
33
  });
34
34
  module.exports = __toCommonJS(commands_exports);
35
- var import_path = require("path");
36
- var import_fs = require("fs");
35
+ var import_node_path = require("node:path");
36
+ var import_node_fs = require("node:fs");
37
37
  var import_shared = require("@rsbuild/shared");
38
38
  var import_commander = require("@rsbuild/shared/commander");
39
39
  var import_loadEnv = require("../loadEnv");
@@ -111,7 +111,7 @@ const applyServerOptions = (command) => {
111
111
  command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
112
112
  };
113
113
  function runCli() {
114
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.6");
114
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.7");
115
115
  const devCommand = import_commander.program.command("dev");
116
116
  const buildCommand = import_commander.program.command("build");
117
117
  const previewCommand = import_commander.program.command("preview");
@@ -145,7 +145,7 @@ function runCli() {
145
145
  previewCommand.description("preview the production build locally").action(async (options) => {
146
146
  try {
147
147
  const rsbuild = await init({ cliOptions: options });
148
- if (rsbuild && !(0, import_fs.existsSync)(rsbuild.context.distPath)) {
148
+ if (rsbuild && !(0, import_node_fs.existsSync)(rsbuild.context.distPath)) {
149
149
  throw new Error(
150
150
  `The output directory ${import_shared.color.yellow(
151
151
  rsbuild.context.distPath
@@ -165,7 +165,7 @@ function runCli() {
165
165
  await rsbuild?.inspectConfig({
166
166
  env: options.env,
167
167
  verbose: options.verbose,
168
- outputPath: (0, import_path.join)(rsbuild.context.distPath, options.output),
168
+ outputPath: (0, import_node_path.join)(rsbuild.context.distPath, options.output),
169
169
  writeToDisk: true
170
170
  });
171
171
  } catch (err) {
@@ -35,8 +35,8 @@ __export(config_exports, {
35
35
  watchFiles: () => watchFiles
36
36
  });
37
37
  module.exports = __toCommonJS(config_exports);
38
- var import_fs = __toESM(require("fs"));
39
- var import_path = require("path");
38
+ var import_node_fs = __toESM(require("node:fs"));
39
+ var import_node_path = require("node:path");
40
40
  var import_shared = require("@rsbuild/shared");
41
41
  var import_restart = require("../server/restart");
42
42
  function defineConfig(config) {
@@ -44,8 +44,8 @@ function defineConfig(config) {
44
44
  }
45
45
  const resolveConfigPath = (root, customConfig) => {
46
46
  if (customConfig) {
47
- const customConfigPath = (0, import_path.isAbsolute)(customConfig) ? customConfig : (0, import_path.join)(root, customConfig);
48
- if (import_fs.default.existsSync(customConfigPath)) {
47
+ const customConfigPath = (0, import_node_path.isAbsolute)(customConfig) ? customConfig : (0, import_node_path.join)(root, customConfig);
48
+ if (import_node_fs.default.existsSync(customConfigPath)) {
49
49
  return customConfigPath;
50
50
  }
51
51
  import_shared.logger.warn(`Cannot find config file: ${import_shared.color.dim(customConfigPath)}
@@ -60,8 +60,8 @@ const resolveConfigPath = (root, customConfig) => {
60
60
  "rsbuild.config.cts"
61
61
  ];
62
62
  for (const file of CONFIG_FILES) {
63
- const configFile = (0, import_path.join)(root, file);
64
- if (import_fs.default.existsSync(configFile)) {
63
+ const configFile = (0, import_node_path.join)(root, file);
64
+ if (import_node_fs.default.existsSync(configFile)) {
65
65
  return configFile;
66
66
  }
67
67
  }
@@ -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.6"}`}
37
+ import_rslog.logger.greet(` ${`Rsbuild v${"0.3.7"}`}
38
38
  `);
39
39
  }
40
40
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.js CHANGED
@@ -38,7 +38,7 @@ var import_createRsbuild = require("./createRsbuild");
38
38
  var import_config = require("./cli/config");
39
39
  var import_shared = require("@rsbuild/shared");
40
40
  var import_constants = require("./constants");
41
- const version = "0.3.6";
41
+ const version = "0.3.7";
42
42
  // Annotate the CommonJS export names for ESM import in node:
43
43
  0 && (module.exports = {
44
44
  PLUGIN_BABEL_NAME,
package/dist/loadEnv.js CHANGED
@@ -31,8 +31,8 @@ __export(loadEnv_exports, {
31
31
  loadEnv: () => loadEnv
32
32
  });
33
33
  module.exports = __toCommonJS(loadEnv_exports);
34
- var import_fs = __toESM(require("fs"));
35
- var import_path = require("path");
34
+ var import_node_fs = __toESM(require("node:fs"));
35
+ var import_node_path = require("node:path");
36
36
  var import_shared = require("@rsbuild/shared");
37
37
  var import_dotenv = require("../compiled/dotenv");
38
38
  var import_dotenv_expand = require("../compiled/dotenv-expand");
@@ -41,16 +41,21 @@ function loadEnv({
41
41
  mode = (0, import_shared.getNodeEnv)(),
42
42
  prefixes = ["PUBLIC_"]
43
43
  } = {}) {
44
+ if (mode === "local") {
45
+ throw new Error(
46
+ `'local' cannot be used as a value for env mode, because ".env.local" represents a temporary local file. Please use another value.`
47
+ );
48
+ }
44
49
  const filenames = [
45
50
  ".env",
46
51
  ".env.local",
47
52
  `.env.${mode}`,
48
53
  `.env.${mode}.local`
49
54
  ];
50
- const filePaths = filenames.map((filename) => (0, import_path.join)(cwd, filename)).filter(import_shared.isFileSync);
55
+ const filePaths = filenames.map((filename) => (0, import_node_path.join)(cwd, filename)).filter(import_shared.isFileSync);
51
56
  const parsed = {};
52
57
  filePaths.forEach((envPath) => {
53
- Object.assign(parsed, (0, import_dotenv.parse)(import_fs.default.readFileSync(envPath)));
58
+ Object.assign(parsed, (0, import_dotenv.parse)(import_node_fs.default.readFileSync(envPath)));
54
59
  });
55
60
  (0, import_dotenv_expand.expand)({ parsed });
56
61
  const publicVars = {};
@@ -32,7 +32,7 @@ __export(asset_exports, {
32
32
  pluginAsset: () => pluginAsset
33
33
  });
34
34
  module.exports = __toCommonJS(asset_exports);
35
- var import_path = __toESM(require("path"));
35
+ var import_node_path = __toESM(require("node:path"));
36
36
  var import_shared = require("@rsbuild/shared");
37
37
  function getRegExpForExts(exts) {
38
38
  const matcher = exts.map((ext) => ext.trim()).map((ext) => ext.startsWith(".") ? ext.slice(1) : ext).join("|");
@@ -55,13 +55,13 @@ const pluginAsset = () => ({
55
55
  (0, import_shared.chainStaticAssetRule)({
56
56
  rule,
57
57
  maxSize,
58
- filename: import_path.default.posix.join(distDir, filename),
58
+ filename: import_node_path.default.posix.join(distDir, filename),
59
59
  assetType
60
60
  });
61
61
  };
62
62
  createAssetRule("image", import_shared.IMAGE_EXTENSIONS);
63
63
  createAssetRule("svg", ["svg"]);
64
- createAssetRule("media", import_shared.MEDIA_EXTENSIONS);
64
+ createAssetRule("media", [...import_shared.VIDEO_EXTENSIONS, ...import_shared.AUDIO_EXTENSIONS]);
65
65
  createAssetRule("font", import_shared.FONT_EXTENSIONS);
66
66
  });
67
67
  }
@@ -31,7 +31,7 @@ __export(basic_exports, {
31
31
  pluginBasic: () => pluginBasic
32
32
  });
33
33
  module.exports = __toCommonJS(basic_exports);
34
- var import_path = __toESM(require("path"));
34
+ var import_node_path = __toESM(require("node:path"));
35
35
  var import_shared = require("@rsbuild/shared");
36
36
  const pluginBasic = () => ({
37
37
  name: "rsbuild:basic",
@@ -61,7 +61,7 @@ const pluginBasic = () => ({
61
61
  }
62
62
  if (env === "development") {
63
63
  chain.output.devtoolModuleFilenameTemplate(
64
- (info) => import_path.default.resolve(info.absoluteResourcePath).replace(/\\/g, "/")
64
+ (info) => import_node_path.default.resolve(info.absoluteResourcePath).replace(/\\/g, "/")
65
65
  );
66
66
  }
67
67
  }
@@ -31,12 +31,12 @@ __export(cache_exports, {
31
31
  pluginCache: () => pluginCache
32
32
  });
33
33
  module.exports = __toCommonJS(cache_exports);
34
- var import_crypto = __toESM(require("crypto"));
35
- var import_path = require("path");
34
+ var import_node_crypto = __toESM(require("node:crypto"));
35
+ var import_node_path = require("node:path");
36
36
  var import_shared = require("@rsbuild/shared");
37
37
  var import_shared2 = require("@rsbuild/shared");
38
38
  async function validateCache(cacheDirectory, buildDependencies) {
39
- const configFile = (0, import_path.join)(cacheDirectory, "buildDependencies.json");
39
+ const configFile = (0, import_node_path.join)(cacheDirectory, "buildDependencies.json");
40
40
  if (await (0, import_shared2.isFileExists)(configFile)) {
41
41
  const prevBuildDependencies = await import_shared.fse.readJSON(configFile);
42
42
  if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) {
@@ -47,19 +47,19 @@ async function validateCache(cacheDirectory, buildDependencies) {
47
47
  await import_shared.fse.outputJSON(configFile, buildDependencies);
48
48
  }
49
49
  function getDigestHash(digest) {
50
- const fsHash = import_crypto.default.createHash("md5");
50
+ const fsHash = import_node_crypto.default.createHash("md5");
51
51
  const md5 = fsHash.update(JSON.stringify(digest)).digest("hex").slice(0, 8);
52
52
  return md5;
53
53
  }
54
54
  function getCacheDirectory({ cacheDirectory }, context) {
55
55
  if (cacheDirectory) {
56
- return (0, import_path.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, import_path.join)(context.rootPath, cacheDirectory);
56
+ return (0, import_node_path.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, import_node_path.join)(context.rootPath, cacheDirectory);
57
57
  }
58
- return (0, import_path.join)(context.cachePath, context.bundlerType);
58
+ return (0, import_node_path.join)(context.cachePath, context.bundlerType);
59
59
  }
60
60
  async function getBuildDependencies(context) {
61
- const rootPackageJson = (0, import_path.join)(context.rootPath, "package.json");
62
- const browserslistConfig = (0, import_path.join)(context.rootPath, ".browserslistrc");
61
+ const rootPackageJson = (0, import_node_path.join)(context.rootPath, "package.json");
62
+ const browserslistConfig = (0, import_node_path.join)(context.rootPath, ".browserslistrc");
63
63
  const buildDependencies = {};
64
64
  if (await (0, import_shared2.isFileExists)(rootPackageJson)) {
65
65
  buildDependencies.packageJson = [rootPackageJson];
@@ -72,7 +72,7 @@ async function getBuildDependencies(context) {
72
72
  }
73
73
  const tailwindExts = ["ts", "js", "cjs", "mjs"];
74
74
  const configs = tailwindExts.map(
75
- (ext) => (0, import_path.join)(context.rootPath, `tailwind.config.${ext}`)
75
+ (ext) => (0, import_node_path.join)(context.rootPath, `tailwind.config.${ext}`)
76
76
  );
77
77
  const tailwindConfig = (0, import_shared2.findExists)(configs);
78
78
  if (tailwindConfig) {
@@ -32,7 +32,7 @@ __export(fileSize_exports, {
32
32
  pluginFileSize: () => pluginFileSize
33
33
  });
34
34
  module.exports = __toCommonJS(fileSize_exports);
35
- var import_path = __toESM(require("path"));
35
+ var import_node_path = __toESM(require("node:path"));
36
36
  var import_shared = require("@rsbuild/shared");
37
37
  var import_shared2 = require("@rsbuild/shared");
38
38
  const filterAsset = (asset) => !/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
@@ -68,13 +68,13 @@ async function printFileSizes(config, stats, distPath) {
68
68
  const { default: gzipSize } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/gzip-size")));
69
69
  const formatAsset = (asset) => {
70
70
  const fileName = asset.name.split("?")[0];
71
- const contents = import_shared.fse.readFileSync(import_path.default.join(distPath, fileName));
71
+ const contents = import_shared.fse.readFileSync(import_node_path.default.join(distPath, fileName));
72
72
  const size = contents.length;
73
73
  const gzippedSize = gzipSize.sync(contents);
74
74
  return {
75
75
  size,
76
- folder: import_path.default.join(import_path.default.basename(distPath), import_path.default.dirname(fileName)),
77
- name: import_path.default.basename(fileName),
76
+ folder: import_node_path.default.join(import_node_path.default.basename(distPath), import_node_path.default.dirname(fileName)),
77
+ name: import_node_path.default.basename(fileName),
78
78
  gzippedSize,
79
79
  sizeLabel: calcFileSize(size),
80
80
  gzipSizeLabel: getAssetColor(gzippedSize)(calcFileSize(gzippedSize))
@@ -104,7 +104,7 @@ async function printFileSizes(config, stats, distPath) {
104
104
  import_shared2.logger.info("Production file sizes:\n");
105
105
  const longestLabelLength = Math.max(...assets.map((a) => a.sizeLabel.length));
106
106
  const longestFileLength = Math.max(
107
- ...assets.map((a) => (a.folder + import_path.default.sep + a.name).length)
107
+ ...assets.map((a) => (a.folder + import_node_path.default.sep + a.name).length)
108
108
  );
109
109
  if (config.detail !== false) {
110
110
  printHeader(longestFileLength, longestLabelLength);
@@ -114,7 +114,7 @@ async function printFileSizes(config, stats, distPath) {
114
114
  assets.forEach((asset) => {
115
115
  let { sizeLabel } = asset;
116
116
  const { name, folder, gzipSizeLabel } = asset;
117
- const fileNameLength = (folder + import_path.default.sep + name).length;
117
+ const fileNameLength = (folder + import_node_path.default.sep + name).length;
118
118
  const sizeLength = sizeLabel.length;
119
119
  totalSize += asset.size;
120
120
  totalGzipSize += asset.gzippedSize;
@@ -123,7 +123,7 @@ async function printFileSizes(config, stats, distPath) {
123
123
  const rightPadding = " ".repeat(longestLabelLength - sizeLength);
124
124
  sizeLabel += rightPadding;
125
125
  }
126
- let fileNameLabel = import_shared2.color.dim(asset.folder + import_path.default.sep) + import_shared2.color.cyan(asset.name);
126
+ let fileNameLabel = import_shared2.color.dim(asset.folder + import_node_path.default.sep) + import_shared2.color.cyan(asset.name);
127
127
  if (fileNameLength < longestFileLength) {
128
128
  const rightPadding = " ".repeat(longestFileLength - fileNameLength);
129
129
  fileNameLabel += rightPadding;
@@ -37,7 +37,7 @@ __export(html_exports, {
37
37
  pluginHtml: () => pluginHtml
38
38
  });
39
39
  module.exports = __toCommonJS(html_exports);
40
- var import_path = __toESM(require("path"));
40
+ var import_node_path = __toESM(require("node:path"));
41
41
  var import_shared = require("@rsbuild/shared");
42
42
  function getTitle(entryName, config) {
43
43
  return (0, import_shared.mergeChainedOptions)({
@@ -58,7 +58,7 @@ function getInject(entryName, config) {
58
58
  }
59
59
  const existTemplatePath = [];
60
60
  async function getTemplate(entryName, config, rootPath) {
61
- const DEFAULT_TEMPLATE = import_path.default.resolve(
61
+ const DEFAULT_TEMPLATE = import_node_path.default.resolve(
62
62
  __dirname,
63
63
  "../../static/template.html"
64
64
  );
@@ -73,7 +73,7 @@ async function getTemplate(entryName, config, rootPath) {
73
73
  templatePath
74
74
  };
75
75
  }
76
- const absolutePath = (0, import_path.isAbsolute)(templatePath) ? templatePath : import_path.default.resolve(rootPath, templatePath);
76
+ const absolutePath = (0, import_node_path.isAbsolute)(templatePath) ? templatePath : import_node_path.default.resolve(rootPath, templatePath);
77
77
  if (!existTemplatePath.includes(absolutePath)) {
78
78
  if (!await (0, import_shared.isFileExists)(absolutePath)) {
79
79
  throw new Error(
@@ -274,7 +274,7 @@ const pluginHtml = () => ({
274
274
  if (appIcon) {
275
275
  const { HtmlAppIconPlugin } = await Promise.resolve().then(() => __toESM(require("../rspack/HtmlAppIconPlugin")));
276
276
  const distDir = (0, import_shared.getDistPath)(config, "image");
277
- const iconPath = import_path.default.isAbsolute(appIcon) ? appIcon : import_path.default.join(api.context.rootPath, appIcon);
277
+ const iconPath = import_node_path.default.isAbsolute(appIcon) ? appIcon : import_node_path.default.join(api.context.rootPath, appIcon);
278
278
  chain.plugin(CHAIN_ID.PLUGIN.APP_ICON).use(HtmlAppIconPlugin, [{ iconPath, distDir }]);
279
279
  }
280
280
  }
@@ -21,7 +21,7 @@ __export(nodeAddons_exports, {
21
21
  pluginNodeAddons: () => pluginNodeAddons
22
22
  });
23
23
  module.exports = __toCommonJS(nodeAddons_exports);
24
- var import_path = require("path");
24
+ var import_node_path = require("node:path");
25
25
  var import_shared = require("@rsbuild/shared");
26
26
  const pluginNodeAddons = () => ({
27
27
  name: "rsbuild:node-addons",
@@ -33,7 +33,7 @@ const pluginNodeAddons = () => ({
33
33
  const getDistName = (resourcePath) => {
34
34
  const pkgJSON = (0, import_shared.findUpSync)({
35
35
  filename: "package.json",
36
- cwd: (0, import_path.dirname)(resourcePath)
36
+ cwd: (0, import_node_path.dirname)(resourcePath)
37
37
  });
38
38
  if (!pkgJSON) {
39
39
  throw new Error(
@@ -56,7 +56,7 @@ const pluginNodeAddons = () => ({
56
56
  const serverPath = (0, import_shared.getDistPath)(config, "server");
57
57
  return `${serverPath}/${getFilename(resourcePath, pkgName)}`;
58
58
  };
59
- chain.module.rule(CHAIN_ID.RULE.NODE).test(/\.node$/).use(CHAIN_ID.USE.NODE).loader((0, import_path.join)(__dirname, "../../compiled/node-loader")).options({
59
+ chain.module.rule(CHAIN_ID.RULE.NODE).test(/\.node$/).use(CHAIN_ID.USE.NODE).loader((0, import_node_path.join)(__dirname, "../../compiled/node-loader")).options({
60
60
  name: getDistName
61
61
  });
62
62
  });
@@ -22,7 +22,7 @@ __export(server_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(server_exports);
24
24
  var import_shared = require("@rsbuild/shared");
25
- var import_path = require("path");
25
+ var import_node_path = require("node:path");
26
26
  const pluginServer = () => ({
27
27
  name: "rsbuild:server",
28
28
  setup(api) {
@@ -33,7 +33,7 @@ const pluginServer = () => ({
33
33
  if (!copyOnBuild || !name) {
34
34
  return;
35
35
  }
36
- const publicDir = (0, import_path.isAbsolute)(name) ? name : (0, import_path.join)(api.context.rootPath, name);
36
+ const publicDir = (0, import_node_path.isAbsolute)(name) ? name : (0, import_node_path.join)(api.context.rootPath, name);
37
37
  if (!import_shared.fse.existsSync(publicDir)) {
38
38
  return;
39
39
  }
@@ -33,7 +33,7 @@ __export(splitChunks_exports, {
33
33
  pluginSplitChunks: () => pluginSplitChunks
34
34
  });
35
35
  module.exports = __toCommonJS(splitChunks_exports);
36
- var import_assert = __toESM(require("assert"));
36
+ var import_node_assert = __toESM(require("node:assert"));
37
37
  var import_shared = require("@rsbuild/shared");
38
38
  function getUserDefinedCacheGroups(forceSplitting) {
39
39
  const cacheGroups = {};
@@ -120,7 +120,7 @@ function splitByModule(ctx) {
120
120
  }
121
121
  function splitBySize(ctx) {
122
122
  const { override, userDefinedCacheGroups, defaultConfig, rsbuildConfig } = ctx;
123
- (0, import_assert.default)(rsbuildConfig.strategy === "split-by-size");
123
+ (0, import_node_assert.default)(rsbuildConfig.strategy === "split-by-size");
124
124
  return {
125
125
  ...defaultConfig,
126
126
  minSize: rsbuildConfig.minSize ?? 0,
@@ -33,11 +33,11 @@ __export(startUrl_exports, {
33
33
  replacePlaceholder: () => replacePlaceholder
34
34
  });
35
35
  module.exports = __toCommonJS(startUrl_exports);
36
- var import_path = require("path");
36
+ var import_node_path = require("node:path");
37
37
  var import_shared = require("@rsbuild/shared");
38
- var import_child_process = require("child_process");
39
- var import_util = require("util");
40
- const execAsync = (0, import_util.promisify)(import_child_process.exec);
38
+ var import_node_child_process = require("node:child_process");
39
+ var import_node_util = require("node:util");
40
+ const execAsync = (0, import_node_util.promisify)(import_node_child_process.exec);
41
41
  const supportedChromiumBrowsers = [
42
42
  "Google Chrome Canary",
43
43
  "Google Chrome Dev",
@@ -67,7 +67,7 @@ async function openBrowser(url) {
67
67
  url
68
68
  )}" "${targetBrowser}"`,
69
69
  {
70
- cwd: (0, import_path.join)(__dirname, "../../static")
70
+ cwd: (0, import_node_path.join)(__dirname, "../../static")
71
71
  }
72
72
  );
73
73
  return true;
@@ -21,7 +21,7 @@ __export(wasm_exports, {
21
21
  pluginWasm: () => pluginWasm
22
22
  });
23
23
  module.exports = __toCommonJS(wasm_exports);
24
- var import_path = require("path");
24
+ var import_node_path = require("node:path");
25
25
  var import_shared = require("@rsbuild/shared");
26
26
  const pluginWasm = () => ({
27
27
  name: "rsbuild:wasm",
@@ -33,7 +33,7 @@ const pluginWasm = () => ({
33
33
  ...chain.get("experiments"),
34
34
  asyncWebAssembly: true
35
35
  });
36
- const wasmFilename = import_path.posix.join(distPath, "[hash].module.wasm");
36
+ const wasmFilename = import_node_path.posix.join(distPath, "[hash].module.wasm");
37
37
  chain.output.merge({
38
38
  webassemblyModuleFilename: wasmFilename
39
39
  });
@@ -22,7 +22,7 @@ __export(config_exports, {
22
22
  withDefaultConfig: () => withDefaultConfig
23
23
  });
24
24
  module.exports = __toCommonJS(config_exports);
25
- var import_path = require("path");
25
+ var import_node_path = require("node:path");
26
26
  var import_shared = require("@rsbuild/shared");
27
27
  const createDefaultConfig = () => ({
28
28
  dev: (0, import_shared.getDefaultDevConfig)(),
@@ -44,7 +44,7 @@ function getDefaultEntry(root) {
44
44
  "jsx",
45
45
  ".mjs",
46
46
  ".cjs"
47
- ].map((ext) => (0, import_path.join)(root, `src/index.${ext}`));
47
+ ].map((ext) => (0, import_node_path.join)(root, `src/index.${ext}`));
48
48
  const entryFile = (0, import_shared.findExists)(files);
49
49
  if (entryFile) {
50
50
  return {
@@ -54,26 +54,20 @@ function getDefaultEntry(root) {
54
54
  return {};
55
55
  }
56
56
  const withDefaultConfig = async (rootPath, config) => {
57
- const merged = (0, import_shared.mergeRsbuildConfig)(
58
- createDefaultConfig(),
59
- config
60
- );
57
+ const merged = (0, import_shared.mergeRsbuildConfig)(createDefaultConfig(), config);
61
58
  merged.source || (merged.source = {});
62
59
  if (!merged.source.entry) {
63
60
  merged.source.entry = getDefaultEntry(rootPath);
64
61
  }
65
62
  if (!merged.source.tsconfigPath) {
66
- const tsconfigPath = (0, import_path.join)(rootPath, import_shared.TS_CONFIG_FILE);
63
+ const tsconfigPath = (0, import_node_path.join)(rootPath, import_shared.TS_CONFIG_FILE);
67
64
  if (await (0, import_shared.isFileExists)(tsconfigPath)) {
68
65
  merged.source.tsconfigPath = tsconfigPath;
69
66
  }
70
67
  }
71
68
  return merged;
72
69
  };
73
- const normalizeConfig = (config) => (0, import_shared.mergeRsbuildConfig)(
74
- createDefaultConfig(),
75
- config
76
- );
70
+ const normalizeConfig = (config) => (0, import_shared.mergeRsbuildConfig)(createDefaultConfig(), config);
77
71
  // Annotate the CommonJS export names for ESM import in node:
78
72
  0 && (module.exports = {
79
73
  normalizeConfig,
@@ -23,12 +23,12 @@ __export(createContext_exports, {
23
23
  updateContextByNormalizedConfig: () => updateContextByNormalizedConfig
24
24
  });
25
25
  module.exports = __toCommonJS(createContext_exports);
26
- var import_path = require("path");
26
+ var import_node_path = require("node:path");
27
27
  var import_shared = require("@rsbuild/shared");
28
28
  var import_initHooks = require("./initHooks");
29
29
  var import_config = require("../config");
30
30
  function getAbsolutePath(root, filepath) {
31
- return (0, import_path.isAbsolute)(filepath) ? filepath : (0, import_path.join)(root, filepath);
31
+ return (0, import_node_path.isAbsolute)(filepath) ? filepath : (0, import_node_path.join)(root, filepath);
32
32
  }
33
33
  function getAbsoluteDistPath(cwd, config) {
34
34
  const dirRoot = (0, import_shared.getDistPath)(config, "root");
@@ -38,12 +38,12 @@ async function createContextByConfig(options, bundlerType, config = {}) {
38
38
  const { cwd } = options;
39
39
  const rootPath = cwd;
40
40
  const distPath = getAbsoluteDistPath(cwd, config);
41
- const cachePath = (0, import_path.join)(rootPath, "node_modules", ".cache");
41
+ const cachePath = (0, import_node_path.join)(rootPath, "node_modules", ".cache");
42
42
  const tsconfigPath = config.source?.tsconfigPath;
43
43
  const context = {
44
44
  entry: config.source?.entry || {},
45
45
  targets: config.output?.targets || [],
46
- version: "0.3.6",
46
+ version: "0.3.7",
47
47
  rootPath,
48
48
  distPath,
49
49
  cachePath,
@@ -21,7 +21,7 @@ __export(inspectConfig_exports, {
21
21
  inspectConfig: () => inspectConfig
22
22
  });
23
23
  module.exports = __toCommonJS(inspectConfig_exports);
24
- var import_path = require("path");
24
+ var import_node_path = require("node:path");
25
25
  var import_initConfigs = require("./initConfigs");
26
26
  var import_shared = require("@rsbuild/shared");
27
27
  async function inspectConfig({
@@ -55,8 +55,8 @@ async function inspectConfig({
55
55
  )
56
56
  );
57
57
  let outputPath = inspectOptions.outputPath || context.distPath;
58
- if (!(0, import_path.isAbsolute)(outputPath)) {
59
- outputPath = (0, import_path.join)(context.rootPath, outputPath);
58
+ if (!(0, import_node_path.isAbsolute)(outputPath)) {
59
+ outputPath = (0, import_node_path.join)(context.rootPath, outputPath);
60
60
  }
61
61
  if (inspectOptions.writeToDisk) {
62
62
  await (0, import_shared.outputInspectConfigFiles)({
@@ -34,7 +34,7 @@ __export(css_exports, {
34
34
  pluginCss: () => pluginCss
35
35
  });
36
36
  module.exports = __toCommonJS(css_exports);
37
- var import_path = __toESM(require("path"));
37
+ var import_node_path = __toESM(require("node:path"));
38
38
  var import_shared = require("@rsbuild/shared");
39
39
  const enableNativeCss = (config) => !config.output.injectStyles;
40
40
  async function applyBaseCSSRule({
@@ -86,7 +86,7 @@ async function applyBaseCSSRule({
86
86
  } else {
87
87
  if (!isServer && !isWebWorker && enableCSSModuleTS) {
88
88
  const { cssModules } = config.output;
89
- rule.use(CHAIN_ID.USE.CSS_MODULES_TS).loader(import_path.default.resolve(__dirname, "../css-modules-typescript-pre-loader")).options({
89
+ rule.use(CHAIN_ID.USE.CSS_MODULES_TS).loader(import_node_path.default.resolve(__dirname, "../css-modules-typescript-pre-loader")).options({
90
90
  modules: {
91
91
  exportLocalsConvention: cssModules.exportLocalsConvention,
92
92
  auto: cssModules.auto
@@ -162,9 +162,11 @@ const pluginCss = () => {
162
162
  });
163
163
  api.modifyRspackConfig(
164
164
  async (rspackConfig, { isProd, isServer, isWebWorker }) => {
165
+ var _a;
165
166
  const config = api.getNormalizedConfig();
166
167
  if (!enableNativeCss(config)) {
167
- (0, import_shared.setConfig)(rspackConfig, "experiments.css", false);
168
+ rspackConfig.experiments || (rspackConfig.experiments = {});
169
+ rspackConfig.experiments.css = false;
168
170
  return;
169
171
  }
170
172
  let localIdentName = config.output.cssModules.localIdentName || // Using shorter classname in production to reduce bundle size
@@ -175,11 +177,13 @@ const pluginCss = () => {
175
177
  );
176
178
  localIdentName = localIdentName.replace(":base64", "");
177
179
  }
178
- (0, import_shared.setConfig)(rspackConfig, "builtins.css.modules", {
180
+ rspackConfig.builtins || (rspackConfig.builtins = {});
181
+ (_a = rspackConfig.builtins).css || (_a.css = {});
182
+ rspackConfig.builtins.css.modules = {
179
183
  localsConvention: config.output.cssModules.exportLocalsConvention,
180
184
  localIdentName,
181
185
  exportsOnly: isServer || isWebWorker
182
- });
186
+ };
183
187
  const rules = rspackConfig.module?.rules;
184
188
  applyCSSModuleRule(rules, import_shared.CSS_REGEX, config);
185
189
  }
@@ -31,7 +31,7 @@ __export(output_exports, {
31
31
  pluginOutput: () => pluginOutput
32
32
  });
33
33
  module.exports = __toCommonJS(output_exports);
34
- var import_path = require("path");
34
+ var import_node_path = require("node:path");
35
35
  var import_shared = require("@rsbuild/shared");
36
36
  const pluginOutput = () => ({
37
37
  name: "rsbuild:output",
@@ -51,8 +51,8 @@ const pluginOutput = () => ({
51
51
  const cssPath = (0, import_shared.getDistPath)(config, "css");
52
52
  const cssFilename = (0, import_shared.getFilename)(config, "css", isProd);
53
53
  rspackConfig.output || (rspackConfig.output = {});
54
- rspackConfig.output.cssFilename = import_path.posix.join(cssPath, cssFilename);
55
- rspackConfig.output.cssChunkFilename = import_path.posix.join(
54
+ rspackConfig.output.cssFilename = import_node_path.posix.join(cssPath, cssFilename);
55
+ rspackConfig.output.cssChunkFilename = import_node_path.posix.join(
56
56
  cssPath,
57
57
  `async/${cssFilename}`
58
58
  );
@@ -29,16 +29,12 @@ const pluginResolve = () => ({
29
29
  api.modifyRspackConfig(async (rspackConfig, { isServer }) => {
30
30
  const isTsProject = Boolean(api.context.tsconfigPath);
31
31
  const config = api.getNormalizedConfig();
32
+ rspackConfig.resolve || (rspackConfig.resolve = {});
32
33
  if (isTsProject && config.source.aliasStrategy === "prefer-tsconfig") {
33
- (0, import_shared.setConfig)(
34
- rspackConfig,
35
- "resolve.tsConfigPath",
36
- api.context.tsconfigPath
37
- );
34
+ rspackConfig.resolve.tsConfigPath = api.context.tsconfigPath;
38
35
  }
39
36
  if (isServer) {
40
- const nodeConditionNames = ["require", "node"];
41
- (0, import_shared.setConfig)(rspackConfig, "resolve.conditionNames", nodeConditionNames);
37
+ rspackConfig.resolve.conditionNames = ["require", "node"];
42
38
  }
43
39
  });
44
40
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  import type { RsbuildPlugin } from '../../types';
3
- import inspector from 'inspector';
3
+ import inspector from 'node:inspector';
4
4
  export declare const stopProfiler: (output: string, profileSession?: inspector.Session) => void;
5
5
  export declare const pluginRspackProfile: () => RsbuildPlugin;
@@ -32,8 +32,8 @@ __export(rspackProfile_exports, {
32
32
  stopProfiler: () => stopProfiler
33
33
  });
34
34
  module.exports = __toCommonJS(rspackProfile_exports);
35
- var import_path = __toESM(require("path"));
36
- var import_inspector = __toESM(require("inspector"));
35
+ var import_node_path = __toESM(require("node:path"));
36
+ var import_node_inspector = __toESM(require("node:inspector"));
37
37
  var import_shared = require("@rsbuild/shared");
38
38
  var import_shared2 = require("@rsbuild/shared");
39
39
  const stopProfiler = (output, profileSession) => {
@@ -60,7 +60,7 @@ const pluginRspackProfile = () => ({
60
60
  experimental_cleanupGlobalTrace: cleanupGlobalTrace
61
61
  } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
62
62
  const timestamp = Date.now();
63
- const profileDir = import_path.default.join(
63
+ const profileDir = import_node_path.default.join(
64
64
  api.context.distPath,
65
65
  `rspack-profile-${timestamp}`
66
66
  );
@@ -68,16 +68,16 @@ const pluginRspackProfile = () => ({
68
68
  const enableProfileTrace = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("TRACE");
69
69
  const enableCPUProfile = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("CPU");
70
70
  const enableLogging = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("LOGGING");
71
- const traceFilePath = import_path.default.join(profileDir, "trace.json");
72
- const cpuProfilePath = import_path.default.join(profileDir, "jscpuprofile.json");
73
- const loggingFilePath = import_path.default.join(profileDir, "logging.json");
71
+ const traceFilePath = import_node_path.default.join(profileDir, "trace.json");
72
+ const cpuProfilePath = import_node_path.default.join(profileDir, "jscpuprofile.json");
73
+ const loggingFilePath = import_node_path.default.join(profileDir, "logging.json");
74
74
  const onStart = () => {
75
75
  import_shared.fse.ensureDirSync(profileDir);
76
76
  if (enableProfileTrace) {
77
77
  registerGlobalTrace("trace", "chrome", traceFilePath);
78
78
  }
79
79
  if (enableCPUProfile) {
80
- profileSession = new import_inspector.default.Session();
80
+ profileSession = new import_node_inspector.default.Session();
81
81
  profileSession.connect();
82
82
  profileSession.post("Profiler.enable");
83
83
  profileSession.post("Profiler.start");
@@ -33,7 +33,7 @@ __export(swc_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(swc_exports);
35
35
  var import_shared = require("@rsbuild/shared");
36
- var import_path = __toESM(require("path"));
36
+ var import_node_path = __toESM(require("node:path"));
37
37
  var import_constants = require("../../constants");
38
38
  const builtinSwcLoaderName = "builtin:swc-loader";
39
39
  async function getDefaultSwcConfig(config, rootPath, target) {
@@ -79,7 +79,7 @@ const pluginSwc = () => ({
79
79
  if (swcConfig.jsc?.externalHelpers) {
80
80
  chain.resolve.alias.set(
81
81
  "@swc/helpers",
82
- import_path.default.dirname(require.resolve("@swc/helpers/package.json"))
82
+ import_node_path.default.dirname(require.resolve("@swc/helpers/package.json"))
83
83
  );
84
84
  }
85
85
  if ((0, import_shared.isWebTarget)(target)) {
@@ -101,7 +101,7 @@ const pluginSwc = () => ({
101
101
  async function applyCoreJs(swcConfig, chain, polyfillMode) {
102
102
  const coreJsPath = require.resolve("core-js/package.json");
103
103
  const version = (0, import_shared.getCoreJsVersion)(coreJsPath);
104
- const coreJsDir = import_path.default.dirname(coreJsPath);
104
+ const coreJsDir = import_node_path.default.dirname(coreJsPath);
105
105
  swcConfig.env.coreJs = version;
106
106
  if (polyfillMode === "usage") {
107
107
  swcConfig.env.shippedProposals = true;
@@ -36,7 +36,7 @@ __export(shared_exports, {
36
36
  rspackMinVersion: () => rspackMinVersion
37
37
  });
38
38
  module.exports = __toCommonJS(shared_exports);
39
- var import_path = require("path");
39
+ var import_node_path = require("node:path");
40
40
  var import_shared = require("@rsbuild/shared");
41
41
  var import_shared2 = require("@rsbuild/shared");
42
42
  var import_shared3 = require("@rsbuild/shared");
@@ -103,7 +103,7 @@ const isSatisfyRspackVersion = async (originalVersion) => {
103
103
  return true;
104
104
  };
105
105
  const getCompiledPath = (packageName) => {
106
- const providerCompilerPath = (0, import_path.join)(__dirname, "../../compiled", packageName);
106
+ const providerCompilerPath = (0, import_node_path.join)(__dirname, "../../compiled", packageName);
107
107
  if (import_shared2.fse.existsSync(providerCompilerPath)) {
108
108
  return providerCompilerPath;
109
109
  }
@@ -36,8 +36,8 @@ __export(HtmlAppIconPlugin_exports, {
36
36
  HtmlAppIconPlugin: () => HtmlAppIconPlugin
37
37
  });
38
38
  module.exports = __toCommonJS(HtmlAppIconPlugin_exports);
39
- var import_fs = __toESM(require("fs"));
40
- var import_path = require("path");
39
+ var import_node_fs = __toESM(require("node:fs"));
40
+ var import_node_path = require("node:path");
41
41
  var import_webpack_sources = __toESM(require("@rsbuild/shared/webpack-sources"));
42
42
  var import_shared = require("@rsbuild/shared");
43
43
  var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
@@ -51,12 +51,12 @@ class HtmlAppIconPlugin {
51
51
  this.iconPath = options.iconPath;
52
52
  }
53
53
  apply(compiler) {
54
- if (!import_fs.default.existsSync(this.iconPath)) {
54
+ if (!import_node_fs.default.existsSync(this.iconPath)) {
55
55
  throw new Error(
56
56
  `[${this.name}] Can not find the app icon, please check if the '${this.iconPath}' file exists'.`
57
57
  );
58
58
  }
59
- const iconRelativePath = import_path.posix.join(this.distDir, (0, import_path.basename)(this.iconPath));
59
+ const iconRelativePath = import_node_path.posix.join(this.distDir, (0, import_node_path.basename)(this.iconPath));
60
60
  compiler.hooks.compilation.tap(this.name, (compilation) => {
61
61
  (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTagGroups.tap(this.name, (data) => {
62
62
  const publicPath = (0, import_shared.getPublicPathFromCompiler)(compiler);
@@ -82,7 +82,7 @@ class HtmlAppIconPlugin {
82
82
  stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_PRE_PROCESS
83
83
  },
84
84
  (assets) => {
85
- const source = import_fs.default.readFileSync(this.iconPath);
85
+ const source = import_node_fs.default.readFileSync(this.iconPath);
86
86
  assets[iconRelativePath] = new import_webpack_sources.default.RawSource(
87
87
  source,
88
88
  false
@@ -26,7 +26,7 @@ __export(InlineChunkHtmlPlugin_exports, {
26
26
  InlineChunkHtmlPlugin: () => InlineChunkHtmlPlugin
27
27
  });
28
28
  module.exports = __toCommonJS(InlineChunkHtmlPlugin_exports);
29
- var import_path = require("path");
29
+ var import_node_path = require("node:path");
30
30
  var import_shared = require("@rsbuild/shared");
31
31
  var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
32
32
  class InlineChunkHtmlPlugin {
@@ -61,7 +61,7 @@ class InlineChunkHtmlPlugin {
61
61
  if (devtool && // If the source map is inlined, we do not need to update the sourceMappingURL
62
62
  !devtool.includes("inline") && source.includes("# sourceMappingURL")) {
63
63
  const prefix = (0, import_shared.addTrailingSlash)(
64
- (0, import_path.join)(publicPath, this.distPath[type] || "")
64
+ (0, import_node_path.join)(publicPath, this.distPath[type] || "")
65
65
  );
66
66
  return source.replace(
67
67
  /# sourceMappingURL=/,
@@ -31,8 +31,9 @@ __export(determineAsValue_exports, {
31
31
  determineAsValue: () => determineAsValue
32
32
  });
33
33
  module.exports = __toCommonJS(determineAsValue_exports);
34
- var import_path = __toESM(require("path"));
35
- var import_url = require("url");
34
+ var import_node_path = __toESM(require("node:path"));
35
+ var import_node_url = require("node:url");
36
+ var import_shared = require("@rsbuild/shared");
36
37
  /**
37
38
  * @license
38
39
  * Copyright 2018 Google Inc.
@@ -54,41 +55,24 @@ function determineAsValue({
54
55
  href,
55
56
  file
56
57
  }) {
57
- const url = new import_url.URL(file || href, "https://example.com");
58
- const extension = import_path.default.extname(url.pathname);
59
- if ([".css"].includes(extension)) {
58
+ const url = new import_node_url.URL(file || href, "https://example.com");
59
+ const extension = import_node_path.default.extname(url.pathname).slice(1);
60
+ if (["css"].includes(extension)) {
60
61
  return "style";
61
62
  }
62
- if ([
63
- ".png",
64
- ".jpg",
65
- ".jpeg",
66
- ".jfif",
67
- ".pjpeg",
68
- ".pjp",
69
- ".svg",
70
- ".webp",
71
- ".bmp",
72
- ".apng",
73
- ".avif",
74
- ".gif",
75
- ".ico",
76
- ".cur",
77
- ".tif",
78
- ".tiff"
79
- ].includes(extension)) {
63
+ if (import_shared.IMAGE_EXTENSIONS.includes(extension)) {
80
64
  return "image";
81
65
  }
82
- if ([".mp4", ".ogg", ".webm"].includes(extension)) {
66
+ if (import_shared.VIDEO_EXTENSIONS.includes(extension)) {
83
67
  return "video";
84
68
  }
85
- if ([".mp3", ".wav"].includes(extension)) {
69
+ if (import_shared.AUDIO_EXTENSIONS.includes(extension)) {
86
70
  return "audio";
87
71
  }
88
- if ([".woff2", ".otf", ".ttf", ".woff", ".eot"].includes(extension)) {
72
+ if (import_shared.FONT_EXTENSIONS.includes(extension)) {
89
73
  return "font";
90
74
  }
91
- if ([".vtt"].includes(extension)) {
75
+ if (["vtt"].includes(extension)) {
92
76
  return "track";
93
77
  }
94
78
  return "script";
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import type { IncomingMessage } from 'http';
4
- import type { Socket } from 'net';
3
+ import type { IncomingMessage } from 'node:http';
4
+ import type { Socket } from 'node:net';
5
5
  import type { DevMiddlewaresConfig, DevMiddlewareAPI, DevMiddleware as CustomDevMiddleware } from '@rsbuild/shared';
6
6
  type Options = {
7
7
  publicPaths: string[];
@@ -31,9 +31,9 @@ __export(getDevMiddlewares_exports, {
31
31
  getMiddlewares: () => getMiddlewares
32
32
  });
33
33
  module.exports = __toCommonJS(getDevMiddlewares_exports);
34
- var import_url = __toESM(require("url"));
34
+ var import_node_url = __toESM(require("node:url"));
35
35
  var import_middlewares = require("./middlewares");
36
- var import_path = require("path");
36
+ var import_node_path = require("node:path");
37
37
  const applySetupMiddlewares = (dev, compileMiddlewareAPI) => {
38
38
  const setupMiddlewares = dev.setupMiddlewares || [];
39
39
  const serverOptions = {
@@ -71,7 +71,7 @@ const applyDefaultMiddlewares = async ({
71
71
  }
72
72
  middlewares.push((req, res, next) => {
73
73
  res.setHeader("Access-Control-Allow-Origin", "*");
74
- const path = req.url ? import_url.default.parse(req.url).pathname : "";
74
+ const path = req.url ? import_node_url.default.parse(req.url).pathname : "";
75
75
  if (path?.includes("hot-update")) {
76
76
  res.setHeader("Access-Control-Allow-Credentials", "false");
77
77
  }
@@ -104,7 +104,7 @@ const applyDefaultMiddlewares = async ({
104
104
  if (dev.publicDir !== false && dev.publicDir?.name) {
105
105
  const { default: sirv } = await Promise.resolve().then(() => __toESM(require("../../compiled/sirv")));
106
106
  const { name } = dev.publicDir;
107
- const publicDir = (0, import_path.isAbsolute)(name) ? name : (0, import_path.join)(pwd, name);
107
+ const publicDir = (0, import_node_path.isAbsolute)(name) ? name : (0, import_node_path.join)(pwd, name);
108
108
  const assetMiddleware = sirv(publicDir, {
109
109
  etag: true,
110
110
  dev: true
@@ -114,7 +114,7 @@ const applyDefaultMiddlewares = async ({
114
114
  const { distPath } = output;
115
115
  compileMiddlewareAPI && middlewares.push(
116
116
  (0, import_middlewares.getHtmlFallbackMiddleware)({
117
- distPath: (0, import_path.isAbsolute)(distPath) ? distPath : (0, import_path.join)(pwd, distPath),
117
+ distPath: (0, import_node_path.isAbsolute)(distPath) ? distPath : (0, import_node_path.join)(pwd, distPath),
118
118
  callback: compileMiddlewareAPI.middleware,
119
119
  htmlFallback: dev.htmlFallback
120
120
  })
@@ -33,10 +33,10 @@ __export(httpServer_exports, {
33
33
  module.exports = __toCommonJS(httpServer_exports);
34
34
  const createHttpServer = async (options) => {
35
35
  if (options.https) {
36
- const { createServer: createServer2 } = await Promise.resolve().then(() => __toESM(require("https")));
36
+ const { createServer: createServer2 } = await Promise.resolve().then(() => __toESM(require("node:https")));
37
37
  return createServer2(options.https, options.middlewares);
38
38
  }
39
- const { createServer } = await Promise.resolve().then(() => __toESM(require("http")));
39
+ const { createServer } = await Promise.resolve().then(() => __toESM(require("node:http")));
40
40
  return createServer(options.middlewares);
41
41
  };
42
42
  // Annotate the CommonJS export names for ESM import in node:
@@ -34,9 +34,9 @@ __export(middlewares_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(middlewares_exports);
36
36
  var import_shared = require("@rsbuild/shared");
37
- var import_url = require("url");
38
- var import_path = __toESM(require("path"));
39
- var import_fs = __toESM(require("fs"));
37
+ var import_node_url = require("node:url");
38
+ var import_node_path = __toESM(require("node:path"));
39
+ var import_node_fs = __toESM(require("node:fs"));
40
40
  const faviconFallbackMiddleware = (req, res, next) => {
41
41
  if (req.url === "/favicon.ico") {
42
42
  res.statusCode = 204;
@@ -63,14 +63,14 @@ const getHtmlFallbackMiddleware = ({ htmlFallback, distPath, callback }) => {
63
63
  const { url } = req;
64
64
  let pathname = url;
65
65
  try {
66
- pathname = (0, import_url.parse)(url, false, true).pathname;
66
+ pathname = (0, import_node_url.parse)(url, false, true).pathname;
67
67
  } catch (err) {
68
68
  import_shared.logger.error(
69
69
  new Error(`Invalid URL: ${import_shared.color.yellow(url)}`, { cause: err })
70
70
  );
71
71
  return next();
72
72
  }
73
- let outputFileSystem = import_fs.default;
73
+ let outputFileSystem = import_node_fs.default;
74
74
  if (res.locals.webpack) {
75
75
  const { devMiddleware } = res.locals.webpack;
76
76
  outputFileSystem = devMiddleware.outputFileSystem;
@@ -87,7 +87,7 @@ const getHtmlFallbackMiddleware = ({ htmlFallback, distPath, callback }) => {
87
87
  };
88
88
  if (pathname.endsWith("/")) {
89
89
  const newUrl = `${pathname}index.html`;
90
- const filePath = import_path.default.join(distPath, pathname, "index.html");
90
+ const filePath = import_node_path.default.join(distPath, pathname, "index.html");
91
91
  if (outputFileSystem.existsSync(filePath)) {
92
92
  return rewrite(newUrl);
93
93
  }
@@ -96,13 +96,13 @@ const getHtmlFallbackMiddleware = ({ htmlFallback, distPath, callback }) => {
96
96
  !pathname.endsWith(".html")
97
97
  ) {
98
98
  const newUrl = `${pathname}.html`;
99
- const filePath = import_path.default.join(distPath, `${pathname}.html`);
99
+ const filePath = import_node_path.default.join(distPath, `${pathname}.html`);
100
100
  if (outputFileSystem.existsSync(filePath)) {
101
101
  return rewrite(newUrl);
102
102
  }
103
103
  }
104
104
  if (htmlFallback === "index") {
105
- if (outputFileSystem.existsSync(import_path.default.join(distPath, "index.html"))) {
105
+ if (outputFileSystem.existsSync(import_node_path.default.join(distPath, "index.html"))) {
106
106
  return rewrite("/index.html");
107
107
  }
108
108
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { Server } from 'http';
2
+ import type { Server } from 'node:http';
3
3
  import connect from '@rsbuild/shared/connect';
4
4
  import { type ServerConfig, type RsbuildConfig, type StartServerResult, type PreviewServerOptions } from '@rsbuild/shared';
5
5
  import type { InternalContext } from '../types';
@@ -38,7 +38,7 @@ __export(prodServer_exports, {
38
38
  });
39
39
  module.exports = __toCommonJS(prodServer_exports);
40
40
  var import_connect = __toESM(require("@rsbuild/shared/connect"));
41
- var import_path = require("path");
41
+ var import_node_path = require("node:path");
42
42
  var import_sirv = __toESM(require("../../compiled/sirv"));
43
43
  var import_shared = require("@rsbuild/shared");
44
44
  var import_helper = require("./helper");
@@ -100,7 +100,7 @@ class RsbuildProdServer {
100
100
  serverConfig: { htmlFallback },
101
101
  pwd
102
102
  } = this.options;
103
- const assetMiddleware = (0, import_sirv.default)((0, import_path.join)(pwd, path), {
103
+ const assetMiddleware = (0, import_sirv.default)((0, import_node_path.join)(pwd, path), {
104
104
  etag: true,
105
105
  dev: true,
106
106
  ignores: ["favicon.ico"],
@@ -32,7 +32,7 @@ __export(restart_exports, {
32
32
  restartDevServer: () => restartDevServer
33
33
  });
34
34
  module.exports = __toCommonJS(restart_exports);
35
- var import_path = __toESM(require("path"));
35
+ var import_node_path = __toESM(require("node:path"));
36
36
  var import_shared = require("@rsbuild/shared");
37
37
  var import_commands = require("../cli/commands");
38
38
  let cleaners = [];
@@ -46,7 +46,7 @@ const clearConsole = () => {
46
46
  };
47
47
  const restartDevServer = async ({ filePath }) => {
48
48
  clearConsole();
49
- const filename = import_path.default.basename(filePath);
49
+ const filename = import_node_path.default.basename(filePath);
50
50
  import_shared.logger.info(`Restart because ${import_shared.color.yellow(filename)} is changed.
51
51
  `);
52
52
  for (const cleaner of cleaners) {
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import type { IncomingMessage } from 'http';
4
- import type { Socket } from 'net';
3
+ import type { IncomingMessage } from 'node:http';
4
+ import type { Socket } from 'node:net';
5
5
  import ws from '../../compiled/ws';
6
6
  import { type Stats, type DevMiddlewaresConfig } from '@rsbuild/shared';
7
7
  export declare class SocketServer {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -57,7 +57,7 @@
57
57
  "core-js": "~3.32.2",
58
58
  "html-webpack-plugin": "npm:html-rspack-plugin@5.5.7",
59
59
  "postcss": "^8.4.33",
60
- "@rsbuild/shared": "0.3.6"
60
+ "@rsbuild/shared": "0.3.7"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "16.x",
package/types.d.ts CHANGED
@@ -17,6 +17,14 @@ declare module '*.jpeg' {
17
17
  const src: string;
18
18
  export default src;
19
19
  }
20
+ declare module '*.pjpeg' {
21
+ const src: string;
22
+ export default src;
23
+ }
24
+ declare module '*.pjp' {
25
+ const src: string;
26
+ export default src;
27
+ }
20
28
  declare module '*.png' {
21
29
  const src: string;
22
30
  export default src;
@@ -41,10 +49,18 @@ declare module '*.avif' {
41
49
  const src: string;
42
50
  export default src;
43
51
  }
52
+ declare module '*.tif' {
53
+ const src: string;
54
+ export default src;
55
+ }
44
56
  declare module '*.tiff' {
45
57
  const src: string;
46
58
  export default src;
47
59
  }
60
+ declare module '*.jfif' {
61
+ const src: string;
62
+ export default src;
63
+ }
48
64
 
49
65
  /**
50
66
  * Font assets
@@ -109,6 +125,14 @@ declare module '*.mov' {
109
125
  const src: string;
110
126
  export default src;
111
127
  }
128
+ declare module '*.m4a' {
129
+ const src: string;
130
+ export default src;
131
+ }
132
+ declare module '*.opus' {
133
+ const src: string;
134
+ export default src;
135
+ }
112
136
 
113
137
  /**
114
138
  * Configuration files