@rsbuild/core 1.4.9 → 1.4.11
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.
- package/compiled/css-loader/index.js +18 -18
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-load-config/index.js +10 -10
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/index.cjs +65 -51
- package/dist/index.js +61 -46
- package/dist-types/constants.d.ts +0 -1
- package/dist-types/helpers/index.d.ts +1 -0
- package/dist-types/index.d.ts +2 -2
- package/dist-types/pluginHelper.d.ts +1 -4
- package/dist-types/rspack.d.ts +2 -0
- package/dist-types/server/compilationMiddleware.d.ts +2 -5
- package/dist-types/server/devServer.d.ts +1 -2
- package/dist-types/server/httpServer.d.ts +1 -2
- package/dist-types/server/middlewares.d.ts +8 -9
- package/dist-types/server/prodServer.d.ts +1 -2
- package/dist-types/types/config.d.ts +8 -4
- package/dist-types/types/plugin.d.ts +7 -1
- package/dist-types/types/thirdParty.d.ts +2 -0
- package/package.json +4 -4
- /package/dist-types/{rspack → rspack-plugins}/RsbuildHtmlPlugin.d.ts +0 -0
- /package/dist-types/{rspack → rspack-plugins}/resource-hints/HtmlResourceHintsPlugin.d.ts +0 -0
- /package/dist-types/{rspack → rspack-plugins}/resource-hints/doesChunkBelongToHtml.d.ts +0 -0
- /package/dist-types/{rspack → rspack-plugins}/resource-hints/extractChunks.d.ts +0 -0
- /package/dist-types/{rspack → rspack-plugins}/resource-hints/getResourceType.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
2
|
let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin, isDockerCached, cachedResult;
|
|
3
|
-
import {
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
4
|
import { logger } from "../compiled/rslog/index.js";
|
|
5
5
|
import node_path, { dirname, isAbsolute as external_node_path_isAbsolute, join, posix, relative, sep } from "node:path";
|
|
6
6
|
import { URL as external_node_url_URL, fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
import picocolors from "../compiled/picocolors/index.js";
|
|
8
8
|
import node_fs, { constants as external_node_fs_constants, existsSync } from "node:fs";
|
|
9
9
|
import { EventEmitter } from "events";
|
|
10
|
-
import { createRequire } from "node:module";
|
|
11
10
|
import node_os, { constants as external_node_os_constants } from "node:os";
|
|
12
11
|
import node_process from "node:process";
|
|
13
12
|
import rspack_chain from "../compiled/rspack-chain/index.js";
|
|
@@ -17,7 +16,7 @@ import { lookup } from "../compiled/mrmime/index.js";
|
|
|
17
16
|
import node_zlib from "node:zlib";
|
|
18
17
|
import { Buffer as external_node_buffer_Buffer } from "node:buffer";
|
|
19
18
|
import node_child_process, { execFile } from "node:child_process";
|
|
20
|
-
import promises
|
|
19
|
+
import promises from "node:fs/promises";
|
|
21
20
|
var EsmMode, __webpack_modules__ = {
|
|
22
21
|
"../../node_modules/.pnpm/clone-deep@4.0.1/node_modules/clone-deep/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
23
22
|
let clone = __webpack_require__("../../node_modules/.pnpm/shallow-clone@3.0.1/node_modules/shallow-clone/index.js"), typeOf = __webpack_require__("../../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js"), isPlainObject = __webpack_require__("../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js");
|
|
@@ -765,6 +764,7 @@ __webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(p
|
|
|
765
764
|
setCssExtractPlugin: ()=>setCssExtractPlugin,
|
|
766
765
|
setHTMLPlugin: ()=>setHTMLPlugin
|
|
767
766
|
});
|
|
767
|
+
let rspack_rspack = createRequire(import.meta.url)('@rspack/core');
|
|
768
768
|
var cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs);
|
|
769
769
|
let constants_filename = fileURLToPath(import.meta.url), constants_dirname = dirname(constants_filename), ROOT_DIST_DIR = 'dist', LOADER_PATH = join(constants_dirname), STATIC_PATH = join(constants_dirname, '../static'), COMPILED_PATH = join(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
|
|
770
770
|
'chrome >= 87',
|
|
@@ -777,7 +777,7 @@ let constants_filename = fileURLToPath(import.meta.url), constants_dirname = dir
|
|
|
777
777
|
node: [
|
|
778
778
|
'node >= 16'
|
|
779
779
|
]
|
|
780
|
-
},
|
|
780
|
+
}, JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/, SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, CSS_REGEX = /\.css$/, RAW_QUERY_REGEX = /^\?raw$/, INLINE_QUERY_REGEX = /^\?inline$/, NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, PLUGIN_SWC_NAME = 'rsbuild:swc', PLUGIN_CSS_NAME = 'rsbuild:css', FONT_EXTENSIONS = [
|
|
781
781
|
'woff',
|
|
782
782
|
'woff2',
|
|
783
783
|
'eot',
|
|
@@ -1079,6 +1079,8 @@ function getFilename(config, type, isProd, isServer) {
|
|
|
1079
1079
|
return filename.media ?? `[name]${hash}[ext]`;
|
|
1080
1080
|
case 'assets':
|
|
1081
1081
|
return filename.assets ?? `[name]${hash}[ext]`;
|
|
1082
|
+
case 'wasm':
|
|
1083
|
+
return filename.wasm ?? '[hash].module.wasm';
|
|
1082
1084
|
default:
|
|
1083
1085
|
throw Error(`${picocolors.dim('[rsbuild:config]')} unknown key ${picocolors.yellow(type)} in ${picocolors.yellow('output.filename')}`);
|
|
1084
1086
|
}
|
|
@@ -1956,7 +1958,11 @@ async function initPlugins({ context, pluginManager }) {
|
|
|
1956
1958
|
var _removedEnvPlugins_environment;
|
|
1957
1959
|
let { name, setup } = instance;
|
|
1958
1960
|
if (!(removedPlugins.has(name) || environment && (null == (_removedEnvPlugins_environment = removedEnvPlugins[environment]) ? void 0 : _removedEnvPlugins_environment.has(name)))) {
|
|
1959
|
-
if (instance.apply && context.action) {
|
|
1961
|
+
if (instance.apply && context.action) if (isFunction(instance.apply)) {
|
|
1962
|
+
if (!1 === instance.apply(context.originalConfig, {
|
|
1963
|
+
action: context.action
|
|
1964
|
+
})) continue;
|
|
1965
|
+
} else {
|
|
1960
1966
|
let expected = {
|
|
1961
1967
|
build: 'build',
|
|
1962
1968
|
dev: 'serve',
|
|
@@ -2088,7 +2094,7 @@ async function updateEnvironmentContext(context, configs) {
|
|
|
2088
2094
|
async function createContext(options, userConfig) {
|
|
2089
2095
|
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
|
|
2090
2096
|
return {
|
|
2091
|
-
version: "1.4.
|
|
2097
|
+
version: "1.4.11",
|
|
2092
2098
|
rootPath,
|
|
2093
2099
|
distPath: '',
|
|
2094
2100
|
cachePath,
|
|
@@ -2413,7 +2419,7 @@ async function getConfigUtils(config, chainUtils) {
|
|
|
2413
2419
|
}
|
|
2414
2420
|
function getChainUtils(target, environment) {
|
|
2415
2421
|
return {
|
|
2416
|
-
rspack:
|
|
2422
|
+
rspack: rspack_rspack,
|
|
2417
2423
|
environment,
|
|
2418
2424
|
env: process.env.NODE_ENV,
|
|
2419
2425
|
target,
|
|
@@ -2426,7 +2432,7 @@ function getChainUtils(target, environment) {
|
|
|
2426
2432
|
};
|
|
2427
2433
|
}
|
|
2428
2434
|
async function generateRspackConfig({ target, context, environment }) {
|
|
2429
|
-
let chainUtils = getChainUtils(target, context.environments[environment]), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } =
|
|
2435
|
+
let chainUtils = getChainUtils(target, context.environments[environment]), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = rspack_rspack, rspackConfig = (await modifyBundlerChain(context, {
|
|
2430
2436
|
...chainUtils,
|
|
2431
2437
|
bundler: {
|
|
2432
2438
|
BannerPlugin,
|
|
@@ -2642,9 +2648,9 @@ async function createCompiler_createCompiler(options) {
|
|
|
2642
2648
|
if (await context.hooks.onBeforeCreateCompiler.callBatch({
|
|
2643
2649
|
bundlerConfigs: rspackConfigs,
|
|
2644
2650
|
environments: context.environments
|
|
2645
|
-
}), !await isSatisfyRspackVersion(
|
|
2646
|
-
let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ?
|
|
2647
|
-
isVersionLogged || (logger.debug(`use Rspack v${
|
|
2651
|
+
}), !await isSatisfyRspackVersion(rspack_rspack.rspackVersion)) throw Error(`${picocolors.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${picocolors.green(rspackMinVersion)}`);
|
|
2652
|
+
let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? rspack_rspack(rspackConfigs) : rspack_rspack(rspackConfigs[0]), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
|
|
2653
|
+
isVersionLogged || (logger.debug(`use Rspack v${rspack_rspack.rspackVersion}`), isVersionLogged = !0);
|
|
2648
2654
|
};
|
|
2649
2655
|
return compiler.hooks.watchRun.tap('rsbuild:compiling', (compiler)=>{
|
|
2650
2656
|
logRspackVersion(), isCompiling || function(compiler, context) {
|
|
@@ -2691,7 +2697,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
2691
2697
|
context,
|
|
2692
2698
|
compiler,
|
|
2693
2699
|
bundlerConfigs: rspackConfigs,
|
|
2694
|
-
MultiStatsCtor:
|
|
2700
|
+
MultiStatsCtor: rspack_rspack.MultiStats
|
|
2695
2701
|
}), await context.hooks.onAfterCreateCompiler.callBatch({
|
|
2696
2702
|
compiler,
|
|
2697
2703
|
environments: context.environments
|
|
@@ -2712,16 +2718,19 @@ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOption
|
|
|
2712
2718
|
bundlerConfigs,
|
|
2713
2719
|
compiler,
|
|
2714
2720
|
isWatch: !!watch,
|
|
2715
|
-
MultiStatsCtor:
|
|
2716
|
-
}), watch)
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2721
|
+
MultiStatsCtor: rspack_rspack.MultiStats
|
|
2722
|
+
}), watch) {
|
|
2723
|
+
let watchOptions = bundlerConfigs ? bundlerConfigs.map((options)=>options.watchOptions || {}) : [];
|
|
2724
|
+
return compiler.watch(watchOptions.length > 1 ? watchOptions : watchOptions[0] || {}, (err)=>{
|
|
2725
|
+
err && logger.error(err);
|
|
2726
|
+
}), {
|
|
2727
|
+
close: ()=>new Promise((resolve)=>{
|
|
2728
|
+
compiler.close(()=>{
|
|
2729
|
+
resolve();
|
|
2730
|
+
});
|
|
2731
|
+
})
|
|
2732
|
+
};
|
|
2733
|
+
}
|
|
2725
2734
|
let { stats } = await new Promise((resolve, reject)=>{
|
|
2726
2735
|
compiler.run((err, stats)=>{
|
|
2727
2736
|
compiler.close((closeErr)=>{
|
|
@@ -2940,7 +2949,7 @@ async function gzipSize(input) {
|
|
|
2940
2949
|
let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), getAssetColor = (size)=>size > 300000 ? picocolors.red : size > 100000 ? picocolors.yellow : picocolors.green, calcFileSize = (len)=>{
|
|
2941
2950
|
let val = len / 1000;
|
|
2942
2951
|
return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
|
|
2943
|
-
}, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? picocolors.cyan(assetName) :
|
|
2952
|
+
}, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? picocolors.cyan(assetName) : assetName.endsWith('.css') ? picocolors.yellow(assetName) : assetName.endsWith('.html') ? picocolors.green(assetName) : picocolors.magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i;
|
|
2944
2953
|
async function printFileSizes(options, stats, rootPath, environmentName) {
|
|
2945
2954
|
let logs = [], showTotal = !1 !== options.total, showDetail = !1 !== options.detail, exclude = options.exclude ?? excludeAsset;
|
|
2946
2955
|
if (!showTotal && !showDetail) return logs;
|
|
@@ -3299,7 +3308,7 @@ let isWsl = ()=>{
|
|
|
3299
3308
|
if (mountPoint) return mountPoint;
|
|
3300
3309
|
let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
|
|
3301
3310
|
try {
|
|
3302
|
-
await promises.access(configFilePath,
|
|
3311
|
+
await promises.access(configFilePath, external_node_fs_constants.F_OK), isConfigFileExists = !0;
|
|
3303
3312
|
} catch {}
|
|
3304
3313
|
if (!isConfigFileExists) return defaultMountPoint;
|
|
3305
3314
|
let configContent = await promises.readFile(configFilePath, {
|
|
@@ -4006,7 +4015,7 @@ async function applyProfile(root, filterValue, traceLayer = 'perfetto', traceOut
|
|
|
4006
4015
|
let timestamp = Date.now(), defaultOutputDir = node_path.join(root, `.rspack-profile-${timestamp}-${process.pid}`), defaultRustTracePerfettoOutput = node_path.join(defaultOutputDir, 'rspack.pftrace');
|
|
4007
4016
|
traceOutput = 'perfetto' === traceLayer ? defaultRustTracePerfettoOutput : 'stdout';
|
|
4008
4017
|
}
|
|
4009
|
-
return await ensureFileDir(traceOutput), await
|
|
4018
|
+
return await ensureFileDir(traceOutput), await rspack_rspack.experiments.globalTrace.register("OVERVIEW" === filterValue ? 'info' : "ALL" === filterValue ? 'trace' : filterValue, traceLayer, traceOutput), traceOutput;
|
|
4010
4019
|
}
|
|
4011
4020
|
let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, SPLIT_STRATEGY_DISPATCHER = {
|
|
4012
4021
|
'split-by-experience': function(ctx) {
|
|
@@ -4623,7 +4632,7 @@ class CompilationManager {
|
|
|
4623
4632
|
}(devConfig), middleware = await getCompilationMiddleware(this.compiler, {
|
|
4624
4633
|
callbacks: {
|
|
4625
4634
|
onInvalid: (token, fileName)=>{
|
|
4626
|
-
if ('string' == typeof fileName &&
|
|
4635
|
+
if ('string' == typeof fileName && fileName.endsWith('.html')) return void this.socketServer.sockWrite({
|
|
4627
4636
|
type: 'static-changed'
|
|
4628
4637
|
}, token);
|
|
4629
4638
|
this.socketServer.sockWrite({
|
|
@@ -4796,7 +4805,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
|
|
|
4796
4805
|
(helpers_isMultiCompiler(compiler) ? compiler.compilers.some((childCompiler)=>{
|
|
4797
4806
|
var _childCompiler_options_experiments;
|
|
4798
4807
|
return null == (_childCompiler_options_experiments = childCompiler.options.experiments) ? void 0 : _childCompiler_options_experiments.lazyCompilation;
|
|
4799
|
-
}) : null == (_compiler_options_experiments = compiler.options.experiments) ? void 0 : _compiler_options_experiments.lazyCompilation) && middlewares.push(
|
|
4808
|
+
}) : null == (_compiler_options_experiments = compiler.options.experiments) ? void 0 : _compiler_options_experiments.lazyCompilation) && middlewares.push(rspack_rspack.experiments.lazyCompilationMiddleware(compiler));
|
|
4800
4809
|
}
|
|
4801
4810
|
server.base && '/' !== server.base && middlewares.push(getBaseMiddleware({
|
|
4802
4811
|
base: server.base
|
|
@@ -5681,10 +5690,12 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
5681
5690
|
aggregateTimeout: 0
|
|
5682
5691
|
}), chain.performance.hints(!1), chain.module.parser.merge({
|
|
5683
5692
|
javascript: {
|
|
5684
|
-
exportsPresence: 'error'
|
|
5693
|
+
exportsPresence: 'error',
|
|
5694
|
+
typeReexportsPresence: 'tolerant'
|
|
5685
5695
|
}
|
|
5686
5696
|
}), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin), isDev && chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)), 'rspack' === api.context.bundlerType && chain.experiments({
|
|
5687
5697
|
...chain.get('experiments'),
|
|
5698
|
+
typeReexportsPresence: !0,
|
|
5688
5699
|
rspackFuture: {
|
|
5689
5700
|
bundlerInfo: {
|
|
5690
5701
|
force: !1
|
|
@@ -5777,7 +5788,7 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
5777
5788
|
{
|
|
5778
5789
|
name: 'rsbuild:output',
|
|
5779
5790
|
setup (api) {
|
|
5780
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd, isServer, environment })=>{
|
|
5791
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd, isServer, environment, rspack })=>{
|
|
5781
5792
|
var jsAsync;
|
|
5782
5793
|
let { distPath, config } = environment, publicPath = function({ isDev, config, context }) {
|
|
5783
5794
|
var _context_devServer, _context_devServer1, _context_devServer2;
|
|
@@ -6240,15 +6251,13 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6240
6251
|
{
|
|
6241
6252
|
name: 'rsbuild:wasm',
|
|
6242
6253
|
setup (api) {
|
|
6243
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
|
|
6244
|
-
let { config } = environment, distPath = config.output.distPath.wasm;
|
|
6254
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isProd })=>{
|
|
6255
|
+
let { config } = environment, distPath = config.output.distPath.wasm, filename = posix.join(distPath, getFilename(config, 'wasm', isProd));
|
|
6245
6256
|
chain.experiments({
|
|
6246
6257
|
...chain.get('experiments'),
|
|
6247
6258
|
asyncWebAssembly: !0
|
|
6248
|
-
})
|
|
6249
|
-
|
|
6250
|
-
chain.output.webassemblyModuleFilename(wasmFilename), chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).dependency('url').type('asset/resource').set('generator', {
|
|
6251
|
-
filename: wasmFilename
|
|
6259
|
+
}), chain.output.webassemblyModuleFilename(filename), chain.module.rule(CHAIN_ID.RULE.WASM).test(/\.wasm$/).dependency('url').type('asset/resource').set('generator', {
|
|
6260
|
+
filename
|
|
6252
6261
|
});
|
|
6253
6262
|
});
|
|
6254
6263
|
}
|
|
@@ -6353,7 +6362,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6353
6362
|
config: config.tools.styleLoader
|
|
6354
6363
|
});
|
|
6355
6364
|
rule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
|
|
6356
|
-
} else rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin ||
|
|
6365
|
+
} else rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin).loader).options(config.tools.cssExtract.loaderOptions);
|
|
6357
6366
|
else rule.use(CHAIN_ID.USE.IGNORE_CSS).loader(node_path.join(LOADER_PATH, 'ignoreCssLoader.mjs'));
|
|
6358
6367
|
let importLoaders = 0, updateRules = (callback)=>{
|
|
6359
6368
|
callback(rule, 'normal'), callback(inlineRule, 'inline');
|
|
@@ -6430,7 +6439,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6430
6439
|
let isStringExport = 'string' === cssLoaderOptions.exportType;
|
|
6431
6440
|
if (isStringExport && rule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT) && rule.uses.delete(CHAIN_ID.USE.MINI_CSS_EXTRACT), emitCss && !config.output.injectStyles && !isStringExport) {
|
|
6432
6441
|
let extractPluginOptions = config.tools.cssExtract.pluginOptions, cssPath = config.output.distPath.css, cssFilename = getFilename(config, 'css', isProd), isCssFilenameFn = 'function' == typeof cssFilename, cssAsyncPath = config.output.distPath.cssAsync ?? (cssPath ? `${cssPath}/async` : 'async');
|
|
6433
|
-
chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(cssExtractPlugin ||
|
|
6442
|
+
chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin, [
|
|
6434
6443
|
{
|
|
6435
6444
|
filename: isCssFilenameFn ? (...args)=>{
|
|
6436
6445
|
let name = cssFilename(...args);
|
|
@@ -6452,7 +6461,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6452
6461
|
name: 'rsbuild:minimize',
|
|
6453
6462
|
setup (api) {
|
|
6454
6463
|
let isRspack = 'rspack' === api.context.bundlerType;
|
|
6455
|
-
api.modifyBundlerChain(async (chain, { environment, CHAIN_ID })=>{
|
|
6464
|
+
api.modifyBundlerChain(async (chain, { environment, CHAIN_ID, rspack })=>{
|
|
6456
6465
|
let { config } = environment, { minifyJs, minifyCss, jsOptions, cssOptions } = parseMinifyOptions(config);
|
|
6457
6466
|
if (chain.optimization.minimize(minifyJs || minifyCss), minifyJs && isRspack && chain.optimization.minimizer(CHAIN_ID.MINIMIZER.JS).use(rspack.SwcJsMinimizerRspackPlugin, [
|
|
6458
6467
|
((config, jsOptions)=>{
|
|
@@ -6505,7 +6514,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6505
6514
|
{
|
|
6506
6515
|
name: 'rsbuild:progress',
|
|
6507
6516
|
setup (api) {
|
|
6508
|
-
'webpack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
|
|
6517
|
+
'webpack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, rspack })=>{
|
|
6509
6518
|
let { config } = environment, options = config.dev.progressBar;
|
|
6510
6519
|
if (!options) return;
|
|
6511
6520
|
let prefix = !0 !== options && void 0 !== options.id ? options.id : environment.name;
|
|
@@ -6567,6 +6576,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
6567
6576
|
isModule: 'unknown',
|
|
6568
6577
|
env: {
|
|
6569
6578
|
targets: browserslist
|
|
6579
|
+
},
|
|
6580
|
+
rspackExperiments: {
|
|
6581
|
+
collectTypeScriptInfo: {
|
|
6582
|
+
typeExports: !0,
|
|
6583
|
+
exportedEnum: !1
|
|
6584
|
+
}
|
|
6570
6585
|
}
|
|
6571
6586
|
};
|
|
6572
6587
|
}({
|
|
@@ -7029,7 +7044,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7029
7044
|
let { config } = environment;
|
|
7030
7045
|
if (!(null == (_config_moduleFederation = config.moduleFederation) ? void 0 : _config_moduleFederation.options) || 'web' !== target) return;
|
|
7031
7046
|
let { options } = config.moduleFederation;
|
|
7032
|
-
chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(
|
|
7047
|
+
chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(rspack_rspack.container.ModuleFederationPlugin, [
|
|
7033
7048
|
options
|
|
7034
7049
|
]), options.name && (options.exposes && chain.plugin('mf-patch-split-chunks').use(PatchSplitChunksPlugin, [
|
|
7035
7050
|
options.name
|
|
@@ -7050,7 +7065,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7050
7065
|
api.onBeforeBuild(({ isFirstCompile })=>{
|
|
7051
7066
|
isFirstCompile && onStart();
|
|
7052
7067
|
}), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
|
|
7053
|
-
traceOutput && (
|
|
7068
|
+
traceOutput && (rspack_rspack.experiments.globalTrace.cleanup(), logger.info(`profile file saved to ${picocolors.cyan(traceOutput)}`));
|
|
7054
7069
|
});
|
|
7055
7070
|
}
|
|
7056
7071
|
},
|
|
@@ -7088,7 +7103,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
|
7088
7103
|
{
|
|
7089
7104
|
name: 'rsbuild:sri',
|
|
7090
7105
|
setup (api) {
|
|
7091
|
-
api.modifyBundlerChain((chain, { environment, CHAIN_ID })=>{
|
|
7106
|
+
api.modifyBundlerChain((chain, { environment, CHAIN_ID, rspack })=>{
|
|
7092
7107
|
if ('webpack' === api.context.bundlerType) return;
|
|
7093
7108
|
let { config, htmlPaths } = environment;
|
|
7094
7109
|
if (0 === Object.keys(htmlPaths).length) return;
|
|
@@ -7699,11 +7714,11 @@ async function runCLI() {
|
|
|
7699
7714
|
].includes(level) && (logger.level = level);
|
|
7700
7715
|
}
|
|
7701
7716
|
let { npm_execpath } = process.env;
|
|
7702
|
-
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.
|
|
7717
|
+
(!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && logger.log(), logger.greet(` Rsbuild v1.4.11\n`);
|
|
7703
7718
|
try {
|
|
7704
7719
|
!function() {
|
|
7705
7720
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
7706
|
-
cli.help(), cli.version("1.4.
|
|
7721
|
+
cli.help(), cli.version("1.4.11"), cli.option('--base <base>', 'specify the base path of the server').option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'specify the loader to load the config file, can be `jiti` or `native`', {
|
|
7707
7722
|
default: 'jiti'
|
|
7708
7723
|
}).option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('-m, --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('--log-level <level>', 'specify the log level, can be `info`, `warn`, `error` or `silent`').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--environment <name>', 'specify the name of environment to build', {
|
|
7709
7724
|
type: [
|
|
@@ -7761,5 +7776,5 @@ async function runCLI() {
|
|
|
7761
7776
|
logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
|
|
7762
7777
|
}
|
|
7763
7778
|
}
|
|
7764
|
-
let src_version = "1.4.
|
|
7765
|
-
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack, runCLI, src_version as version };
|
|
7779
|
+
let src_version = "1.4.11";
|
|
7780
|
+
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, rspack_rspack as rspack, runCLI, src_version as version };
|
|
@@ -24,7 +24,6 @@ export declare const DEFAULT_ASSET_PREFIX = "/";
|
|
|
24
24
|
export declare const DEFAULT_BASE_URL = "/";
|
|
25
25
|
export declare const DEFAULT_WEB_BROWSERSLIST: string[];
|
|
26
26
|
export declare const DEFAULT_BROWSERSLIST: Record<string, string[]>;
|
|
27
|
-
export declare const HTML_REGEX: RegExp;
|
|
28
27
|
export declare const JS_REGEX: RegExp;
|
|
29
28
|
export declare const SCRIPT_REGEX: RegExp;
|
|
30
29
|
export declare const CSS_REGEX: RegExp;
|
|
@@ -31,6 +31,7 @@ export declare const canParse: (url: string) => boolean;
|
|
|
31
31
|
export declare const ensureAssetPrefix: (url: string, assetPrefix?: Rspack.PublicPath) => string;
|
|
32
32
|
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'js', isProd: boolean, isServer?: boolean): Rspack.Filename;
|
|
33
33
|
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'css', isProd: boolean): Rspack.CssFilename;
|
|
34
|
+
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: 'wasm', isProd: boolean): Rspack.WebassemblyModuleFilename;
|
|
34
35
|
export declare function getFilename(config: NormalizedConfig | NormalizedEnvironmentConfig, type: Exclude<keyof FilenameConfig, 'js' | 'css'>, isProd: boolean, isServer?: boolean): Rspack.AssetModuleFilename;
|
|
35
36
|
export declare function partition<T>(array: T[], predicate: (value: T) => boolean): [T[], T[]];
|
|
36
37
|
export declare const applyToCompiler: (compiler: Rspack.Compiler | Rspack.MultiCompiler, apply: (c: Rspack.Compiler, index: number) => void) => void;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the public API of @rsbuild/core.
|
|
4
4
|
*/
|
|
5
5
|
import type * as Rspack from '@rspack/core';
|
|
6
|
-
import { rspack } from '
|
|
6
|
+
import { rspack } from './rspack';
|
|
7
7
|
export { runCLI } from './cli';
|
|
8
8
|
export { createRsbuild } from './createRsbuild';
|
|
9
9
|
export { type ConfigParams, defineConfig, type LoadConfigOptions, type LoadConfigResult, loadConfig, } from './loadConfig';
|
|
@@ -19,4 +19,4 @@ export { type Logger, logger } from './logger';
|
|
|
19
19
|
export { mergeRsbuildConfig } from './mergeConfig';
|
|
20
20
|
export type { RsbuildDevServer } from './server/devServer';
|
|
21
21
|
export type { StartServerResult } from './server/helper';
|
|
22
|
-
export type { AliasStrategy, AppIcon, AppIconItem, Build, BuildOptions, BundlerPluginInstance, Charset, CleanDistPath, CleanDistPathObject, ClientConfig, CliShortcut, CompressOptions, ConfigChain, ConfigChainWithContext, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentConfig, EnvironmentContext, FilenameConfig, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlBasicTag, HtmlConfig, HtmlFallback, HtmlRspackPlugin, HtmlTag, HtmlTagContext, HtmlTagDescriptor, HtmlTagHandler, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InspectConfigOptions, InspectConfigResult, InternalContext, LegalComments, LogLevel, ManifestConfig, ManifestData, ManifestObjectConfig, MergedEnvironmentConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModifyWebpackChainFn, ModifyWebpackChainUtils, ModifyWebpackConfigFn, ModifyWebpackConfigUtils, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreconnectOption, PreviewOptions, PrintUrls, ProcessAssetsDescriptor, ProcessAssetsHandler, ProcessAssetsHook, ProgressBarConfig, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PublicDir, PublicDirOptions, RequestHandler, ResolvedCreateRsbuildOptions, ResolveHandler, ResolveHook, ResourceHintsIncludeType, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, ScriptInject, ScriptLoading, SecurityConfig, ServerConfig, SetupMiddlewaresContext, SetupMiddlewaresFn, SourceConfig, SourceMap, SplitChunks, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles, } from './types';
|
|
22
|
+
export type { AliasStrategy, AppIcon, AppIconItem, Build, BuildOptions, BundlerPluginInstance, Charset, CleanDistPath, CleanDistPathObject, ClientConfig, CliShortcut, CompressOptions, ConfigChain, ConfigChainWithContext, Connect, ConsoleType, CreateCompiler, CreateRsbuildOptions, CrossOrigin, CSSLoaderOptions, CSSModules, CSSModulesLocalsConvention, DataUriLimit, Decorators, DevConfig, DistPathConfig, EnvironmentConfig, EnvironmentContext, FilenameConfig, HistoryApiFallbackContext, HistoryApiFallbackOptions, HtmlBasicTag, HtmlConfig, HtmlFallback, HtmlRspackPlugin, HtmlTag, HtmlTagContext, HtmlTagDescriptor, HtmlTagHandler, InlineChunkConfig, InlineChunkTest, InlineChunkTestFunction, InspectConfigOptions, InspectConfigResult, InternalContext, LegalComments, LogLevel, ManifestConfig, ManifestData, ManifestObjectConfig, MergedEnvironmentConfig, MetaAttrs, MetaOptions, Minify, ModifyBundlerChainFn, ModifyBundlerChainUtils, ModifyChainUtils, ModifyEnvironmentConfigFn, ModifyEnvironmentConfigUtils, ModifyHTMLContext, ModifyHTMLFn, ModifyHTMLTagsContext, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRsbuildConfigUtils, ModifyRspackConfigFn, ModifyRspackConfigUtils, ModifyWebpackChainFn, ModifyWebpackChainUtils, ModifyWebpackConfigFn, ModifyWebpackConfigUtils, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedEnvironmentConfig, NormalizedHtmlConfig, NormalizedModuleFederationConfig, NormalizedOutputConfig, NormalizedPerformanceConfig, NormalizedSecurityConfig, NormalizedServerConfig, NormalizedSourceConfig, NormalizedToolsConfig, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompileFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, OutputConfig, OutputStructure, PerformanceConfig, PluginManager, Polyfill, PostCSSLoaderOptions, PostCSSOptions, PostCSSPlugin, PreconnectOption, PreviewOptions, PrintUrls, ProcessAssetsDescriptor, ProcessAssetsHandler, ProcessAssetsHook, ProgressBarConfig, ProxyBypass, ProxyConfig, ProxyFilter, ProxyOptions, PublicDir, PublicDirOptions, RequestHandler, ResolvedCreateRsbuildOptions, ResolveHandler, ResolveHook, ResourceHintsIncludeType, RsbuildConfig, RsbuildContext, RsbuildEntry, RsbuildEntryDescription, RsbuildInstance, RsbuildMode, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildProvider, RsbuildProviderHelpers, RsbuildTarget, RspackChain, RspackRule, ScriptInject, ScriptLoading, SecurityConfig, ServerConfig, SetupMiddlewaresContext, SetupMiddlewaresFn, SourceConfig, SourceMap, SplitChunks, SriAlgorithm, SriOptions, StartDevServerOptions, StyleLoaderOptions, ToolsConfig, TransformContext, TransformDescriptor, TransformHandler, TransformHook, TransformImport, WatchFiles, } from './types';
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* This file is used to get/set the global instance for html-plugin and css-extract plugin.
|
|
3
|
-
*/
|
|
4
|
-
import { rspack } from '@rspack/core';
|
|
1
|
+
import { rspack } from './rspack';
|
|
5
2
|
import type { HtmlRspackPlugin } from './types';
|
|
6
3
|
/**
|
|
7
4
|
* This method is used to override the Rsbuild default html-plugin (html-rspack-plugin).
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
1
|
import type { Compiler, MultiCompiler, Stats } from '@rspack/core';
|
|
3
|
-
import type { DevConfig, EnvironmentContext,
|
|
2
|
+
import type { Connect, DevConfig, EnvironmentContext, ServerConfig } from '../types';
|
|
4
3
|
export declare const isClientCompiler: (compiler: {
|
|
5
4
|
options: {
|
|
6
5
|
target?: Compiler["options"]["target"];
|
|
@@ -15,7 +14,6 @@ export declare const setupServerHooks: ({ compiler, token, callbacks: { onDone,
|
|
|
15
14
|
token: string;
|
|
16
15
|
callbacks: ServerCallbacks;
|
|
17
16
|
}) => void;
|
|
18
|
-
type Middleware = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => Promise<void>;
|
|
19
17
|
export type CompilationMiddlewareOptions = {
|
|
20
18
|
/**
|
|
21
19
|
* To ensure HMR works, the devMiddleware need inject the HMR client path into page when HMR enable.
|
|
@@ -29,7 +27,7 @@ export type CompilationMiddlewareOptions = {
|
|
|
29
27
|
serverConfig: ServerConfig;
|
|
30
28
|
environments: Record<string, EnvironmentContext>;
|
|
31
29
|
};
|
|
32
|
-
export type CompilationMiddleware =
|
|
30
|
+
export type CompilationMiddleware = Connect.NextHandleFunction & {
|
|
33
31
|
close: (callback: (err: Error | null | undefined) => void) => any;
|
|
34
32
|
watch: () => void;
|
|
35
33
|
};
|
|
@@ -40,4 +38,3 @@ export type CompilationMiddleware = Middleware & {
|
|
|
40
38
|
* - Notify server when compiler hooks are triggered
|
|
41
39
|
*/
|
|
42
40
|
export declare const getCompilationMiddleware: (compiler: Compiler | MultiCompiler, options: CompilationMiddlewareOptions) => Promise<CompilationMiddleware>;
|
|
43
|
-
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
-
import type Connect from '
|
|
4
|
-
import type { CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalContext, NormalizedConfig } from '../types';
|
|
3
|
+
import type { Connect, CreateCompiler, CreateDevServerOptions, EnvironmentAPI, InternalContext, NormalizedConfig } from '../types';
|
|
5
4
|
type HTTPServer = Server | Http2SecureServer;
|
|
6
5
|
export type SockWriteType = 'static-changed' | (string & {});
|
|
7
6
|
export type SockWrite = (type: SockWriteType, data?: string | boolean | Record<string, any>) => void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
-
import type Connect from '
|
|
4
|
-
import type { ServerConfig } from '../types';
|
|
3
|
+
import type { Connect, ServerConfig } from '../types';
|
|
5
4
|
export declare const createHttpServer: ({ serverConfig, middlewares, }: {
|
|
6
5
|
serverConfig: ServerConfig;
|
|
7
6
|
middlewares: Connect.Server;
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import type Connect from '
|
|
2
|
-
import type { EnvironmentAPI, HtmlFallback, RequestHandler as Middleware } from '../types';
|
|
1
|
+
import type { Connect, EnvironmentAPI, HtmlFallback, RequestHandler } from '../types';
|
|
3
2
|
import type { CompilationManager } from './compilationManager';
|
|
4
|
-
export declare const faviconFallbackMiddleware:
|
|
3
|
+
export declare const faviconFallbackMiddleware: RequestHandler;
|
|
5
4
|
export declare const getRequestLoggerMiddleware: () => Promise<Connect.NextHandleFunction>;
|
|
6
|
-
export declare const notFoundMiddleware:
|
|
7
|
-
export declare const optionsFallbackMiddleware:
|
|
5
|
+
export declare const notFoundMiddleware: RequestHandler;
|
|
6
|
+
export declare const optionsFallbackMiddleware: RequestHandler;
|
|
8
7
|
/**
|
|
9
8
|
* Support access HTML without suffix
|
|
10
9
|
*/
|
|
11
10
|
export declare const getHtmlCompletionMiddleware: (params: {
|
|
12
11
|
distPath: string;
|
|
13
12
|
compilationManager: CompilationManager;
|
|
14
|
-
}) =>
|
|
13
|
+
}) => RequestHandler;
|
|
15
14
|
/**
|
|
16
15
|
* handle `server.base`
|
|
17
16
|
*/
|
|
18
17
|
export declare const getBaseMiddleware: (params: {
|
|
19
18
|
base: string;
|
|
20
|
-
}) =>
|
|
19
|
+
}) => RequestHandler;
|
|
21
20
|
/**
|
|
22
21
|
* support HTML fallback in some edge cases
|
|
23
22
|
*/
|
|
@@ -25,10 +24,10 @@ export declare const getHtmlFallbackMiddleware: (params: {
|
|
|
25
24
|
distPath: string;
|
|
26
25
|
compilationManager: CompilationManager;
|
|
27
26
|
htmlFallback?: HtmlFallback;
|
|
28
|
-
}) =>
|
|
27
|
+
}) => RequestHandler;
|
|
29
28
|
/**
|
|
30
29
|
* Support viewing served files via `/rsbuild-dev-server` route
|
|
31
30
|
*/
|
|
32
31
|
export declare const viewingServedFilesMiddleware: (params: {
|
|
33
32
|
environments: EnvironmentAPI;
|
|
34
|
-
}) =>
|
|
33
|
+
}) => RequestHandler;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
-
import type Connect from '
|
|
4
|
-
import type { InternalContext, NormalizedConfig, PreviewOptions, ServerConfig } from '../types';
|
|
3
|
+
import type { Connect, InternalContext, NormalizedConfig, PreviewOptions, ServerConfig } from '../types';
|
|
5
4
|
import { type StartServerResult } from './helper';
|
|
6
5
|
type RsbuildProdServerOptions = {
|
|
7
6
|
pwd: string;
|
|
@@ -13,7 +13,7 @@ import type { EnvironmentContext, ModifyBundlerChainUtils, ModifyChainUtils, Rou
|
|
|
13
13
|
import type { ModifyWebpackChainUtils, ModifyWebpackConfigUtils, RsbuildPlugins } from './plugin';
|
|
14
14
|
import type { RsbuildEntry, RsbuildMode, RsbuildTarget } from './rsbuild';
|
|
15
15
|
import type { BundlerPluginInstance, Rspack, RspackRule } from './rspack';
|
|
16
|
-
import type { CSSExtractOptions, CSSLoaderModulesOptions, CSSLoaderOptions, HtmlRspackPlugin, LoosePostCSSPlugin, PostCSSLoaderOptions, StyleLoaderOptions, WebpackConfig } from './thirdParty';
|
|
16
|
+
import type { Connect, CSSExtractOptions, CSSLoaderModulesOptions, CSSLoaderOptions, HtmlRspackPlugin, LoosePostCSSPlugin, PostCSSLoaderOptions, StyleLoaderOptions, WebpackConfig } from './thirdParty';
|
|
17
17
|
import type { ConfigChain, ConfigChainMergeContext, ConfigChainWithContext, MaybePromise, OneOrMany, TwoLevelReadonly } from './utils';
|
|
18
18
|
export type ToolsSwcConfig = ConfigChain<SwcLoaderOptions>;
|
|
19
19
|
export type ToolsBundlerChainConfig = OneOrMany<(chain: RspackChain, utils: ModifyBundlerChainUtils) => MaybePromise<void>>;
|
|
@@ -747,7 +747,12 @@ export type FilenameConfig = {
|
|
|
747
747
|
*/
|
|
748
748
|
media?: Rspack.AssetModuleFilename;
|
|
749
749
|
/**
|
|
750
|
-
*
|
|
750
|
+
* The name of Wasm files.
|
|
751
|
+
* @default '[hash].module.wasm'
|
|
752
|
+
*/
|
|
753
|
+
wasm?: Rspack.WebassemblyModuleFilename;
|
|
754
|
+
/**
|
|
755
|
+
* The name of other assets, except for above (image, svg, font, html, wasm...)
|
|
751
756
|
* @default '[name].[contenthash:8][ext]'
|
|
752
757
|
*/
|
|
753
758
|
assets?: Rspack.AssetModuleFilename;
|
|
@@ -1328,8 +1333,7 @@ export type NormalizedHtmlConfig = HtmlConfig & {
|
|
|
1328
1333
|
export type ProgressBarConfig = {
|
|
1329
1334
|
id?: string;
|
|
1330
1335
|
};
|
|
1331
|
-
export type
|
|
1332
|
-
export type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
|
|
1336
|
+
export type RequestHandler = Connect.NextHandleFunction;
|
|
1333
1337
|
export type EnvironmentAPI = {
|
|
1334
1338
|
[name: string]: {
|
|
1335
1339
|
/**
|
|
@@ -124,7 +124,12 @@ export type PluginManager = Pick<RsbuildInstance, 'getPlugins' | 'addPlugins' |
|
|
|
124
124
|
/** Get all plugins with environment info */
|
|
125
125
|
getAllPluginsWithMeta: () => PluginMeta[];
|
|
126
126
|
};
|
|
127
|
-
export type
|
|
127
|
+
export type RsbuildPluginApplyFn = (this: void,
|
|
128
|
+
/**
|
|
129
|
+
* The original Rsbuild configuration object (before plugin processing)
|
|
130
|
+
*/
|
|
131
|
+
config: RsbuildConfig, context: Pick<RsbuildContext, 'action'>) => boolean;
|
|
132
|
+
export type RsbuildPluginApply = 'serve' | 'build' | RsbuildPluginApplyFn;
|
|
128
133
|
/**
|
|
129
134
|
* The type of the Rsbuild plugin object.
|
|
130
135
|
*/
|
|
@@ -137,6 +142,7 @@ export type RsbuildPlugin = {
|
|
|
137
142
|
* Conditional apply the plugin during serve or build.
|
|
138
143
|
* - `'serve'`: Apply the plugin when starting the dev server or preview server.
|
|
139
144
|
* - `'build'`: Apply the plugin during build.
|
|
145
|
+
* - Can be a function that returns `true` to apply the plugin or `false` to skip it.
|
|
140
146
|
* - If not specified, the plugin will be applied during both serve and build.
|
|
141
147
|
*/
|
|
142
148
|
apply?: RsbuildPluginApply;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { CssExtractRspackLoaderOptions, CssExtractRspackPluginOptions } from '@rspack/core';
|
|
2
2
|
/** @ts-ignore `webpack` type only exists when `@rsbuild/webpack` is installed */
|
|
3
3
|
import type { Configuration as WebpackConfig } from 'webpack';
|
|
4
|
+
import type Connect from '../../compiled/connect/index.js';
|
|
4
5
|
import type HtmlRspackPlugin from '../../compiled/html-rspack-plugin/index.js';
|
|
5
6
|
import type { AcceptedPlugin, ProcessOptions } from '../../compiled/postcss';
|
|
6
7
|
import type { Rspack } from './rspack';
|
|
8
|
+
export type { Connect };
|
|
7
9
|
export type { HtmlRspackPlugin };
|
|
8
10
|
export interface CSSExtractOptions {
|
|
9
11
|
pluginOptions?: CssExtractRspackPluginOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.11",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"types.d.ts"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@rspack/core": "1.4.
|
|
49
|
+
"@rspack/core": "1.4.10",
|
|
50
50
|
"@rspack/lite-tapable": "~1.0.1",
|
|
51
51
|
"@swc/helpers": "^0.5.17",
|
|
52
52
|
"core-js": "~3.44.0",
|
|
53
|
-
"jiti": "^2.
|
|
53
|
+
"jiti": "^2.5.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@rslib/core": "0.
|
|
56
|
+
"@rslib/core": "0.11.0",
|
|
57
57
|
"@types/connect": "3.4.38",
|
|
58
58
|
"@types/cors": "^2.8.19",
|
|
59
59
|
"@types/node": "^22.16.5",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|