@rsbuild/core 2.0.0-beta.2 → 2.0.0-beta.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.
@@ -0,0 +1,133 @@
1
+ {
2
+ "name": "jiti",
3
+ "version": "2.6.1",
4
+ "description": "Runtime typescript and ESM support for Node.js",
5
+ "repository": "unjs/jiti",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./lib/jiti.d.mts",
12
+ "default": "./lib/jiti.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./lib/jiti.d.cts",
16
+ "default": "./lib/jiti.cjs"
17
+ }
18
+ },
19
+ "./register": {
20
+ "types": "./lib/jiti-register.d.mts",
21
+ "import": "./lib/jiti-register.mjs"
22
+ },
23
+ "./native": {
24
+ "types": "./lib/jiti.d.mts",
25
+ "import": "./lib/jiti-native.mjs"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "main": "./lib/jiti.cjs",
30
+ "module": "./lib/jiti.mjs",
31
+ "types": "./lib/jiti.d.cts",
32
+ "typesVersions": {
33
+ "*": {
34
+ "register": [
35
+ "./lib/jiti-register.d.mts"
36
+ ],
37
+ "native": [
38
+ "./lib/jiti.d.mts"
39
+ ]
40
+ }
41
+ },
42
+ "bin": {
43
+ "jiti": "./lib/jiti-cli.mjs"
44
+ },
45
+ "files": [
46
+ "lib",
47
+ "dist",
48
+ "register.cjs"
49
+ ],
50
+ "scripts": {
51
+ "bench": "node test/bench.mjs && deno -A test/bench.mjs && bun --bun test/bench.mjs",
52
+ "build": "pnpm clean && pnpm rspack",
53
+ "clean": "rm -rf dist",
54
+ "dev": "pnpm clean && pnpm rspack --watch",
55
+ "jiti": "JITI_DEBUG=1 JITI_JSX=1 lib/jiti-cli.mjs",
56
+ "lint": "eslint . && prettier -c src lib test stubs",
57
+ "lint:fix": "eslint --fix . && prettier -w src lib test stubs",
58
+ "prepack": "pnpm build",
59
+ "release": "pnpm build && pnpm test && changelogen --release --push --publish",
60
+ "test": "pnpm lint && pnpm test:types && vitest run --coverage && pnpm test:node-register && pnpm test:bun && pnpm test:native",
61
+ "test:bun": "bun --bun test test/bun",
62
+ "test:native": "pnpm test:native:bun && pnpm test:native:node && pnpm test:native:deno",
63
+ "test:native:bun": "bun --bun test test/native/bun.test.ts",
64
+ "test:native:deno": "deno test -A --no-check test/native/deno.test.ts",
65
+ "test:native:node": "node --test --experimental-strip-types test/native/node.test.ts",
66
+ "test:node-register": "JITI_JSX=1 node --test test/node-register.test.mjs",
67
+ "test:types": "tsc --noEmit"
68
+ },
69
+ "devDependencies": {
70
+ "@babel/core": "^7.28.4",
71
+ "@babel/helper-module-imports": "^7.27.1",
72
+ "@babel/helper-module-transforms": "^7.28.3",
73
+ "@babel/helper-plugin-utils": "^7.27.1",
74
+ "@babel/helper-simple-access": "^7.27.1",
75
+ "@babel/plugin-proposal-decorators": "^7.28.0",
76
+ "@babel/plugin-syntax-class-properties": "^7.12.13",
77
+ "@babel/plugin-syntax-import-assertions": "^7.27.1",
78
+ "@babel/plugin-syntax-jsx": "^7.27.1",
79
+ "@babel/plugin-transform-export-namespace-from": "^7.27.1",
80
+ "@babel/plugin-transform-react-jsx": "^7.27.1",
81
+ "@babel/plugin-transform-typescript": "^7.28.0",
82
+ "@babel/preset-typescript": "^7.27.1",
83
+ "@babel/template": "^7.27.2",
84
+ "@babel/traverse": "^7.28.4",
85
+ "@babel/types": "^7.28.4",
86
+ "@rspack/cli": "^1.5.8",
87
+ "@rspack/core": "^1.5.8",
88
+ "@types/babel__core": "^7.20.5",
89
+ "@types/babel__helper-module-imports": "^7.18.3",
90
+ "@types/babel__helper-plugin-utils": "^7.10.3",
91
+ "@types/babel__template": "^7.4.4",
92
+ "@types/babel__traverse": "^7.28.0",
93
+ "@types/node": "^24.6.1",
94
+ "@vitest/coverage-v8": "^3.2.4",
95
+ "acorn": "^8.15.0",
96
+ "babel-plugin-parameter-decorator": "^1.0.16",
97
+ "changelogen": "^0.6.2",
98
+ "config": "^4.1.1",
99
+ "consola": "^3.4.2",
100
+ "defu": "^6.1.4",
101
+ "destr": "^2.0.5",
102
+ "escape-string-regexp": "^5.0.0",
103
+ "eslint": "^9.36.0",
104
+ "eslint-config-unjs": "^0.5.0",
105
+ "estree-walker": "^3.0.3",
106
+ "etag": "^1.8.1",
107
+ "fast-glob": "^3.3.3",
108
+ "is-installed-globally": "^1.0.0",
109
+ "mime": "^4.1.0",
110
+ "mlly": "^1.8.0",
111
+ "moment-timezone": "^0.6.0",
112
+ "nano-jsx": "^0.2.0",
113
+ "pathe": "^2.0.3",
114
+ "pkg-types": "^2.3.0",
115
+ "preact": "^10.27.2",
116
+ "preact-render-to-string": "^6.6.2",
117
+ "prettier": "^3.6.2",
118
+ "react": "^19.1.1",
119
+ "react-dom": "^19.1.1",
120
+ "reflect-metadata": "^0.2.2",
121
+ "solid-js": "^1.9.9",
122
+ "std-env": "^3.9.0",
123
+ "terser-webpack-plugin": "^5.3.14",
124
+ "tinyexec": "^1.0.1",
125
+ "ts-loader": "^9.5.4",
126
+ "typescript": "^5.9.3",
127
+ "vitest": "^3.2.4",
128
+ "vue": "^3.5.22",
129
+ "yoctocolors": "^2.1.2",
130
+ "zod": "^4.1.11"
131
+ },
132
+ "packageManager": "pnpm@10.17.1"
133
+ }
@@ -1,15 +1,15 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 937: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(251)["default"];
4
+ 561: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(483)["default"];
6
6
  },
7
- 251: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 483: (__unused_webpack_module, exports, __nccwpck_require__) => {
8
8
  var __webpack_unused_export__;
9
9
  __webpack_unused_export__ = { value: true };
10
10
  exports["default"] = loader;
11
11
  var _nodePath = _interopRequireDefault(__nccwpck_require__(760));
12
- var _utils = __nccwpck_require__(30);
12
+ var _utils = __nccwpck_require__(646);
13
13
  function _interopRequireDefault(e) {
14
14
  return e && e.__esModule ? e : { default: e };
15
15
  }
@@ -179,7 +179,7 @@
179
179
  callback(null, result.css, map, { ast });
180
180
  }
181
181
  },
182
- 30: (module, exports, __nccwpck_require__) => {
182
+ 646: (module, exports, __nccwpck_require__) => {
183
183
  module = __nccwpck_require__.nmd(module);
184
184
  Object.defineProperty(exports, "__esModule", { value: true });
185
185
  exports.exec = exec;
@@ -309,7 +309,7 @@
309
309
  };
310
310
  if (!tsLoader) {
311
311
  const opts = { interopDefault: true };
312
- const { createJiti } = __nccwpck_require__(549);
312
+ const { createJiti } = __nccwpck_require__(966);
313
313
  const jiti = createJiti(__filename, opts);
314
314
  tsLoader = (filepath) => jiti.import(filepath, { default: true });
315
315
  }
@@ -668,8 +668,8 @@
668
668
  return obj;
669
669
  }
670
670
  },
671
- 549: (module) => {
672
- module.exports = require("jiti");
671
+ 966: (module) => {
672
+ module.exports = require("../jiti");
673
673
  },
674
674
  995: (module) => {
675
675
  module.exports = require("node:module");
@@ -715,6 +715,6 @@
715
715
  })();
716
716
  if (typeof __nccwpck_require__ !== "undefined")
717
717
  __nccwpck_require__.ab = __dirname + "/";
718
- var __webpack_exports__ = __nccwpck_require__(937);
718
+ var __webpack_exports__ = __nccwpck_require__(561);
719
719
  module.exports = __webpack_exports__;
720
720
  })();
@@ -1,16 +1,16 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 15: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- const loader = __nccwpck_require__(545);
4
+ 139: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ const loader = __nccwpck_require__(669);
6
6
  module.exports = loader.default;
7
7
  },
8
- 545: (__unused_webpack_module, exports, __nccwpck_require__) => {
8
+ 669: (__unused_webpack_module, exports, __nccwpck_require__) => {
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports["default"] = void 0;
11
11
  var _path = _interopRequireDefault(__nccwpck_require__(928));
12
- var _utils = __nccwpck_require__(476);
13
- var _options = _interopRequireDefault(__nccwpck_require__(483));
12
+ var _utils = __nccwpck_require__(256);
13
+ var _options = _interopRequireDefault(__nccwpck_require__(671));
14
14
  function _interopRequireDefault(obj) {
15
15
  return obj && obj.__esModule ? obj : { default: obj };
16
16
  }
@@ -104,7 +104,7 @@
104
104
  };
105
105
  var _default = (exports["default"] = loader);
106
106
  },
107
- 150: (module) => {
107
+ 58: (module) => {
108
108
  function isEqualLocals(a, b, isNamedExport) {
109
109
  if ((!a && b) || (a && !b)) {
110
110
  return false;
@@ -130,7 +130,7 @@
130
130
  }
131
131
  module.exports = isEqualLocals;
132
132
  },
133
- 476: (__unused_webpack_module, exports, __nccwpck_require__) => {
133
+ 256: (__unused_webpack_module, exports, __nccwpck_require__) => {
134
134
  Object.defineProperty(exports, "__esModule", { value: true });
135
135
  exports.getExportLazyStyleCode = getExportLazyStyleCode;
136
136
  exports.getExportStyleCode = getExportStyleCode;
@@ -151,7 +151,7 @@
151
151
  exports.getdomAPI = getdomAPI;
152
152
  exports.stringifyRequest = stringifyRequest;
153
153
  var _path = _interopRequireDefault(__nccwpck_require__(928));
154
- var _isEqualLocals = _interopRequireDefault(__nccwpck_require__(150));
154
+ var _isEqualLocals = _interopRequireDefault(__nccwpck_require__(58));
155
155
  function _interopRequireDefault(obj) {
156
156
  return obj && obj.__esModule ? obj : { default: obj };
157
157
  }
@@ -394,7 +394,7 @@
394
394
  928: (module) => {
395
395
  module.exports = require("path");
396
396
  },
397
- 483: (module) => {
397
+ 671: (module) => {
398
398
  module.exports = JSON.parse(
399
399
  '{"title":"Style Loader options","type":"object","properties":{"injectType":{"description":"Allows to setup how styles will be injected into DOM.","link":"https://github.com/webpack-contrib/style-loader#injecttype","enum":["styleTag","singletonStyleTag","autoStyleTag","lazyStyleTag","lazySingletonStyleTag","lazyAutoStyleTag","linkTag"]},"attributes":{"description":"Adds custom attributes to tag.","link":"https://github.com/webpack-contrib/style-loader#attributes","type":"object"},"insert":{"description":"Inserts `<style>`/`<link>` at the given position.","link":"https://github.com/webpack-contrib/style-loader#insert","anyOf":[{"type":"string"},{"instanceof":"Function"}]},"base":{"description":"Sets module ID base for DLLPlugin.","link":"https://github.com/webpack-contrib/style-loader#base","type":"number"},"esModule":{"description":"Use the ES modules syntax.","link":"https://github.com/webpack-contrib/css-loader#esmodule","type":"boolean"},"styleTagTransform":{"description":"Transform tag and css when insert \'style\' tag into the DOM","link":"https://github.com/webpack-contrib/style-loader#styleTagTransform","anyOf":[{"type":"string"},{"instanceof":"Function"}]}},"additionalProperties":false}',
400
400
  );
@@ -422,6 +422,6 @@
422
422
  }
423
423
  if (typeof __nccwpck_require__ !== "undefined")
424
424
  __nccwpck_require__.ab = __dirname + "/";
425
- var __webpack_exports__ = __nccwpck_require__(15);
425
+ var __webpack_exports__ = __nccwpck_require__(139);
426
426
  module.exports = __webpack_exports__;
427
427
  })();
package/dist/131.js CHANGED
@@ -904,7 +904,7 @@ __webpack_require__.add({
904
904
  return loaded && '__esModule' in loaded ? loaded.default : loaded;
905
905
  }
906
906
  if (void 0 === jiti) try {
907
- jiti = (await import("jiti")).default;
907
+ jiti = (await import("../compiled/jiti/lib/jiti.mjs")).default;
908
908
  } catch (error) {
909
909
  importError.push(error);
910
910
  }
@@ -2217,7 +2217,7 @@ let external_node_module_ = __webpack_require__("node:module"), vendors_require
2217
2217
  isMergeableObject: isPlainObject
2218
2218
  });
2219
2219
  function getFilename(config, type, isProd, isServer) {
2220
- let { filename, filenameHash } = config.output, defaultHash = '[contenthash:8]', getHash = ()=>'string' == typeof filenameHash ? filenameHash ? `.[${filenameHash}]` : '' : filenameHash ? `.${defaultHash}` : '';
2220
+ let { filename, filenameHash } = config.output, defaultHash = '[contenthash:10]', getHash = ()=>'string' == typeof filenameHash ? filenameHash ? `.[${filenameHash}]` : '' : filenameHash ? `.${defaultHash}` : '';
2221
2221
  switch(type){
2222
2222
  case 'js':
2223
2223
  return filename.js ?? `[name]${isProd && !isServer ? getHash() : ''}.js`;
@@ -2270,7 +2270,7 @@ async function helpers_hash(data) {
2270
2270
  }
2271
2271
  let compiler_isMultiCompiler = (compiler)=>'compilers' in compiler && Array.isArray(compiler.compilers), getPublicPathFromCompiler = (compiler)=>{
2272
2272
  let { publicPath } = compiler.options.output;
2273
- return 'string' == typeof publicPath ? 'auto' === publicPath ? '' : publicPath.endsWith('/') ? publicPath : `${publicPath}/` : DEFAULT_ASSET_PREFIX;
2273
+ return 'string' == typeof publicPath ? 'auto' === publicPath || '' === publicPath ? '' : publicPath.endsWith('/') ? publicPath : `${publicPath}/` : DEFAULT_ASSET_PREFIX;
2274
2274
  }, applyToCompiler = (compiler, apply)=>{
2275
2275
  compiler_isMultiCompiler(compiler) ? compiler.compilers.forEach(apply) : apply(compiler, 0);
2276
2276
  }, addCompilationError = (compilation, message)=>{
@@ -3004,7 +3004,7 @@ function exitHook(onExit) {
3004
3004
  let external_node_url_ = __webpack_require__("node:url"), addTrailingSlash = (s)=>s.endsWith('/') ? s : `${s}/`, isURL = (str)=>str.startsWith('http') || str.startsWith('//'), urlJoin = (base, path)=>{
3005
3005
  let [urlProtocol, baseUrl] = base.split('://');
3006
3006
  return `${urlProtocol}://${external_node_path_.posix.join(baseUrl, path)}`;
3007
- }, ensureAssetPrefix = (url, assetPrefix = DEFAULT_ASSET_PREFIX)=>url.startsWith('//') || external_node_url_.URL.canParse(url) || 'auto' === assetPrefix || 'function' == typeof assetPrefix ? url : assetPrefix.startsWith('http') ? urlJoin(assetPrefix, url) : assetPrefix.startsWith('//') ? urlJoin(`https:${assetPrefix}`, url).replace('https:', '') : external_node_path_.posix.join(assetPrefix, url), formatPublicPath = (publicPath, withSlash = !0)=>'auto' === publicPath ? publicPath : withSlash ? addTrailingSlash(publicPath) : publicPath.replace(/\/+$/, ''), getPublicPathFromChain = (chain, withSlash = !0)=>{
3007
+ }, ensureAssetPrefix = (url, assetPrefix = DEFAULT_ASSET_PREFIX)=>url.startsWith('//') || external_node_url_.URL.canParse(url) || 'auto' === assetPrefix || 'function' == typeof assetPrefix ? url : assetPrefix.startsWith('http') ? urlJoin(assetPrefix, url) : assetPrefix.startsWith('//') ? urlJoin(`https:${assetPrefix}`, url).replace('https:', '') : external_node_path_.posix.join(assetPrefix, url), formatPublicPath = (publicPath, withSlash = !0)=>'auto' === publicPath || '' === publicPath ? publicPath : withSlash ? addTrailingSlash(publicPath) : publicPath.replace(/\/+$/, ''), getPublicPathFromChain = (chain, withSlash = !0)=>{
3008
3008
  let publicPath = chain.output.get('publicPath');
3009
3009
  return 'string' == typeof publicPath ? formatPublicPath(publicPath, withSlash) : formatPublicPath(DEFAULT_ASSET_PREFIX, withSlash);
3010
3010
  };
@@ -3399,7 +3399,7 @@ function createPublicContext(context) {
3399
3399
  async function createContext(options, userConfig) {
3400
3400
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
3401
3401
  return {
3402
- version: "2.0.0-beta.2",
3402
+ version: "2.0.0-beta.4",
3403
3403
  rootPath,
3404
3404
  distPath: '',
3405
3405
  cachePath,
@@ -3710,16 +3710,9 @@ function validateRspackConfig(config) {
3710
3710
  config.devServer && src_logger.warn(`${color.dim('[rsbuild:config]')} Find invalid Rspack config: "${color.yellow('devServer')}". Note that Rspack's "devServer" config is not supported by Rsbuild. You can use Rsbuild's "dev" config to configure the Rsbuild dev server.`);
3711
3711
  }
3712
3712
  async function generateRspackConfig({ target, context, environmentName }) {
3713
- let chainUtils = getChainUtils(target, context.environments[environmentName], context.environments), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = core_rspack, rspackConfig = (await modifyBundlerChain(context, {
3713
+ let chainUtils = getChainUtils(target, context.environments[environmentName], context.environments), rspackConfig = (await modifyBundlerChain(context, {
3714
3714
  ...chainUtils,
3715
- bundler: {
3716
- BannerPlugin,
3717
- DefinePlugin,
3718
- IgnorePlugin,
3719
- ProvidePlugin,
3720
- SourceMapDevToolPlugin,
3721
- HotModuleReplacementPlugin
3722
- }
3715
+ bundler: core_rspack
3723
3716
  })).toConfig();
3724
3717
  return validateRspackConfig(rspackConfig = await modifyRspackConfig(context, rspackConfig, chainUtils)), rspackConfig;
3725
3718
  }
@@ -5953,13 +5946,19 @@ function setupWriteToDisk(compilers, writeToDisk) {
5953
5946
  }), compiler.__hasRsbuildAssetEmittedCallback = !0);
5954
5947
  });
5955
5948
  }
5956
- let noop = ()=>{}, isTsError = (error)=>'message' in error && error.stack?.includes('ts-checker-rspack-plugin');
5949
+ let noop = ()=>{}, normalizeLiveReload = (liveReload)=>'boolean' == typeof liveReload ? {
5950
+ enabled: liveReload,
5951
+ html: liveReload
5952
+ } : {
5953
+ enabled: !0,
5954
+ html: !1 !== liveReload.html
5955
+ }, isTsError = (error)=>'message' in error && error.stack?.includes('ts-checker-rspack-plugin');
5957
5956
  function applyHMREntry({ config, compiler, token, resolvedHost, resolvedPort }) {
5958
5957
  if (!((compiler)=>{
5959
5958
  let { target } = compiler.options;
5960
5959
  return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
5961
5960
  })(compiler) || !config.dev.hmr && !config.dev.liveReload) return;
5962
- let clientConfig = {
5961
+ let { enabled: liveReloadEnabled } = normalizeLiveReload(config.dev.liveReload), clientConfig = {
5963
5962
  ...config.dev.client
5964
5963
  };
5965
5964
  '<port>' === clientConfig.port && (clientConfig.port = resolvedPort);
@@ -5970,7 +5969,7 @@ init(
5970
5969
  ${JSON.stringify(clientConfig)},
5971
5970
  ${JSON.stringify(resolvedHost)},
5972
5971
  ${resolvedPort},
5973
- ${config.dev.liveReload},
5972
+ ${liveReloadEnabled},
5974
5973
  ${!!config.dev.browserLogs},
5975
5974
  ${JSON.stringify(config.dev.client.logLevel)}
5976
5975
  )
@@ -5992,14 +5991,14 @@ let assets_middleware_assetsMiddleware = async ({ config, compiler, context, soc
5992
5991
  compiler,
5993
5992
  resolvedHost,
5994
5993
  resolvedPort
5995
- }), (({ context, compiler, token, socketServer })=>{
5994
+ }), (({ context, compiler, token, socketServer, liveReload })=>{
5996
5995
  if (((compiler)=>{
5997
5996
  let { target } = compiler.options;
5998
5997
  return !!target && (Array.isArray(target) ? target.includes('node') : 'node' === target);
5999
5998
  })(compiler)) return;
6000
5999
  let errorsCount = null, warningsCount = null;
6001
6000
  compiler.hooks.invalid.tap('rsbuild-dev-server', (fileName)=>{
6002
- errorsCount = null, warningsCount = null, 'string' == typeof fileName && fileName.endsWith('.html') && socketServer.sockWrite({
6001
+ errorsCount = null, warningsCount = null, 'string' == typeof fileName && fileName.endsWith('.html') && normalizeLiveReload(liveReload).html && socketServer.sockWrite({
6003
6002
  type: 'static-changed'
6004
6003
  }, token);
6005
6004
  }), compiler.hooks.done.tap('rsbuild-dev-server', (stats)=>{
@@ -6031,7 +6030,8 @@ let assets_middleware_assetsMiddleware = async ({ config, compiler, context, soc
6031
6030
  context,
6032
6031
  compiler,
6033
6032
  socketServer,
6034
- token
6033
+ token,
6034
+ liveReload: environment.config.dev.liveReload
6035
6035
  }));
6036
6036
  });
6037
6037
  let compilers = compiler_isMultiCompiler(compiler) ? compiler.compilers : [
@@ -6531,7 +6531,7 @@ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls,
6531
6531
  input: process.stdin
6532
6532
  });
6533
6533
  return rl.on('line', (input)=>{
6534
- if ('h' === input) {
6534
+ if ('h' === (input = input.trim().toLowerCase())) {
6535
6535
  let message = `\n ${color.bold(color.blue('Shortcuts:'))}\n`;
6536
6536
  for (let shortcut of shortcuts)message += ` ${shortcut.description}\n`;
6537
6537
  src_logger.log(message);
@@ -7528,21 +7528,17 @@ function applyDefaultPlugins(pluginManager, context) {
7528
7528
  {
7529
7529
  name: 'rsbuild:basic',
7530
7530
  setup (api) {
7531
- api.modifyBundlerChain((chain, { isDev, target, bundler, environment, CHAIN_ID })=>{
7531
+ api.modifyBundlerChain((chain, { isDev, target, rspack, environment, CHAIN_ID })=>{
7532
7532
  let { config } = environment;
7533
7533
  chain.name(environment.name), chain.context(api.context.rootPath), chain.mode(environment.config.mode), chain.infrastructureLogging({
7534
7534
  level: 'error'
7535
7535
  }), chain.watchOptions({
7536
7536
  aggregateTimeout: 0
7537
7537
  }), chain.performance.hints(!1), chain.module.parser.merge({
7538
- javascript: {
7539
- exportsPresence: 'error'
7540
- }
7541
- }), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), chain.module.parser.merge({
7542
7538
  javascript: {
7543
7539
  typeReexportsPresence: 'tolerant'
7544
7540
  }
7545
- });
7541
+ }), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(rspack.HotModuleReplacementPlugin);
7546
7542
  });
7547
7543
  }
7548
7544
  },
@@ -7576,7 +7572,7 @@ function applyDefaultPlugins(pluginManager, context) {
7576
7572
  {
7577
7573
  name: 'rsbuild:source-map',
7578
7574
  setup (api) {
7579
- api.modifyBundlerChain((chain, { bundler, environment, isDev, target })=>{
7575
+ api.modifyBundlerChain((chain, { rspack, environment, isDev, target })=>{
7580
7576
  let { config } = environment, devtool = ((config)=>{
7581
7577
  let { sourceMap } = config.output, isProd = 'production' === config.mode;
7582
7578
  return !1 !== sourceMap && (!0 === sourceMap ? isProd ? 'source-map' : 'cheap-module-source-map' : void 0 === sourceMap.js ? !isProd && 'cheap-module-source-map' : sourceMap.js);
@@ -7584,7 +7580,7 @@ function applyDefaultPlugins(pluginManager, context) {
7584
7580
  chain.devtool(devtool), isDev && 'web' === target ? chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)) : chain.output.devtoolModuleFilenameTemplate('[relative-resource-path]'), !devtool && ((config)=>{
7585
7581
  let { sourceMap } = config.output;
7586
7582
  return 'object' == typeof sourceMap && sourceMap.css;
7587
- })(config) && chain.plugin('source-map-css').use(bundler.SourceMapDevToolPlugin, [
7583
+ })(config) && chain.plugin('source-map-css').use(rspack.SourceMapDevToolPlugin, [
7588
7584
  {
7589
7585
  test: /\.css$/,
7590
7586
  filename: '[file].map[query]'
@@ -7759,7 +7755,13 @@ function applyDefaultPlugins(pluginManager, context) {
7759
7755
  path: targetPath
7760
7756
  };
7761
7757
  })()
7762
- ].filter((pathInfo)=>!!pathInfo))await emptyDir(pathInfo.path, pathInfo.keep);
7758
+ ].filter((pathInfo)=>!!pathInfo)){
7759
+ if ('/' === pathInfo.path) {
7760
+ let prefix = color.dim('[rsbuild:cleanOutput]');
7761
+ throw Error(`${prefix} Refusing to clean output at ${color.cyan(`"${pathInfo.path}"`)}. Update ${color.yellow('`output.distPath.root`')} or set ${color.yellow('`output.cleanDistPath`')} to false.`);
7762
+ }
7763
+ await emptyDir(pathInfo.path, pathInfo.keep);
7764
+ }
7763
7765
  };
7764
7766
  api.onBeforeBuild(async ({ isFirstCompile, environments })=>{
7765
7767
  isFirstCompile && await cleanAll({
@@ -7910,7 +7912,7 @@ function applyDefaultPlugins(pluginManager, context) {
7910
7912
  }
7911
7913
  },
7912
7914
  {
7913
- name: 'rsbuild:app-icon',
7915
+ name: 'rsbuild:appIcon',
7914
7916
  setup (api) {
7915
7917
  let htmlTagsMap = new Map(), iconFormatMap = new Map();
7916
7918
  api.processAssets({
@@ -7947,16 +7949,16 @@ function applyDefaultPlugins(pluginManager, context) {
7947
7949
  })(icon, distDir, publicPath, lookup)), tags = [];
7948
7950
  for (let icon of icons){
7949
7951
  if ('web-app-manifest' === icon.target && !appIcon.name) {
7950
- addCompilationError(compilation, `${color.dim('[rsbuild:app-icon]')} ${color.yellow('"appIcon.name"')} is required when ${color.yellow('"target"')} is ${color.yellow('"web-app-manifest"')}.`);
7952
+ addCompilationError(compilation, `${color.dim('[rsbuild:appIcon]')} ${color.yellow('"appIcon.name"')} is required when ${color.yellow('"target"')} is ${color.yellow('"web-app-manifest"')}.`);
7951
7953
  continue;
7952
7954
  }
7953
7955
  if (!icon.isURL) {
7954
7956
  if (!compilation.inputFileSystem) {
7955
- addCompilationError(compilation, `${color.dim('[rsbuild:app-icon]')} Failed to read the icon file as ${color.yellow('"compilation.inputFileSystem"')} is not available.`);
7957
+ addCompilationError(compilation, `${color.dim('[rsbuild:appIcon]')} Failed to read the icon file as ${color.yellow('"compilation.inputFileSystem"')} is not available.`);
7956
7958
  continue;
7957
7959
  }
7958
7960
  if (!await fileExistsByCompilation(compilation, icon.absolutePath)) {
7959
- addCompilationError(compilation, `${color.dim('[rsbuild:app-icon]')} Failed to find the icon file at ${color.yellow(icon.absolutePath)}.`);
7961
+ addCompilationError(compilation, `${color.dim('[rsbuild:appIcon]')} Failed to find the icon file at ${color.yellow(icon.absolutePath)}.`);
7960
7962
  continue;
7961
7963
  }
7962
7964
  let source = await readFileAsync(compilation.inputFileSystem, icon.absolutePath);
@@ -8013,10 +8015,7 @@ function applyDefaultPlugins(pluginManager, context) {
8013
8015
  setup (api) {
8014
8016
  api.modifyBundlerChain((chain, { CHAIN_ID, environment, isProd })=>{
8015
8017
  let { config } = environment, distPath = config.output.distPath.wasm, filename = external_node_path_.posix.join(distPath, getFilename(config, 'wasm', isProd));
8016
- chain.experiments({
8017
- ...chain.get('experiments'),
8018
- asyncWebAssembly: !0
8019
- }), chain.output.webassemblyModuleFilename(filename), chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).dependency('url').type('asset/resource').set('generator', {
8018
+ chain.output.webassemblyModuleFilename(filename), chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).dependency('url').type('asset/resource').set('generator', {
8020
8019
  filename
8021
8020
  });
8022
8021
  });
@@ -8033,7 +8032,7 @@ function applyDefaultPlugins(pluginManager, context) {
8033
8032
  raw: !0
8034
8033
  }, ({ code, emitFile, resourcePath })=>{
8035
8034
  let name, filename = (name = resourcePath && external_node_path_.default.parse(resourcePath).name) ? `${name}.node` : null;
8036
- if (null === filename) throw Error(`${color.dim('[rsbuild:node-addons]')} Failed to load Node.js addon: ${color.yellow(resourcePath)}`);
8035
+ if (null === filename) throw Error(`${color.dim('[rsbuild:nodeAddons]')} Failed to load Node.js addon: ${color.yellow(resourcePath)}`);
8037
8036
  emitFile(filename, code);
8038
8037
  let config = api.getNormalizedConfig(), handleErrorSnippet = `throw new Error('Failed to load Node.js addon: "${filename}"', {
8039
8038
  cause: error,
@@ -8069,7 +8068,7 @@ try {
8069
8068
  {
8070
8069
  name: 'rsbuild:define',
8071
8070
  setup (api) {
8072
- api.modifyBundlerChain((chain, { CHAIN_ID, bundler, environment })=>{
8071
+ api.modifyBundlerChain((chain, { CHAIN_ID, rspack, environment })=>{
8073
8072
  let { config } = environment, baseUrl = JSON.stringify(config.server.base), assetPrefix = JSON.stringify(getPublicPathFromChain(chain, !1)), mergedDefine = {
8074
8073
  ...{
8075
8074
  'import.meta.env': {
@@ -8084,7 +8083,7 @@ try {
8084
8083
  },
8085
8084
  ...config.source.define
8086
8085
  };
8087
- checkProcessEnvSecurity(mergedDefine), chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(bundler.DefinePlugin, [
8086
+ checkProcessEnvSecurity(mergedDefine), chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(rspack.DefinePlugin, [
8088
8087
  mergedDefine
8089
8088
  ]);
8090
8089
  });
@@ -8589,7 +8588,7 @@ try {
8589
8588
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
8590
8589
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
8591
8590
  if (!1 === manifest) return;
8592
- let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.0_@module-federation+runtime-tools@0.24.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8591
+ let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.2_@module-federation+runtime-tools@2.0.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8593
8592
  manifestFilenames.set(environment.name, manifestOptions.filename);
8594
8593
  let pluginOptions = {
8595
8594
  fileName: manifestOptions.filename,
@@ -8957,7 +8956,7 @@ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta,
8957
8956
  src_logger.debug(`${errorMessage}, fallback to jiti.`), src_logger.debug(err);
8958
8957
  }
8959
8958
  if (void 0 === configExport) try {
8960
- let { createJiti } = await import("jiti"), jiti = createJiti(import.meta.filename, {
8959
+ let { createJiti } = await import("../compiled/jiti/lib/jiti.mjs"), jiti = createJiti(import.meta.filename, {
8961
8960
  moduleCache: !1,
8962
8961
  interopDefault: !0,
8963
8962
  nativeModules: [
@@ -9094,7 +9093,7 @@ let applyServerOptions = (command)=>{
9094
9093
  };
9095
9094
  function setupCommands() {
9096
9095
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9097
- cli.version("2.0.0-beta.2"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9096
+ cli.version("2.0.0-beta.4"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9098
9097
  default: 'auto'
9099
9098
  }).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
9100
9099
  type: [
@@ -9163,7 +9162,7 @@ function initNodeEnv() {
9163
9162
  }
9164
9163
  function showGreeting() {
9165
9164
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9166
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-beta.2\n`);
9165
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-beta.4\n`);
9167
9166
  }
9168
9167
  function setupLogLevel() {
9169
9168
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9184,5 +9183,5 @@ function runCLI() {
9184
9183
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9185
9184
  }
9186
9185
  }
9187
- let src_version = "2.0.0-beta.2";
9186
+ let src_version = "2.0.0-beta.4";
9188
9187
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, external_node_util_promisify, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_logger as logger, src_version as version };
@@ -1,7 +1,7 @@
1
1
  import { __webpack_require__ } from "./rslib-runtime.js";
2
2
  import "./131.js";
3
3
  __webpack_require__.add({
4
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.0_@module-federation+runtime-tools@0.24.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js" (__unused_rspack_module, exports, __webpack_require__) {
4
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.2_@module-federation+runtime-tools@2.0.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js" (__unused_rspack_module, exports, __webpack_require__) {
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: !0
7
7
  }), exports.transformFiles = exports.reduceChunk = exports.reduceAssets = exports.generateManifest = void 0;
@@ -63,11 +63,11 @@ __webpack_require__.add({
63
63
  'sort'
64
64
  ].filter((fname)=>!!options[fname]).reduce((prev, fname)=>prev[fname](options[fname]), files).map(standardizeFilePaths);
65
65
  },
66
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.0_@module-federation+runtime-tools@0.24.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js" (__unused_rspack_module, exports, __webpack_require__) {
66
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.2_@module-federation+runtime-tools@2.0.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js" (__unused_rspack_module, exports, __webpack_require__) {
67
67
  Object.defineProperty(exports, "__esModule", {
68
68
  value: !0
69
69
  }), exports.normalModuleLoaderHook = exports.getCompilerHooks = exports.emitHook = exports.beforeRunHook = void 0;
70
- let node_fs_1 = __webpack_require__("node:fs"), node_path_1 = __webpack_require__("node:path"), lite_tapable_1 = __webpack_require__("../../node_modules/.pnpm/@rspack+lite-tapable@1.1.0/node_modules/@rspack/lite-tapable/dist/index.cjs"), helpers_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.0_@module-federation+runtime-tools@0.24.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js"), compilerHookMap = new WeakMap(), getCompilerHooks = (compiler)=>{
70
+ let node_fs_1 = __webpack_require__("node:fs"), node_path_1 = __webpack_require__("node:path"), lite_tapable_1 = __webpack_require__("../../node_modules/.pnpm/@rspack+lite-tapable@1.1.0/node_modules/@rspack/lite-tapable/dist/index.cjs"), helpers_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.2_@module-federation+runtime-tools@2.0.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/helpers.js"), compilerHookMap = new WeakMap(), getCompilerHooks = (compiler)=>{
71
71
  let hooks = compilerHookMap.get(compiler);
72
72
  return void 0 === hooks && (hooks = {
73
73
  afterEmit: new lite_tapable_1.SyncWaterfallHook([
@@ -121,9 +121,9 @@ __webpack_require__.add({
121
121
  }), emitFile.call(module, file, content, sourceMap));
122
122
  };
123
123
  },
124
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.0_@module-federation+runtime-tools@0.24.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js" (__unused_rspack_module, exports, __webpack_require__) {
124
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.2_@module-federation+runtime-tools@2.0.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js" (__unused_rspack_module, exports, __webpack_require__) {
125
125
  exports.RspackManifestPlugin = void 0;
126
- let node_path_1 = __webpack_require__("node:path"), hooks_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.0_@module-federation+runtime-tools@0.24.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js"), emitCountMap = new Map(), defaults = {
126
+ let node_path_1 = __webpack_require__("node:path"), hooks_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.2_@module-federation+runtime-tools@2.0.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/hooks.js"), emitCountMap = new Map(), defaults = {
127
127
  assetHookStage: 1 / 0,
128
128
  basePath: '',
129
129
  fileName: 'manifest.json',
package/dist/open.js CHANGED
@@ -224,9 +224,11 @@ async function defaultBrowser(_execFileAsync = windows_execFileAsync) {
224
224
  'ProgId'
225
225
  ]), match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
226
226
  if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
227
- let { id } = match.groups, browser = windowsBrowserProgIds[id];
228
- if (!browser) throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
229
- return browser;
227
+ let { id } = match.groups, dotIndex = id.lastIndexOf('.'), hyphenIndex = id.lastIndexOf('-'), baseIdByDot = -1 === dotIndex ? void 0 : id.slice(0, dotIndex), baseIdByHyphen = -1 === hyphenIndex ? void 0 : id.slice(0, hyphenIndex);
228
+ return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? {
229
+ name: id,
230
+ id
231
+ };
230
232
  }
231
233
  let default_browser_execFileAsync = external_node_util_promisify(execFile);
232
234
  async function default_browser_defaultBrowser() {
@@ -7,7 +7,7 @@
7
7
  * https://github.com/webpack/webpack-dev-middleware/blob/master/LICENSE
8
8
  */
9
9
  import { type Compiler, type MultiCompiler } from '@rspack/core';
10
- import type { InternalContext, NormalizedConfig, RequestHandler } from '../../types';
10
+ import type { InternalContext, LiveReload, NormalizedConfig, RequestHandler } from '../../types';
11
11
  import type { SocketServer } from '../socketServer';
12
12
  export type MultiWatching = ReturnType<MultiCompiler['watch']>;
13
13
  export type AssetsMiddlewareClose = (callback: (err?: Error | null) => void) => void;
@@ -16,11 +16,12 @@ export type AssetsMiddleware = RequestHandler & {
16
16
  close: AssetsMiddlewareClose;
17
17
  };
18
18
  export declare const isClientCompiler: (compiler: Compiler) => boolean;
19
- export declare const setupServerHooks: ({ context, compiler, token, socketServer, }: {
19
+ export declare const setupServerHooks: ({ context, compiler, token, socketServer, liveReload, }: {
20
20
  context: InternalContext;
21
21
  compiler: Compiler;
22
22
  token: string;
23
23
  socketServer: SocketServer;
24
+ liveReload: LiveReload;
24
25
  }) => void;
25
26
  /**
26
27
  * The assets middleware handles compiler setup for development:
@@ -1,5 +1,6 @@
1
1
  import type { CliShortcut, NormalizedConfig } from '../types/config';
2
2
  export declare const isCliShortcutsEnabled: (config: NormalizedConfig) => boolean;
3
+ export declare const normalizeShortcutInput: (input: string) => string;
3
4
  export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, }: {
4
5
  help?: boolean | string;
5
6
  openPage: () => Promise<void>;