@rsbuild/core 2.3.5 → 2.3.6
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 +2 -2
- package/compiled/html-rspack-plugin/index.js +27 -50
- package/compiled/html-rspack-plugin/package.json +1 -1
- package/compiled/postcss/index.js +1 -1
- package/compiled/postcss/lib/node.d.ts +2 -2
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-loader/index.js +11 -11
- package/compiled/style-loader/index.js +8 -8
- package/dist/helpers/index.d.ts +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/m.js +260 -228
- package/dist/manifest-plugin.js +1 -1
- package/dist/plugins/builtinCss.d.ts +2 -0
- package/dist/plugins/css.d.ts +1 -2
- package/dist/plugins/cssShared.d.ts +7 -0
- package/dist/server/socketServer.d.ts +1 -1
- package/dist/types/config.d.ts +11 -0
- package/package.json +5 -5
package/dist/m.js
CHANGED
|
@@ -292,8 +292,8 @@ moduleFactories.add({
|
|
|
292
292
|
};
|
|
293
293
|
};
|
|
294
294
|
},
|
|
295
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
296
|
-
let yaml, { resolve } = __rspack_createRequire_require("node:path"), config = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/lilconfig/3.1.3/8e9a79516bf61f8427342cef50cdad2cdc2572f42288ba8053b88eadfdc0ebef/node_modules/lilconfig/src/index.js"), loadOptions = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
295
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/9e609fb6c52072bc6facf6e92463c7ae61177cd218a9d63536247c93a5b51966/node_modules/postcss-load-config/src/index.js" (module) {
|
|
296
|
+
let yaml, { resolve } = __rspack_createRequire_require("node:path"), config = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/lilconfig/3.1.3/8e9a79516bf61f8427342cef50cdad2cdc2572f42288ba8053b88eadfdc0ebef/node_modules/lilconfig/src/index.js"), loadOptions = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/9e609fb6c52072bc6facf6e92463c7ae61177cd218a9d63536247c93a5b51966/node_modules/postcss-load-config/src/options.js"), loadPlugins = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/9e609fb6c52072bc6facf6e92463c7ae61177cd218a9d63536247c93a5b51966/node_modules/postcss-load-config/src/plugins.js"), req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/9e609fb6c52072bc6facf6e92463c7ae61177cd218a9d63536247c93a5b51966/node_modules/postcss-load-config/src/req.js");
|
|
297
297
|
async function processResult(ctx, result) {
|
|
298
298
|
let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
|
|
299
299
|
default: obj
|
|
@@ -366,8 +366,8 @@ moduleFactories.add({
|
|
|
366
366
|
});
|
|
367
367
|
};
|
|
368
368
|
},
|
|
369
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
370
|
-
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
369
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/9e609fb6c52072bc6facf6e92463c7ae61177cd218a9d63536247c93a5b51966/node_modules/postcss-load-config/src/options.js" (module) {
|
|
370
|
+
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/9e609fb6c52072bc6facf6e92463c7ae61177cd218a9d63536247c93a5b51966/node_modules/postcss-load-config/src/req.js");
|
|
371
371
|
module.exports = async function options(config, file) {
|
|
372
372
|
if (config.parser && 'string' == typeof config.parser) try {
|
|
373
373
|
config.parser = await req(config.parser, file);
|
|
@@ -387,8 +387,8 @@ moduleFactories.add({
|
|
|
387
387
|
return config;
|
|
388
388
|
};
|
|
389
389
|
},
|
|
390
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
391
|
-
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
390
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/9e609fb6c52072bc6facf6e92463c7ae61177cd218a9d63536247c93a5b51966/node_modules/postcss-load-config/src/plugins.js" (module) {
|
|
391
|
+
let req = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/9e609fb6c52072bc6facf6e92463c7ae61177cd218a9d63536247c93a5b51966/node_modules/postcss-load-config/src/req.js");
|
|
392
392
|
async function load(plugin, options, file) {
|
|
393
393
|
try {
|
|
394
394
|
if (null == options || 0 === Object.keys(options).length) return await req(plugin, file);
|
|
@@ -404,7 +404,7 @@ moduleFactories.add({
|
|
|
404
404
|
}), list;
|
|
405
405
|
};
|
|
406
406
|
},
|
|
407
|
-
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/
|
|
407
|
+
"../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/9e609fb6c52072bc6facf6e92463c7ae61177cd218a9d63536247c93a5b51966/node_modules/postcss-load-config/src/req.js" (module) {
|
|
408
408
|
let tsx, jiti, { createRequire } = __rspack_createRequire_require("node:module"), { pathToFileURL } = __rspack_createRequire_require("node:url"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
|
|
409
409
|
module.exports = async function req(name, rootFile = __rspack_import_meta_filename__) {
|
|
410
410
|
let url = createRequire(rootFile).resolve(name);
|
|
@@ -2081,9 +2081,9 @@ let setNodeEnv = (env)=>{
|
|
|
2081
2081
|
arr
|
|
2082
2082
|
], cloneDeep = (value)=>null == value ? value : cjs_0_default()({}, value, {
|
|
2083
2083
|
isMergeableObject: isPlainObject
|
|
2084
|
-
}),
|
|
2085
|
-
|
|
2086
|
-
|
|
2084
|
+
}), normalizeCopyOptions = (copy)=>Array.isArray(copy) ? {
|
|
2085
|
+
patterns: copy
|
|
2086
|
+
} : copy, DEFAULT_FILENAME_HASH = 'contenthash:10', normalizeFilenameHash = (filenameHash)=>'boolean' == typeof filenameHash ? {
|
|
2087
2087
|
enable: filenameHash,
|
|
2088
2088
|
format: DEFAULT_FILENAME_HASH
|
|
2089
2089
|
} : 'string' == typeof filenameHash ? {
|
|
@@ -2092,24 +2092,29 @@ function getFilename(config, type, isProd, isServer) {
|
|
|
2092
2092
|
} : {
|
|
2093
2093
|
enable: filenameHash.enable ?? !0,
|
|
2094
2094
|
format: filenameHash.format ?? DEFAULT_FILENAME_HASH
|
|
2095
|
-
}
|
|
2095
|
+
};
|
|
2096
|
+
function getFilename(config, type, isProd, isServer) {
|
|
2097
|
+
let { filename, filenameHash } = config.output, getHash = (useHash)=>{
|
|
2098
|
+
let { enable, format } = normalizeFilenameHash(filenameHash);
|
|
2099
|
+
return 'always' === enable || enable && useHash ? `.[${format}]` : '';
|
|
2100
|
+
};
|
|
2096
2101
|
switch(type){
|
|
2097
2102
|
case 'js':
|
|
2098
|
-
return filename.js ?? `[name]${
|
|
2103
|
+
return filename.js ?? `[name]${getHash(isProd && !isServer)}.js`;
|
|
2099
2104
|
case 'css':
|
|
2100
|
-
return filename.css ?? `[name]${
|
|
2105
|
+
return filename.css ?? `[name]${getHash(isProd)}.css`;
|
|
2101
2106
|
case 'svg':
|
|
2102
|
-
return filename.svg ?? `[name]${getHash()}.svg`;
|
|
2107
|
+
return filename.svg ?? `[name]${getHash(!0)}.svg`;
|
|
2103
2108
|
case 'font':
|
|
2104
|
-
return filename.font ?? `[name]${getHash()}[ext]`;
|
|
2109
|
+
return filename.font ?? `[name]${getHash(!0)}[ext]`;
|
|
2105
2110
|
case 'image':
|
|
2106
|
-
return filename.image ?? `[name]${getHash()}[ext]`;
|
|
2111
|
+
return filename.image ?? `[name]${getHash(!0)}[ext]`;
|
|
2107
2112
|
case 'media':
|
|
2108
|
-
return filename.media ?? `[name]${getHash()}[ext]`;
|
|
2113
|
+
return filename.media ?? `[name]${getHash(!0)}[ext]`;
|
|
2109
2114
|
case 'assets':
|
|
2110
|
-
return filename.assets ?? `[name]${getHash()}[ext]`;
|
|
2115
|
+
return filename.assets ?? `[name]${getHash(!0)}[ext]`;
|
|
2111
2116
|
case 'wasm':
|
|
2112
|
-
return filename.wasm ??
|
|
2117
|
+
return filename.wasm ?? `[${normalizeFilenameHash(filenameHash).format}].module.wasm`;
|
|
2113
2118
|
case 'html':
|
|
2114
2119
|
if (filename.html) return filename.html;
|
|
2115
2120
|
return 'flat' === config.html.outputStructure ? '[name].html' : '[name]/index.html';
|
|
@@ -2654,6 +2659,7 @@ let OVERRIDE_PATHS = new Set([
|
|
|
2654
2659
|
'output.inlineScripts',
|
|
2655
2660
|
'output.inlineStyles',
|
|
2656
2661
|
'output.cssModules.auto',
|
|
2662
|
+
'output.cssModules.mode',
|
|
2657
2663
|
'output.manifest.filter',
|
|
2658
2664
|
'output.manifest.generate',
|
|
2659
2665
|
'output.overrideBrowserslist',
|
|
@@ -2662,11 +2668,14 @@ let OVERRIDE_PATHS = new Set([
|
|
|
2662
2668
|
'performance.printFileSize.total',
|
|
2663
2669
|
'server.open',
|
|
2664
2670
|
'server.compress.filter',
|
|
2671
|
+
'server.cors.origin',
|
|
2665
2672
|
'server.printUrls',
|
|
2666
2673
|
'resolve.extensions',
|
|
2667
2674
|
'resolve.conditionNames',
|
|
2668
2675
|
'resolve.mainFields',
|
|
2676
|
+
'splitChunks.chunks',
|
|
2669
2677
|
'dev.writeToDisk',
|
|
2678
|
+
'dev.cliShortcuts.custom',
|
|
2670
2679
|
'dev.client.overlay.errors',
|
|
2671
2680
|
'dev.client.overlay.runtime',
|
|
2672
2681
|
'provider',
|
|
@@ -2717,20 +2726,37 @@ let OVERRIDE_PATHS = new Set([
|
|
|
2717
2726
|
}
|
|
2718
2727
|
return merged;
|
|
2719
2728
|
}, normalizeConfigStructure = (config)=>{
|
|
2720
|
-
let { dev, output } = config, normalizedConfig = {
|
|
2729
|
+
let { dev, output, environments } = config, normalizedConfig = {
|
|
2721
2730
|
...config
|
|
2722
2731
|
};
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2732
|
+
if (output) {
|
|
2733
|
+
(output = {
|
|
2734
|
+
...output
|
|
2735
|
+
}).copy && (output.copy = normalizeCopyOptions(output.copy)), 'string' == typeof output.distPath && (output.distPath = {
|
|
2736
|
+
root: output.distPath
|
|
2737
|
+
}), 'string' == typeof output.filenameHash && (output.filenameHash = normalizeFilenameHash(output.filenameHash)), 'string' == typeof output.manifest && (output.manifest = {
|
|
2738
|
+
filename: output.manifest
|
|
2739
|
+
});
|
|
2740
|
+
let { dataUriLimit } = output;
|
|
2741
|
+
'number' == typeof dataUriLimit && (output.dataUriLimit = {
|
|
2742
|
+
svg: dataUriLimit,
|
|
2743
|
+
font: dataUriLimit,
|
|
2744
|
+
image: dataUriLimit,
|
|
2745
|
+
media: dataUriLimit,
|
|
2746
|
+
assets: dataUriLimit
|
|
2747
|
+
}), normalizedConfig.output = output;
|
|
2748
|
+
}
|
|
2749
|
+
if (dev && ((dev = {
|
|
2730
2750
|
...dev
|
|
2731
2751
|
}).watchFiles && !Array.isArray(dev.watchFiles) && (dev.watchFiles = [
|
|
2732
2752
|
dev.watchFiles
|
|
2733
|
-
]), normalizedConfig.dev = dev),
|
|
2753
|
+
]), normalizedConfig.dev = dev), environments) {
|
|
2754
|
+
for (let [name, environment] of Object.entries(environments = {
|
|
2755
|
+
...environments
|
|
2756
|
+
}))environment && (environments[name] = normalizeConfigStructure(environment));
|
|
2757
|
+
normalizedConfig.environments = environments;
|
|
2758
|
+
}
|
|
2759
|
+
return normalizedConfig;
|
|
2734
2760
|
}, mergeRsbuildConfig = (...originalConfigs)=>{
|
|
2735
2761
|
let configs = originalConfigs.filter((config)=>void 0 !== config).map(normalizeConfigStructure);
|
|
2736
2762
|
return 2 === configs.length ? merge(configs[0], configs[1]) : 0 === configs.length ? {} : configs.reduce((result, config)=>merge(result, config), {});
|
|
@@ -2823,13 +2849,7 @@ let OVERRIDE_PATHS = new Set([
|
|
|
2823
2849
|
filename: {},
|
|
2824
2850
|
charset: 'utf8',
|
|
2825
2851
|
polyfill: 'off',
|
|
2826
|
-
dataUriLimit:
|
|
2827
|
-
svg: 4096,
|
|
2828
|
-
font: 4096,
|
|
2829
|
-
image: 4096,
|
|
2830
|
-
media: 4096,
|
|
2831
|
-
assets: 4096
|
|
2832
|
-
},
|
|
2852
|
+
dataUriLimit: 4096,
|
|
2833
2853
|
legalComments: 'linked',
|
|
2834
2854
|
injectStyles: !1,
|
|
2835
2855
|
manifest: !1,
|
|
@@ -3365,7 +3385,7 @@ async function createContext(options, userConfig, logger, loadConfigResult) {
|
|
|
3365
3385
|
return config;
|
|
3366
3386
|
})(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, hooks = initHooks();
|
|
3367
3387
|
return {
|
|
3368
|
-
version: "2.3.
|
|
3388
|
+
version: "2.3.6",
|
|
3369
3389
|
rootPath,
|
|
3370
3390
|
configFile: loadConfigResult?.filePath ?? userConfig._privateMeta?.configFilePath,
|
|
3371
3391
|
configFileDependencies: loadConfigResult?.dependencies ?? userConfig._privateMeta?.configFileDependencies ?? [],
|
|
@@ -5016,6 +5036,108 @@ function getRegExpForExts(exts) {
|
|
|
5016
5036
|
let matcher = normalizedExts.join('|');
|
|
5017
5037
|
return RegExp(1 === normalizedExts.length ? `\\.${matcher}$` : `\\.(?:${matcher})$`, 'i');
|
|
5018
5038
|
}
|
|
5039
|
+
function findWorkspaceRoot(root) {
|
|
5040
|
+
let packageRoot, current = root;
|
|
5041
|
+
for(;;){
|
|
5042
|
+
if (isFileSync(join(current, 'pnpm-workspace.yaml')) || isFileSync(join(current, 'lerna.json'))) return current;
|
|
5043
|
+
let packageJson = join(current, 'package.json');
|
|
5044
|
+
if (isFileSync(packageJson)) {
|
|
5045
|
+
packageRoot ??= current;
|
|
5046
|
+
try {
|
|
5047
|
+
let pkg = JSON.parse(readFileSync(packageJson, 'utf8'));
|
|
5048
|
+
if (pkg?.workspaces) return current;
|
|
5049
|
+
} catch {}
|
|
5050
|
+
}
|
|
5051
|
+
let parent = dirname(current);
|
|
5052
|
+
if (parent === current) return packageRoot ?? root;
|
|
5053
|
+
current = parent;
|
|
5054
|
+
}
|
|
5055
|
+
}
|
|
5056
|
+
let postcss_load_config_src = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/9e609fb6c52072bc6facf6e92463c7ae61177cd218a9d63536247c93a5b51966/node_modules/postcss-load-config/src/index.js");
|
|
5057
|
+
var postcss_load_config_src_default = compatGetDefaultExport(postcss_load_config_src);
|
|
5058
|
+
let getCSSOutputFilename = (distPath, filename)=>'function' == typeof filename ? (...args)=>posix.join(distPath, filename(...args)) : posix.join(distPath, filename), getCSSChunkFilename = ({ css, cssAsync }, filename)=>getCSSOutputFilename(cssAsync ?? (css ? `${css}/async` : 'async'), filename);
|
|
5059
|
+
function getLightningCSSLoaderOptions(config, targets, minify) {
|
|
5060
|
+
let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
|
|
5061
|
+
targets,
|
|
5062
|
+
errorRecovery: !0
|
|
5063
|
+
};
|
|
5064
|
+
return minify && (initialOptions.minify = !0), reduceConfigs({
|
|
5065
|
+
initial: initialOptions,
|
|
5066
|
+
config: userOptions
|
|
5067
|
+
});
|
|
5068
|
+
}
|
|
5069
|
+
let clonePostCSSConfig = (config)=>({
|
|
5070
|
+
...config,
|
|
5071
|
+
plugins: config.plugins ? [
|
|
5072
|
+
...config.plugins
|
|
5073
|
+
] : void 0
|
|
5074
|
+
}), getCSSSourceMap = (config)=>{
|
|
5075
|
+
let { sourceMap } = config.output;
|
|
5076
|
+
return 'boolean' == typeof sourceMap ? sourceMap : sourceMap.css;
|
|
5077
|
+
};
|
|
5078
|
+
async function loadUserPostcssrc(root, postcssrcCache) {
|
|
5079
|
+
let cached = postcssrcCache.get(root);
|
|
5080
|
+
if (cached) return clonePostCSSConfig(await cached);
|
|
5081
|
+
let promise = postcss_load_config_src_default()({}, root, {
|
|
5082
|
+
stopDir: findWorkspaceRoot(root)
|
|
5083
|
+
}).catch((err)=>{
|
|
5084
|
+
if (err.message?.includes('No PostCSS Config found')) return {};
|
|
5085
|
+
throw err;
|
|
5086
|
+
});
|
|
5087
|
+
return postcssrcCache.set(root, promise), promise.then((config)=>(postcssrcCache.set(root, config), clonePostCSSConfig(config)));
|
|
5088
|
+
}
|
|
5089
|
+
function createPostCSSTransform(root) {
|
|
5090
|
+
let postcssrcCache = new Map();
|
|
5091
|
+
return async ({ environment, CHAIN_ID }, ...rules)=>{
|
|
5092
|
+
let options = await (async ({ config, root, postcssrcCache })=>{
|
|
5093
|
+
let extraPlugins = [], userOptions = await loadUserPostcssrc(root, postcssrcCache);
|
|
5094
|
+
userOptions.plugins ||= [];
|
|
5095
|
+
let defaultOptions = {
|
|
5096
|
+
implementation: getCompiledPath('postcss'),
|
|
5097
|
+
postcssOptions: userOptions,
|
|
5098
|
+
sourceMap: getCSSSourceMap(config)
|
|
5099
|
+
}, finalOptions = await reduceConfigsWithContext({
|
|
5100
|
+
initial: defaultOptions,
|
|
5101
|
+
config: config.tools.postcss,
|
|
5102
|
+
ctx: {
|
|
5103
|
+
addPlugins (plugins, options = {}) {
|
|
5104
|
+
let { order = 'post' } = options, list = helpers_castArray(plugins);
|
|
5105
|
+
'pre' === order ? extraPlugins.unshift(...list) : extraPlugins.push(...list);
|
|
5106
|
+
}
|
|
5107
|
+
}
|
|
5108
|
+
});
|
|
5109
|
+
finalOptions.postcssOptions ||= {};
|
|
5110
|
+
let updatePostcssOptions = (options)=>(options.plugins ||= [], extraPlugins.length && options.plugins.push(...extraPlugins), options.plugins = options.plugins.map((plugin)=>'function' == typeof plugin && 'postcss' in plugin && plugin.postcss ? plugin() : plugin), options.config = !1, options), { postcssOptions } = finalOptions;
|
|
5111
|
+
if ('function' == typeof postcssOptions) {
|
|
5112
|
+
let postcssOptionsWrapper = (loaderContext)=>{
|
|
5113
|
+
let options = postcssOptions(loaderContext);
|
|
5114
|
+
if ('object' != typeof options || null === options) throw Error(`${color.dim('[rsbuild:css]')} \`postcssOptions\` function must return a PostCSSOptions object, got ${color.yellow(typeof options)}.`);
|
|
5115
|
+
return updatePostcssOptions({
|
|
5116
|
+
...userOptions,
|
|
5117
|
+
...options,
|
|
5118
|
+
plugins: [
|
|
5119
|
+
...userOptions.plugins || [],
|
|
5120
|
+
...options.plugins || []
|
|
5121
|
+
]
|
|
5122
|
+
});
|
|
5123
|
+
};
|
|
5124
|
+
return postcssOptionsWrapper.config = !1, {
|
|
5125
|
+
...finalOptions,
|
|
5126
|
+
postcssOptions: postcssOptionsWrapper
|
|
5127
|
+
};
|
|
5128
|
+
}
|
|
5129
|
+
return finalOptions.postcssOptions = updatePostcssOptions(postcssOptions), finalOptions;
|
|
5130
|
+
})({
|
|
5131
|
+
config: environment.config,
|
|
5132
|
+
root,
|
|
5133
|
+
postcssrcCache
|
|
5134
|
+
});
|
|
5135
|
+
if ('function' != typeof options.postcssOptions && !options.postcssOptions?.plugins?.length) return !1;
|
|
5136
|
+
let loader = getCompiledPath('postcss-loader');
|
|
5137
|
+
for (let rule of rules)rule?.use(CHAIN_ID.USE.POSTCSS).loader(loader).options(options);
|
|
5138
|
+
return !0;
|
|
5139
|
+
};
|
|
5140
|
+
}
|
|
5019
5141
|
function getCacheDirectory({ cacheDirectory }, context) {
|
|
5020
5142
|
return cacheDirectory ? external_node_path_isAbsolute(cacheDirectory) ? cacheDirectory : join(context.rootPath, cacheDirectory) : join(context.cachePath, 'rspack');
|
|
5021
5143
|
}
|
|
@@ -5054,25 +5176,7 @@ let normalizeCleanDistPath = (userOptions)=>{
|
|
|
5054
5176
|
...defaultOptions,
|
|
5055
5177
|
...userOptions
|
|
5056
5178
|
};
|
|
5057
|
-
}
|
|
5058
|
-
function findWorkspaceRoot(root) {
|
|
5059
|
-
let packageRoot, current = root;
|
|
5060
|
-
for(;;){
|
|
5061
|
-
if (isFileSync(join(current, 'pnpm-workspace.yaml')) || isFileSync(join(current, 'lerna.json'))) return current;
|
|
5062
|
-
let packageJson = join(current, 'package.json');
|
|
5063
|
-
if (isFileSync(packageJson)) {
|
|
5064
|
-
packageRoot ??= current;
|
|
5065
|
-
try {
|
|
5066
|
-
let pkg = JSON.parse(readFileSync(packageJson, 'utf8'));
|
|
5067
|
-
if (pkg?.workspaces) return current;
|
|
5068
|
-
} catch {}
|
|
5069
|
-
}
|
|
5070
|
-
let parent = dirname(current);
|
|
5071
|
-
if (parent === current) return packageRoot ?? root;
|
|
5072
|
-
current = parent;
|
|
5073
|
-
}
|
|
5074
|
-
}
|
|
5075
|
-
let getConsolePureFuncs = (methods)=>methods.map((method)=>`console.${method}`), ALL_CONSOLE_PURE_FUNCS = getConsolePureFuncs([
|
|
5179
|
+
}, getConsolePureFuncs = (methods)=>methods.map((method)=>`console.${method}`), ALL_CONSOLE_PURE_FUNCS = getConsolePureFuncs([
|
|
5076
5180
|
'assert',
|
|
5077
5181
|
'clear',
|
|
5078
5182
|
'count',
|
|
@@ -5132,38 +5236,6 @@ function parseMinifyOptions(config) {
|
|
|
5132
5236
|
cssOptions: minify.cssOptions
|
|
5133
5237
|
};
|
|
5134
5238
|
}
|
|
5135
|
-
let postcss_load_config_src = rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/postcss-load-config/6.0.1/b7f5a594bf00404e4e776a1083b3a0cfef602f460cf7e11269b23855d34ff149/node_modules/postcss-load-config/src/index.js");
|
|
5136
|
-
var postcss_load_config_src_default = compatGetDefaultExport(postcss_load_config_src);
|
|
5137
|
-
function getLightningCSSLoaderOptions(config, targets, minify) {
|
|
5138
|
-
let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
|
|
5139
|
-
targets,
|
|
5140
|
-
errorRecovery: !0
|
|
5141
|
-
};
|
|
5142
|
-
return minify && (initialOptions.minify = !0), reduceConfigs({
|
|
5143
|
-
initial: initialOptions,
|
|
5144
|
-
config: userOptions
|
|
5145
|
-
});
|
|
5146
|
-
}
|
|
5147
|
-
let clonePostCSSConfig = (config)=>({
|
|
5148
|
-
...config,
|
|
5149
|
-
plugins: config.plugins ? [
|
|
5150
|
-
...config.plugins
|
|
5151
|
-
] : void 0
|
|
5152
|
-
}), getCSSSourceMap = (config)=>{
|
|
5153
|
-
let { sourceMap } = config.output;
|
|
5154
|
-
return 'boolean' == typeof sourceMap ? sourceMap : sourceMap.css;
|
|
5155
|
-
};
|
|
5156
|
-
async function loadUserPostcssrc(root, postcssrcCache) {
|
|
5157
|
-
let cached = postcssrcCache.get(root);
|
|
5158
|
-
if (cached) return clonePostCSSConfig(await cached);
|
|
5159
|
-
let promise = postcss_load_config_src_default()({}, root, {
|
|
5160
|
-
stopDir: findWorkspaceRoot(root)
|
|
5161
|
-
}).catch((err)=>{
|
|
5162
|
-
if (err.message?.includes('No PostCSS Config found')) return {};
|
|
5163
|
-
throw err;
|
|
5164
|
-
});
|
|
5165
|
-
return postcssrcCache.set(root, promise), promise.then((config)=>(postcssrcCache.set(root, config), clonePostCSSConfig(config)));
|
|
5166
|
-
}
|
|
5167
5239
|
function checkProcessEnvSecurity(define, logger) {
|
|
5168
5240
|
let value = define['process.env'];
|
|
5169
5241
|
if (!value) return;
|
|
@@ -5985,7 +6057,7 @@ function doesChunkBelongToHtml({ chunk, htmlPluginData }) {
|
|
|
5985
6057
|
let { options } = htmlPluginData.plugin;
|
|
5986
6058
|
return recursiveChunkEntryNames(chunk).some((chunkName)=>isChunksFiltered(chunkName, options?.chunks, options?.excludeChunks));
|
|
5987
6059
|
}
|
|
5988
|
-
let getManifestPlugin = cachedImport_cachedImport(()=>import("./manifest-plugin.js").then(()=>rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/rspack-manifest-plugin/5.2.2/
|
|
6060
|
+
let getManifestPlugin = cachedImport_cachedImport(()=>import("./manifest-plugin.js").then(()=>rspackRequire("../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/rspack-manifest-plugin/5.2.2/b54c3f7e531ab4051357d2e4e706e67fa438667b770e5dc3518ad8bd544f3dc3/node_modules/rspack-manifest-plugin/dist/index.js"))), isCSSPath = (filePath)=>filePath.endsWith('.css');
|
|
5989
6061
|
function normalizeManifestObjectConfig(manifest) {
|
|
5990
6062
|
let defaultOptions = {
|
|
5991
6063
|
prefix: !0,
|
|
@@ -7163,11 +7235,11 @@ class SocketServer {
|
|
|
7163
7235
|
this.context = context, this.options = options, this.getOutputFileSystem = getOutputFileSystem, this.onSocketConnect = onSocketConnect, this.onSocketCustomMessage = onSocketCustomMessage;
|
|
7164
7236
|
}
|
|
7165
7237
|
upgrade = (req, socket, head)=>{
|
|
7166
|
-
if (!this.wsServer.shouldHandle(req)) return;
|
|
7238
|
+
if (!this.wsServer.shouldHandle(req)) return !1;
|
|
7167
7239
|
let query = parseQueryString(req);
|
|
7168
|
-
this.context.environmentList.some(({ webSocketToken })=>webSocketToken === query.token) ? this.wsServer.handleUpgrade(req, socket, head, (connection)=>{
|
|
7240
|
+
return this.context.environmentList.some(({ webSocketToken })=>webSocketToken === query.token) ? this.wsServer.handleUpgrade(req, socket, head, (connection)=>{
|
|
7169
7241
|
this.wsServer.emit('connection', connection, req);
|
|
7170
|
-
}) : socket.destroy();
|
|
7242
|
+
}) : socket.destroy(), !0;
|
|
7171
7243
|
};
|
|
7172
7244
|
checkSockets = ()=>{
|
|
7173
7245
|
for (let socket of this.wsServer.clients)socket.isAlive ? (socket.isAlive = !1, socket.ping(()=>{})) : socket.terminate();
|
|
@@ -8452,7 +8524,7 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8452
8524
|
})(options.config, options.devServer, logger);
|
|
8453
8525
|
for (let middleware of before)middlewares.use(middleware);
|
|
8454
8526
|
let { onUpgrade } = await (async ({ config, buildManager, context, devServer, middlewares, postCallbacks })=>{
|
|
8455
|
-
let
|
|
8527
|
+
let proxyUpgrade, launchEditorHandlerPromise, { server } = config, { logger } = context, servedEnvironments = context.environmentList.filter((environment)=>isServingAssets(environment.config)), distPaths = [
|
|
8456
8528
|
...new Set(servedEnvironments.map((environment)=>environment.distPath))
|
|
8457
8529
|
];
|
|
8458
8530
|
if (server.cors) {
|
|
@@ -8465,7 +8537,7 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8465
8537
|
next();
|
|
8466
8538
|
}), server.proxy) {
|
|
8467
8539
|
let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy, logger);
|
|
8468
|
-
for (let middleware of (
|
|
8540
|
+
for (let middleware of (proxyUpgrade = upgrade, proxyMiddlewares))middlewares.use(middleware);
|
|
8469
8541
|
}
|
|
8470
8542
|
let { compress } = server;
|
|
8471
8543
|
if (compress && middlewares.use(gzipMiddleware_gzipMiddleware('object' == typeof compress ? compress : void 0)), 'dev' === context.action && buildManager) {
|
|
@@ -8544,7 +8616,7 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8544
8616
|
})({
|
|
8545
8617
|
environments: pick(devServer.environments, servedEnvironments.map((environment)=>environment.name)),
|
|
8546
8618
|
logger
|
|
8547
|
-
})), buildManager && (middlewares.use(buildManager.assetsMiddleware),
|
|
8619
|
+
})), buildManager && (middlewares.use(buildManager.assetsMiddleware), middlewares.use(function hotUpdateJsonFallbackMiddleware(req, res, next) {
|
|
8548
8620
|
let url = req.url;
|
|
8549
8621
|
if (!url || 'OPTIONS' === req.method) return void next();
|
|
8550
8622
|
let queryIndex = url.indexOf('?'), end = -1 === queryIndex ? url.length : queryIndex;
|
|
@@ -8575,7 +8647,7 @@ async function devServer_createDevServer(options, createCompiler, config, devSer
|
|
|
8575
8647
|
outputFileSystem: buildManager.outputFileSystem
|
|
8576
8648
|
})), middlewares.use(faviconFallbackMiddleware), {
|
|
8577
8649
|
onUpgrade: (...args)=>{
|
|
8578
|
-
|
|
8650
|
+
buildManager?.socketServer.upgrade(...args) || proxyUpgrade?.(...args);
|
|
8579
8651
|
}
|
|
8580
8652
|
};
|
|
8581
8653
|
})({
|
|
@@ -8838,7 +8910,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8838
8910
|
...chain.get('experiments'),
|
|
8839
8911
|
newCache: !0
|
|
8840
8912
|
}), cacheEnabled = !0;
|
|
8841
|
-
let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = getCacheDirectory(cacheConfig, context), buildDependencies = await getBuildDependencies(context, environment, cacheConfig.buildDependencies), useDigest = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length, cacheVersion = `rsbuild-2.3.
|
|
8913
|
+
let { context } = api, cacheConfig = 'boolean' == typeof buildCache ? {} : buildCache, cacheDirectory = getCacheDirectory(cacheConfig, context), buildDependencies = await getBuildDependencies(context, environment, cacheConfig.buildDependencies), useDigest = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length, cacheVersion = `rsbuild-2.3.6-${environment.name}-${env}`;
|
|
8842
8914
|
chain.cache({
|
|
8843
8915
|
type: 'persistent',
|
|
8844
8916
|
version: useDigest ? `${cacheVersion}-${await helpers_hash(JSON.stringify(cacheConfig.cacheDigest))}` : cacheVersion,
|
|
@@ -8899,18 +8971,15 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8899
8971
|
}
|
|
8900
8972
|
});
|
|
8901
8973
|
let isESM = config.output.module;
|
|
8902
|
-
|
|
8974
|
+
isServer && chain.output.merge({
|
|
8903
8975
|
library: {
|
|
8904
8976
|
type: isESM ? 'module' : 'commonjs2'
|
|
8905
8977
|
}
|
|
8906
|
-
}), isESM && (chain.node.set('__dirname', !1).set('__filename', !1), chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import'))
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
options
|
|
8912
|
-
]);
|
|
8913
|
-
}
|
|
8978
|
+
}), isESM && (chain.node.set('__dirname', !1).set('__filename', !1), chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import'));
|
|
8979
|
+
let { copy } = config.output;
|
|
8980
|
+
copy && chain.plugin(CHAIN_ID.PLUGIN.COPY).use(rspack.CopyRspackPlugin, [
|
|
8981
|
+
normalizeCopyOptions(copy)
|
|
8982
|
+
]);
|
|
8914
8983
|
});
|
|
8915
8984
|
}
|
|
8916
8985
|
},
|
|
@@ -9355,11 +9424,49 @@ try {
|
|
|
9355
9424
|
{
|
|
9356
9425
|
name: 'rsbuild:css',
|
|
9357
9426
|
setup (api) {
|
|
9358
|
-
let
|
|
9427
|
+
let applyPostCSS = createPostCSSTransform(api.context.rootPath);
|
|
9428
|
+
async function applyCSSTransforms(utils, mainRule, inlineRule, urlRule) {
|
|
9429
|
+
let { environment, environments, target, CHAIN_ID } = utils, { config } = environment, cssUrlMinimized = !1, useLightningCSS = !1 !== config.tools.lightningcssLoader;
|
|
9430
|
+
if (useLightningCSS) {
|
|
9431
|
+
let { minifyCss, cssOptions } = parseMinifyOptions(config), { browserslist } = environment;
|
|
9432
|
+
if ('node' === target) {
|
|
9433
|
+
let webEnvironment = Object.values(environments).find((env)=>'web' === env.config.output.target);
|
|
9434
|
+
if (webEnvironment) {
|
|
9435
|
+
browserslist = webEnvironment.browserslist;
|
|
9436
|
+
let webMinifyOptions = parseMinifyOptions(webEnvironment.config);
|
|
9437
|
+
minifyCss = webMinifyOptions.minifyCss, cssOptions ??= webMinifyOptions.cssOptions;
|
|
9438
|
+
}
|
|
9439
|
+
}
|
|
9440
|
+
let cssUrlMinimizerOptions = minifyCss ? ((cssOptions)=>{
|
|
9441
|
+
let options = helpers_castArray(cssOptions), { minimizerOptions, test, include, exclude } = options[0] ?? {};
|
|
9442
|
+
return !(options.length > 1 || [
|
|
9443
|
+
test,
|
|
9444
|
+
include,
|
|
9445
|
+
exclude
|
|
9446
|
+
].some((value)=>void 0 !== value)) && (minimizerOptions ?? {});
|
|
9447
|
+
})(cssOptions) : {}, addLightningCSS = async (rule, type)=>{
|
|
9448
|
+
let minify = ('inline' === type || 'url' === type || config.output.injectStyles) && minifyCss, lightningcssOptions = await getLightningCSSLoaderOptions(config, browserslist, minify);
|
|
9449
|
+
if ('url' === type && !0 === lightningcssOptions.minify && !1 !== cssUrlMinimizerOptions) {
|
|
9450
|
+
var loaderOptions;
|
|
9451
|
+
let options;
|
|
9452
|
+
loaderOptions = lightningcssOptions, options = cjs_0_default()(loaderOptions, cssUrlMinimizerOptions), isPlainObject(cssUrlMinimizerOptions.targets) && (options.targets = cssUrlMinimizerOptions.targets), lightningcssOptions = options, cssUrlMinimized = !0;
|
|
9453
|
+
}
|
|
9454
|
+
rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(lightningcssOptions);
|
|
9455
|
+
};
|
|
9456
|
+
mainRule && await addLightningCSS(mainRule, 'main'), await addLightningCSS(inlineRule, 'inline'), await addLightningCSS(urlRule, 'url');
|
|
9457
|
+
}
|
|
9458
|
+
return {
|
|
9459
|
+
useLightningCSS,
|
|
9460
|
+
usePostCSS: await applyPostCSS(utils, mainRule, inlineRule, urlRule),
|
|
9461
|
+
cssUrlMinimized
|
|
9462
|
+
};
|
|
9463
|
+
}
|
|
9359
9464
|
api.modifyBundlerChain({
|
|
9360
9465
|
order: 'pre',
|
|
9361
|
-
handler: async (chain,
|
|
9362
|
-
let
|
|
9466
|
+
handler: async (chain, utils)=>{
|
|
9467
|
+
let { target, isProd, CHAIN_ID, environment } = utils, { config } = environment;
|
|
9468
|
+
if (config.css) return;
|
|
9469
|
+
let cssRule = chain.module.rule(CHAIN_ID.RULE.CSS);
|
|
9363
9470
|
cssRule.test(CSS_REGEX).dependency({
|
|
9364
9471
|
not: 'url'
|
|
9365
9472
|
}), cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_TEXT).with({
|
|
@@ -9378,100 +9485,9 @@ try {
|
|
|
9378
9485
|
mainRule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
|
|
9379
9486
|
} else mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(core_rspack.CssExtractRspackPlugin.loader).options(config.tools.cssExtract.loaderOptions);
|
|
9380
9487
|
else mainRule.use(CHAIN_ID.USE.IGNORE_CSS).loader(node_path.join(LOADER_PATH, 'ignoreCssLoader.mjs'));
|
|
9381
|
-
let
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
}, updateRules = async (callback, options = {})=>{
|
|
9385
|
-
options.skipMain || await callback(mainRule, 'main'), await callback(inlineRule, 'inline'), await callback(urlRule, 'url');
|
|
9386
|
-
}, cssLoaderPath = getCompiledPath('css-loader');
|
|
9387
|
-
await updateRules((rule)=>{
|
|
9388
|
-
rule.use(CHAIN_ID.USE.CSS).loader(cssLoaderPath);
|
|
9389
|
-
});
|
|
9390
|
-
let cssUrlMinimized = !1;
|
|
9391
|
-
if (!1 !== config.tools.lightningcssLoader) {
|
|
9392
|
-
emitCss && importLoaders.normal++, importLoaders.inline++;
|
|
9393
|
-
let { minifyCss, cssOptions } = parseMinifyOptions(config), { browserslist } = environment;
|
|
9394
|
-
if ('node' === target) {
|
|
9395
|
-
let webEnvironment = Object.values(environments).find((env)=>'web' === env.config.output.target);
|
|
9396
|
-
if (webEnvironment) {
|
|
9397
|
-
browserslist = webEnvironment.browserslist;
|
|
9398
|
-
let webMinifyOptions = parseMinifyOptions(webEnvironment.config);
|
|
9399
|
-
minifyCss = webMinifyOptions.minifyCss, cssOptions ??= webMinifyOptions.cssOptions;
|
|
9400
|
-
}
|
|
9401
|
-
}
|
|
9402
|
-
let cssUrlMinimizerOptions = minifyCss ? ((cssOptions)=>{
|
|
9403
|
-
let options = helpers_castArray(cssOptions), { minimizerOptions, test, include, exclude } = options[0] ?? {};
|
|
9404
|
-
return !(options.length > 1 || [
|
|
9405
|
-
test,
|
|
9406
|
-
include,
|
|
9407
|
-
exclude
|
|
9408
|
-
].some((value)=>void 0 !== value)) && (minimizerOptions ?? {});
|
|
9409
|
-
})(cssOptions) : {};
|
|
9410
|
-
await updateRules(async (rule, type)=>{
|
|
9411
|
-
let minify = ('inline' === type || 'url' === type || config.output.injectStyles) && minifyCss, lightningcssOptions = await getLightningCSSLoaderOptions(config, browserslist, minify);
|
|
9412
|
-
if ('url' === type && !0 === lightningcssOptions.minify && !1 !== cssUrlMinimizerOptions) {
|
|
9413
|
-
var loaderOptions;
|
|
9414
|
-
let options;
|
|
9415
|
-
loaderOptions = lightningcssOptions, options = cjs_0_default()(loaderOptions, cssUrlMinimizerOptions), isPlainObject(cssUrlMinimizerOptions.targets) && (options.targets = cssUrlMinimizerOptions.targets), lightningcssOptions = options, cssUrlMinimized = !0;
|
|
9416
|
-
}
|
|
9417
|
-
rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(lightningcssOptions);
|
|
9418
|
-
}, {
|
|
9419
|
-
skipMain: !emitCss
|
|
9420
|
-
});
|
|
9421
|
-
}
|
|
9422
|
-
let postcssLoaderOptions = await (async ({ config, root, postcssrcCache })=>{
|
|
9423
|
-
let extraPlugins = [], userOptions = await loadUserPostcssrc(root, postcssrcCache);
|
|
9424
|
-
userOptions.plugins ||= [];
|
|
9425
|
-
let defaultOptions = {
|
|
9426
|
-
implementation: getCompiledPath('postcss'),
|
|
9427
|
-
postcssOptions: userOptions,
|
|
9428
|
-
sourceMap: getCSSSourceMap(config)
|
|
9429
|
-
}, finalOptions = await reduceConfigsWithContext({
|
|
9430
|
-
initial: defaultOptions,
|
|
9431
|
-
config: config.tools.postcss,
|
|
9432
|
-
ctx: {
|
|
9433
|
-
addPlugins (plugins, options = {}) {
|
|
9434
|
-
let { order = 'post' } = options, list = helpers_castArray(plugins);
|
|
9435
|
-
'pre' === order ? extraPlugins.unshift(...list) : extraPlugins.push(...list);
|
|
9436
|
-
}
|
|
9437
|
-
}
|
|
9438
|
-
});
|
|
9439
|
-
finalOptions.postcssOptions ||= {};
|
|
9440
|
-
let updatePostcssOptions = (options)=>(options.plugins ||= [], extraPlugins.length && options.plugins.push(...extraPlugins), options.plugins = options.plugins.map((plugin)=>'function' == typeof plugin && 'postcss' in plugin && plugin.postcss ? plugin() : plugin), options.config = !1, options), { postcssOptions } = finalOptions;
|
|
9441
|
-
if ('function' == typeof postcssOptions) {
|
|
9442
|
-
let postcssOptionsWrapper = (loaderContext)=>{
|
|
9443
|
-
let options = postcssOptions(loaderContext);
|
|
9444
|
-
if ('object' != typeof options || null === options) throw Error(`${color.dim('[rsbuild:css]')} \`postcssOptions\` function must return a PostCSSOptions object, got ${color.yellow(typeof options)}.`);
|
|
9445
|
-
return updatePostcssOptions({
|
|
9446
|
-
...userOptions,
|
|
9447
|
-
...options,
|
|
9448
|
-
plugins: [
|
|
9449
|
-
...userOptions.plugins || [],
|
|
9450
|
-
...options.plugins || []
|
|
9451
|
-
]
|
|
9452
|
-
});
|
|
9453
|
-
};
|
|
9454
|
-
return postcssOptionsWrapper.config = !1, {
|
|
9455
|
-
...finalOptions,
|
|
9456
|
-
postcssOptions: postcssOptionsWrapper
|
|
9457
|
-
};
|
|
9458
|
-
}
|
|
9459
|
-
return finalOptions.postcssOptions = updatePostcssOptions(postcssOptions), finalOptions;
|
|
9460
|
-
})({
|
|
9461
|
-
config,
|
|
9462
|
-
root: api.context.rootPath,
|
|
9463
|
-
postcssrcCache
|
|
9464
|
-
});
|
|
9465
|
-
if ('function' == typeof postcssLoaderOptions.postcssOptions || postcssLoaderOptions.postcssOptions?.plugins?.length) {
|
|
9466
|
-
emitCss && importLoaders.normal++, importLoaders.inline++;
|
|
9467
|
-
let postcssLoaderPath = getCompiledPath('postcss-loader');
|
|
9468
|
-
await updateRules((rule)=>{
|
|
9469
|
-
rule.use(CHAIN_ID.USE.POSTCSS).loader(postcssLoaderPath).options(postcssLoaderOptions);
|
|
9470
|
-
}, {
|
|
9471
|
-
skipMain: !emitCss
|
|
9472
|
-
});
|
|
9473
|
-
}
|
|
9474
|
-
let localIdentName = config.output.cssModules.localIdentName || (isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'), cssLoaderOptions = await (async ({ config, localIdentName, emitCss })=>{
|
|
9488
|
+
let cssLoaderPath = getCompiledPath('css-loader');
|
|
9489
|
+
mainRule.use(CHAIN_ID.USE.CSS).loader(cssLoaderPath), inlineRule.use(CHAIN_ID.USE.CSS).loader(cssLoaderPath), urlRule.use(CHAIN_ID.USE.CSS).loader(cssLoaderPath);
|
|
9490
|
+
let { useLightningCSS, usePostCSS, cssUrlMinimized } = await applyCSSTransforms(utils, emitCss ? mainRule : void 0, inlineRule, urlRule), importLoaders = Number(useLightningCSS) + Number(usePostCSS), localIdentName = config.output.cssModules.localIdentName || (isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'), cssLoaderOptions = await (async ({ config, localIdentName, emitCss })=>{
|
|
9475
9491
|
let { cssModules } = config.output, defaultOptions = {
|
|
9476
9492
|
modules: {
|
|
9477
9493
|
...cssModules,
|
|
@@ -9505,44 +9521,60 @@ try {
|
|
|
9505
9521
|
config,
|
|
9506
9522
|
localIdentName,
|
|
9507
9523
|
emitCss
|
|
9508
|
-
})
|
|
9509
|
-
await updateRules((rule, type)=>{
|
|
9524
|
+
}), configureCSSLoader = (rule, type)=>{
|
|
9510
9525
|
let finalOptions = 'inline' === type || 'url' === type ? {
|
|
9511
9526
|
...cssLoaderOptions,
|
|
9512
9527
|
exportType: 'string',
|
|
9513
9528
|
modules: !1,
|
|
9514
|
-
importLoaders
|
|
9529
|
+
importLoaders
|
|
9515
9530
|
} : {
|
|
9516
9531
|
...cssLoaderOptions,
|
|
9517
|
-
importLoaders: importLoaders
|
|
9532
|
+
importLoaders: emitCss ? importLoaders : 0
|
|
9518
9533
|
};
|
|
9519
9534
|
emitCss || 'main' !== type || rule.use(CHAIN_ID.USE.IGNORE_CSS).options({
|
|
9520
9535
|
modules: finalOptions.modules
|
|
9521
9536
|
}), rule.use(CHAIN_ID.USE.CSS).options(finalOptions), 'url' !== type && rule.sideEffects(!0), rule.resolve.preferRelative(!0);
|
|
9522
|
-
}
|
|
9523
|
-
|
|
9537
|
+
};
|
|
9538
|
+
configureCSSLoader(mainRule, 'main'), configureCSSLoader(inlineRule, 'inline'), configureCSSLoader(urlRule, 'url');
|
|
9539
|
+
let { distPath } = config.output, cssFilename = getFilename(config, 'css', isProd), filename = getCSSOutputFilename(distPath.css, cssFilename);
|
|
9524
9540
|
urlRule.use(CHAIN_ID.USE.CSS_URL).options({
|
|
9525
|
-
filename
|
|
9541
|
+
filename,
|
|
9526
9542
|
modules: cssLoaderOptions.modules,
|
|
9527
9543
|
minimized: cssUrlMinimized
|
|
9528
9544
|
});
|
|
9529
9545
|
let isStringExport = 'string' === cssLoaderOptions.exportType;
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
+
isStringExport && mainRule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT) && mainRule.uses.delete(CHAIN_ID.USE.MINI_CSS_EXTRACT), !emitCss || config.output.injectStyles || isStringExport || chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(core_rspack.CssExtractRspackPlugin, [
|
|
9547
|
+
{
|
|
9548
|
+
filename,
|
|
9549
|
+
chunkFilename: getCSSChunkFilename(distPath, cssFilename),
|
|
9550
|
+
...config.tools.cssExtract.pluginOptions
|
|
9551
|
+
}
|
|
9552
|
+
]);
|
|
9553
|
+
}
|
|
9554
|
+
});
|
|
9555
|
+
}
|
|
9556
|
+
},
|
|
9557
|
+
{
|
|
9558
|
+
name: 'rsbuild:builtin-css',
|
|
9559
|
+
setup (api) {
|
|
9560
|
+
let applyPostCSS = createPostCSSTransform(api.context.rootPath);
|
|
9561
|
+
api.modifyBundlerChain({
|
|
9562
|
+
order: 'pre',
|
|
9563
|
+
handler: async (chain, utils)=>{
|
|
9564
|
+
let { environment, CHAIN_ID, isProd } = utils, { config, browserslist } = environment;
|
|
9565
|
+
if (!config.css) return;
|
|
9566
|
+
let cssRule = chain.module.rule(CHAIN_ID.RULE.CSS);
|
|
9567
|
+
cssRule.test(CSS_REGEX).dependency({
|
|
9568
|
+
not: 'url'
|
|
9569
|
+
}), cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_TEXT).with({
|
|
9570
|
+
type: 'text'
|
|
9571
|
+
}).type('asset/source'), cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_RAW).resourceQuery(RAW_QUERY_REGEX).type('asset/source');
|
|
9572
|
+
let mainRule = cssRule.oneOf(CHAIN_ID.ONE_OF.CSS_MAIN);
|
|
9573
|
+
if (mainRule.type('css/auto').sideEffects(!0).resolve.preferRelative(!0), !1 !== config.tools.lightningcssLoader && mainRule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(await getLightningCSSLoaderOptions(config, browserslist, !1)), await applyPostCSS(utils, mainRule), 'object' == typeof config.css && 'style' === config.css.exportType) return void mainRule.parser({
|
|
9574
|
+
exportType: 'style'
|
|
9575
|
+
});
|
|
9576
|
+
let { distPath } = config.output, cssFilename = getFilename(config, 'css', isProd);
|
|
9577
|
+
chain.output.set('cssFilename', getCSSOutputFilename(distPath.css, cssFilename)).set('cssChunkFilename', getCSSChunkFilename(distPath, cssFilename));
|
|
9546
9578
|
}
|
|
9547
9579
|
});
|
|
9548
9580
|
}
|
|
@@ -10591,7 +10623,7 @@ let applyServerOptions = (command)=>{
|
|
|
10591
10623
|
};
|
|
10592
10624
|
function setupCommands(argv) {
|
|
10593
10625
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
10594
|
-
cli.version("2.3.
|
|
10626
|
+
cli.version("2.3.6"), 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)', {
|
|
10595
10627
|
default: 'auto'
|
|
10596
10628
|
}).option('--dist-path <dir>', 'Set the root directory of output files').option('--source-map', 'Enable source map').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', {
|
|
10597
10629
|
type: [
|
|
@@ -10656,7 +10688,7 @@ function setupCommands(argv) {
|
|
|
10656
10688
|
}
|
|
10657
10689
|
function showGreeting() {
|
|
10658
10690
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
10659
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.3.
|
|
10691
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.3.6\n`);
|
|
10660
10692
|
}
|
|
10661
10693
|
function setupLogLevel(argv) {
|
|
10662
10694
|
if (argv.length <= 3) return;
|
|
@@ -10678,5 +10710,5 @@ function runCLI({ argv = process.argv } = {}) {
|
|
|
10678
10710
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
10679
10711
|
}
|
|
10680
10712
|
}
|
|
10681
|
-
let src_version = "2.3.
|
|
10713
|
+
let src_version = "2.3.6";
|
|
10682
10714
|
export { core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, mrmime_lookup, runCLI, src_logger as logger, src_version as version };
|