@rsbuild/core 1.0.18 → 1.0.19
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/dist/index.cjs +58 -28
- package/dist/index.js +60 -30
- package/dist-types/types/thirdParty.d.ts +6 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6029,7 +6029,7 @@ async function createContext(options, userConfig, bundlerType) {
|
|
|
6029
6029
|
const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
|
|
6030
6030
|
const cachePath = (0, import_node_path10.join)(rootPath, "node_modules", ".cache");
|
|
6031
6031
|
return {
|
|
6032
|
-
version: "1.0.
|
|
6032
|
+
version: "1.0.19",
|
|
6033
6033
|
rootPath,
|
|
6034
6034
|
distPath: "",
|
|
6035
6035
|
cachePath,
|
|
@@ -9636,7 +9636,7 @@ async function applyCSSRule({
|
|
|
9636
9636
|
config,
|
|
9637
9637
|
root: context.rootPath
|
|
9638
9638
|
});
|
|
9639
|
-
if (postcssLoaderOptions.postcssOptions?.plugins?.length) {
|
|
9639
|
+
if (typeof postcssLoaderOptions.postcssOptions === "function" || postcssLoaderOptions.postcssOptions?.plugins?.length) {
|
|
9640
9640
|
importLoaders++;
|
|
9641
9641
|
rule.use(CHAIN_ID2.USE.POSTCSS).loader(getCompiledPath("postcss-loader")).options(postcssLoaderOptions);
|
|
9642
9642
|
}
|
|
@@ -9660,6 +9660,7 @@ var init_css = __esm({
|
|
|
9660
9660
|
import_deepmerge2 = __toESM(require_cjs());
|
|
9661
9661
|
init_dist2();
|
|
9662
9662
|
init_constants();
|
|
9663
|
+
init_helpers();
|
|
9663
9664
|
init_path();
|
|
9664
9665
|
init_pluginHelper();
|
|
9665
9666
|
isUseCssExtract = (config, target) => !config.output.injectStyles && target !== "node" && target !== "web-worker";
|
|
@@ -9701,35 +9702,57 @@ var init_css = __esm({
|
|
|
9701
9702
|
const extraPlugins = [];
|
|
9702
9703
|
const utils = {
|
|
9703
9704
|
addPlugins(plugins) {
|
|
9704
|
-
|
|
9705
|
-
extraPlugins.push(...plugins);
|
|
9706
|
-
} else {
|
|
9707
|
-
extraPlugins.push(plugins);
|
|
9708
|
-
}
|
|
9705
|
+
extraPlugins.push(...castArray(plugins));
|
|
9709
9706
|
}
|
|
9710
9707
|
};
|
|
9711
|
-
const
|
|
9712
|
-
|
|
9713
|
-
const
|
|
9708
|
+
const userOptions = await loadUserPostcssrc(root);
|
|
9709
|
+
userOptions.plugins ||= [];
|
|
9710
|
+
const defaultOptions2 = {
|
|
9714
9711
|
implementation: getCompiledPath("postcss"),
|
|
9715
|
-
postcssOptions:
|
|
9712
|
+
postcssOptions: userOptions,
|
|
9716
9713
|
sourceMap: config.output.sourceMap.css
|
|
9717
9714
|
};
|
|
9718
|
-
const
|
|
9719
|
-
initial:
|
|
9715
|
+
const finalOptions = reduceConfigsWithContext({
|
|
9716
|
+
initial: defaultOptions2,
|
|
9720
9717
|
config: config.tools.postcss,
|
|
9721
9718
|
ctx: utils
|
|
9722
9719
|
});
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9720
|
+
finalOptions.postcssOptions ||= {};
|
|
9721
|
+
const updatePostcssOptions = (options) => {
|
|
9722
|
+
options.plugins ||= [];
|
|
9723
|
+
if (extraPlugins.length) {
|
|
9724
|
+
options.plugins.push(...extraPlugins);
|
|
9725
|
+
}
|
|
9726
|
+
options.plugins = options.plugins.map(
|
|
9727
|
+
(plugin) => isPostcssPluginCreator(plugin) ? plugin() : plugin
|
|
9728
|
+
);
|
|
9729
|
+
options.config = false;
|
|
9730
|
+
return options;
|
|
9731
|
+
};
|
|
9732
|
+
const { postcssOptions } = finalOptions;
|
|
9733
|
+
if (typeof postcssOptions === "function") {
|
|
9734
|
+
const postcssOptionsWrapper = (loaderContext) => {
|
|
9735
|
+
const options = postcssOptions(loaderContext);
|
|
9736
|
+
if (typeof options !== "object" || options === null) {
|
|
9737
|
+
throw new Error(
|
|
9738
|
+
`\`postcssOptions\` function must return a PostCSSOptions object, got "${typeof options}".`
|
|
9739
|
+
);
|
|
9740
|
+
}
|
|
9741
|
+
const mergedOptions = {
|
|
9742
|
+
...userOptions,
|
|
9743
|
+
...options,
|
|
9744
|
+
plugins: [...userOptions.plugins || [], ...options.plugins || []]
|
|
9745
|
+
};
|
|
9746
|
+
return updatePostcssOptions(mergedOptions);
|
|
9747
|
+
};
|
|
9748
|
+
postcssOptionsWrapper.config = false;
|
|
9749
|
+
return {
|
|
9750
|
+
...finalOptions,
|
|
9751
|
+
postcssOptions: postcssOptionsWrapper
|
|
9752
|
+
};
|
|
9727
9753
|
}
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
);
|
|
9731
|
-
merged.postcssOptions.config = false;
|
|
9732
|
-
return merged;
|
|
9754
|
+
finalOptions.postcssOptions = updatePostcssOptions(postcssOptions);
|
|
9755
|
+
return finalOptions;
|
|
9733
9756
|
};
|
|
9734
9757
|
getCSSLoaderOptions = ({
|
|
9735
9758
|
config,
|
|
@@ -11371,7 +11394,11 @@ function getDefaultSwcConfig(browserslist, cacheRoot) {
|
|
|
11371
11394
|
decorators: true
|
|
11372
11395
|
},
|
|
11373
11396
|
experimental: {
|
|
11374
|
-
cacheRoot
|
|
11397
|
+
cacheRoot,
|
|
11398
|
+
/**
|
|
11399
|
+
* Preserve `with` in imports and exports.
|
|
11400
|
+
*/
|
|
11401
|
+
keepImportAttributes: true
|
|
11375
11402
|
}
|
|
11376
11403
|
},
|
|
11377
11404
|
isModule: "unknown",
|
|
@@ -12892,7 +12919,7 @@ var sri_exports = {};
|
|
|
12892
12919
|
__export(sri_exports, {
|
|
12893
12920
|
pluginSri: () => pluginSri
|
|
12894
12921
|
});
|
|
12895
|
-
var import_node_crypto2, getAssetName, pluginSri;
|
|
12922
|
+
var import_node_crypto2, getAssetName, isSriLinkRel, pluginSri;
|
|
12896
12923
|
var init_sri = __esm({
|
|
12897
12924
|
"src/plugins/sri.ts"() {
|
|
12898
12925
|
"use strict";
|
|
@@ -12906,6 +12933,9 @@ var init_sri = __esm({
|
|
|
12906
12933
|
}
|
|
12907
12934
|
return removeLeadingSlash(url2);
|
|
12908
12935
|
};
|
|
12936
|
+
isSriLinkRel = (rel) => {
|
|
12937
|
+
return typeof rel === "string" && ["stylesheet", "preload", "modulepreload"].includes(rel);
|
|
12938
|
+
};
|
|
12909
12939
|
pluginSri = () => ({
|
|
12910
12940
|
name: "rsbuild:sri",
|
|
12911
12941
|
setup(api) {
|
|
@@ -12936,7 +12966,7 @@ var init_sri = __esm({
|
|
|
12936
12966
|
}
|
|
12937
12967
|
if (tag.tag === "script" && typeof tag.attrs.src === "string") {
|
|
12938
12968
|
url2 = tag.attrs.src;
|
|
12939
|
-
} else if (tag.tag === "link" && tag.attrs.rel
|
|
12969
|
+
} else if (tag.tag === "link" && isSriLinkRel(tag.attrs.rel) && typeof tag.attrs.href === "string") {
|
|
12940
12970
|
url2 = tag.attrs.href;
|
|
12941
12971
|
}
|
|
12942
12972
|
if (!url2) {
|
|
@@ -13610,7 +13640,7 @@ var init_init = __esm({
|
|
|
13610
13640
|
|
|
13611
13641
|
// src/cli/commands.ts
|
|
13612
13642
|
function runCli() {
|
|
13613
|
-
program.name("rsbuild").usage("<command> [options]").version("1.0.
|
|
13643
|
+
program.name("rsbuild").usage("<command> [options]").version("1.0.19");
|
|
13614
13644
|
const devCommand = program.command("dev");
|
|
13615
13645
|
const buildCommand = program.command("build");
|
|
13616
13646
|
const previewCommand = program.command("preview");
|
|
@@ -13719,7 +13749,7 @@ function prepareCli() {
|
|
|
13719
13749
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
13720
13750
|
console.log();
|
|
13721
13751
|
}
|
|
13722
|
-
import_rslog.logger.greet(` ${`Rsbuild v${"1.0.
|
|
13752
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"1.0.19"}`}
|
|
13723
13753
|
`);
|
|
13724
13754
|
}
|
|
13725
13755
|
var import_node_module;
|
|
@@ -13806,7 +13836,7 @@ init_logger();
|
|
|
13806
13836
|
init_mergeConfig();
|
|
13807
13837
|
init_helpers();
|
|
13808
13838
|
init_constants();
|
|
13809
|
-
var version = "1.0.
|
|
13839
|
+
var version = "1.0.19";
|
|
13810
13840
|
// Annotate the CommonJS export names for ESM import in node:
|
|
13811
13841
|
0 && (module.exports = {
|
|
13812
13842
|
PLUGIN_CSS_NAME,
|
package/dist/index.js
CHANGED
|
@@ -46,12 +46,12 @@ var __publicField = (obj, key, value) => {
|
|
|
46
46
|
return value;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.60.
|
|
49
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.60.5_typescript@5.6.3/node_modules/@modern-js/module-tools/shims/esm.js
|
|
50
50
|
import path from "path";
|
|
51
51
|
import { fileURLToPath } from "url";
|
|
52
52
|
var getFilename, getDirname, __dirname, __filename;
|
|
53
53
|
var init_esm = __esm({
|
|
54
|
-
"../../node_modules/.pnpm/@modern-js+module-tools@2.60.
|
|
54
|
+
"../../node_modules/.pnpm/@modern-js+module-tools@2.60.5_typescript@5.6.3/node_modules/@modern-js/module-tools/shims/esm.js"() {
|
|
55
55
|
"use strict";
|
|
56
56
|
getFilename = () => fileURLToPath(import.meta.url);
|
|
57
57
|
getDirname = () => path.dirname(getFilename());
|
|
@@ -6078,7 +6078,7 @@ async function createContext(options, userConfig, bundlerType) {
|
|
|
6078
6078
|
const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
|
|
6079
6079
|
const cachePath = join6(rootPath, "node_modules", ".cache");
|
|
6080
6080
|
return {
|
|
6081
|
-
version: "1.0.
|
|
6081
|
+
version: "1.0.19",
|
|
6082
6082
|
rootPath,
|
|
6083
6083
|
distPath: "",
|
|
6084
6084
|
cachePath,
|
|
@@ -9717,7 +9717,7 @@ async function applyCSSRule({
|
|
|
9717
9717
|
config,
|
|
9718
9718
|
root: context.rootPath
|
|
9719
9719
|
});
|
|
9720
|
-
if (postcssLoaderOptions.postcssOptions?.plugins?.length) {
|
|
9720
|
+
if (typeof postcssLoaderOptions.postcssOptions === "function" || postcssLoaderOptions.postcssOptions?.plugins?.length) {
|
|
9721
9721
|
importLoaders++;
|
|
9722
9722
|
rule.use(CHAIN_ID2.USE.POSTCSS).loader(getCompiledPath("postcss-loader")).options(postcssLoaderOptions);
|
|
9723
9723
|
}
|
|
@@ -9741,6 +9741,7 @@ var init_css = __esm({
|
|
|
9741
9741
|
import_deepmerge2 = __toESM(require_cjs());
|
|
9742
9742
|
init_dist2();
|
|
9743
9743
|
init_constants();
|
|
9744
|
+
init_helpers();
|
|
9744
9745
|
init_path();
|
|
9745
9746
|
init_pluginHelper();
|
|
9746
9747
|
isUseCssExtract = (config, target) => !config.output.injectStyles && target !== "node" && target !== "web-worker";
|
|
@@ -9782,35 +9783,57 @@ var init_css = __esm({
|
|
|
9782
9783
|
const extraPlugins = [];
|
|
9783
9784
|
const utils = {
|
|
9784
9785
|
addPlugins(plugins) {
|
|
9785
|
-
|
|
9786
|
-
extraPlugins.push(...plugins);
|
|
9787
|
-
} else {
|
|
9788
|
-
extraPlugins.push(plugins);
|
|
9789
|
-
}
|
|
9786
|
+
extraPlugins.push(...castArray(plugins));
|
|
9790
9787
|
}
|
|
9791
9788
|
};
|
|
9792
|
-
const
|
|
9793
|
-
|
|
9794
|
-
const
|
|
9789
|
+
const userOptions = await loadUserPostcssrc(root);
|
|
9790
|
+
userOptions.plugins ||= [];
|
|
9791
|
+
const defaultOptions2 = {
|
|
9795
9792
|
implementation: getCompiledPath("postcss"),
|
|
9796
|
-
postcssOptions:
|
|
9793
|
+
postcssOptions: userOptions,
|
|
9797
9794
|
sourceMap: config.output.sourceMap.css
|
|
9798
9795
|
};
|
|
9799
|
-
const
|
|
9800
|
-
initial:
|
|
9796
|
+
const finalOptions = reduceConfigsWithContext({
|
|
9797
|
+
initial: defaultOptions2,
|
|
9801
9798
|
config: config.tools.postcss,
|
|
9802
9799
|
ctx: utils
|
|
9803
9800
|
});
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9801
|
+
finalOptions.postcssOptions ||= {};
|
|
9802
|
+
const updatePostcssOptions = (options) => {
|
|
9803
|
+
options.plugins ||= [];
|
|
9804
|
+
if (extraPlugins.length) {
|
|
9805
|
+
options.plugins.push(...extraPlugins);
|
|
9806
|
+
}
|
|
9807
|
+
options.plugins = options.plugins.map(
|
|
9808
|
+
(plugin) => isPostcssPluginCreator(plugin) ? plugin() : plugin
|
|
9809
|
+
);
|
|
9810
|
+
options.config = false;
|
|
9811
|
+
return options;
|
|
9812
|
+
};
|
|
9813
|
+
const { postcssOptions } = finalOptions;
|
|
9814
|
+
if (typeof postcssOptions === "function") {
|
|
9815
|
+
const postcssOptionsWrapper = (loaderContext) => {
|
|
9816
|
+
const options = postcssOptions(loaderContext);
|
|
9817
|
+
if (typeof options !== "object" || options === null) {
|
|
9818
|
+
throw new Error(
|
|
9819
|
+
`\`postcssOptions\` function must return a PostCSSOptions object, got "${typeof options}".`
|
|
9820
|
+
);
|
|
9821
|
+
}
|
|
9822
|
+
const mergedOptions = {
|
|
9823
|
+
...userOptions,
|
|
9824
|
+
...options,
|
|
9825
|
+
plugins: [...userOptions.plugins || [], ...options.plugins || []]
|
|
9826
|
+
};
|
|
9827
|
+
return updatePostcssOptions(mergedOptions);
|
|
9828
|
+
};
|
|
9829
|
+
postcssOptionsWrapper.config = false;
|
|
9830
|
+
return {
|
|
9831
|
+
...finalOptions,
|
|
9832
|
+
postcssOptions: postcssOptionsWrapper
|
|
9833
|
+
};
|
|
9808
9834
|
}
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
);
|
|
9812
|
-
merged.postcssOptions.config = false;
|
|
9813
|
-
return merged;
|
|
9835
|
+
finalOptions.postcssOptions = updatePostcssOptions(postcssOptions);
|
|
9836
|
+
return finalOptions;
|
|
9814
9837
|
};
|
|
9815
9838
|
getCSSLoaderOptions = ({
|
|
9816
9839
|
config,
|
|
@@ -11468,7 +11491,11 @@ function getDefaultSwcConfig(browserslist, cacheRoot) {
|
|
|
11468
11491
|
decorators: true
|
|
11469
11492
|
},
|
|
11470
11493
|
experimental: {
|
|
11471
|
-
cacheRoot
|
|
11494
|
+
cacheRoot,
|
|
11495
|
+
/**
|
|
11496
|
+
* Preserve `with` in imports and exports.
|
|
11497
|
+
*/
|
|
11498
|
+
keepImportAttributes: true
|
|
11472
11499
|
}
|
|
11473
11500
|
},
|
|
11474
11501
|
isModule: "unknown",
|
|
@@ -13006,7 +13033,7 @@ __export(sri_exports, {
|
|
|
13006
13033
|
pluginSri: () => pluginSri
|
|
13007
13034
|
});
|
|
13008
13035
|
import crypto2 from "crypto";
|
|
13009
|
-
var getAssetName, pluginSri;
|
|
13036
|
+
var getAssetName, isSriLinkRel, pluginSri;
|
|
13010
13037
|
var init_sri = __esm({
|
|
13011
13038
|
"src/plugins/sri.ts"() {
|
|
13012
13039
|
"use strict";
|
|
@@ -13020,6 +13047,9 @@ var init_sri = __esm({
|
|
|
13020
13047
|
}
|
|
13021
13048
|
return removeLeadingSlash(url2);
|
|
13022
13049
|
};
|
|
13050
|
+
isSriLinkRel = (rel) => {
|
|
13051
|
+
return typeof rel === "string" && ["stylesheet", "preload", "modulepreload"].includes(rel);
|
|
13052
|
+
};
|
|
13023
13053
|
pluginSri = () => ({
|
|
13024
13054
|
name: "rsbuild:sri",
|
|
13025
13055
|
setup(api) {
|
|
@@ -13050,7 +13080,7 @@ var init_sri = __esm({
|
|
|
13050
13080
|
}
|
|
13051
13081
|
if (tag.tag === "script" && typeof tag.attrs.src === "string") {
|
|
13052
13082
|
url2 = tag.attrs.src;
|
|
13053
|
-
} else if (tag.tag === "link" && tag.attrs.rel
|
|
13083
|
+
} else if (tag.tag === "link" && isSriLinkRel(tag.attrs.rel) && typeof tag.attrs.href === "string") {
|
|
13054
13084
|
url2 = tag.attrs.href;
|
|
13055
13085
|
}
|
|
13056
13086
|
if (!url2) {
|
|
@@ -13728,7 +13758,7 @@ var init_init = __esm({
|
|
|
13728
13758
|
|
|
13729
13759
|
// src/cli/commands.ts
|
|
13730
13760
|
function runCli() {
|
|
13731
|
-
program.name("rsbuild").usage("<command> [options]").version("1.0.
|
|
13761
|
+
program.name("rsbuild").usage("<command> [options]").version("1.0.19");
|
|
13732
13762
|
const devCommand = program.command("dev");
|
|
13733
13763
|
const buildCommand = program.command("build");
|
|
13734
13764
|
const previewCommand = program.command("preview");
|
|
@@ -13839,7 +13869,7 @@ function prepareCli() {
|
|
|
13839
13869
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
13840
13870
|
console.log();
|
|
13841
13871
|
}
|
|
13842
|
-
logger.greet(` ${`Rsbuild v${"1.0.
|
|
13872
|
+
logger.greet(` ${`Rsbuild v${"1.0.19"}`}
|
|
13843
13873
|
`);
|
|
13844
13874
|
}
|
|
13845
13875
|
var init_prepare = __esm({
|
|
@@ -13911,7 +13941,7 @@ init_mergeConfig();
|
|
|
13911
13941
|
init_helpers();
|
|
13912
13942
|
init_constants();
|
|
13913
13943
|
import { rspack as rspack10 } from "@rspack/core";
|
|
13914
|
-
var version = "1.0.
|
|
13944
|
+
var version = "1.0.19";
|
|
13915
13945
|
export {
|
|
13916
13946
|
PLUGIN_CSS_NAME,
|
|
13917
13947
|
PLUGIN_SWC_NAME,
|
|
@@ -16,20 +16,24 @@ export type PostCSSOptions = ProcessOptions & {
|
|
|
16
16
|
export type PostCSSLoaderOptions = {
|
|
17
17
|
/**
|
|
18
18
|
* Enable PostCSS Parser support in CSS-in-JS. If you use JS styles the postcss-js parser, add the execute option.
|
|
19
|
+
* @default undefined
|
|
19
20
|
*/
|
|
20
21
|
execute?: boolean;
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* Whether to generate source maps.
|
|
24
|
+
* @default `rsbuildConfig.output.sourceMap.css`
|
|
23
25
|
*/
|
|
24
26
|
sourceMap?: boolean;
|
|
25
27
|
/**
|
|
26
28
|
* The special implementation option determines which implementation of PostCSS to use.
|
|
29
|
+
* @default `@rsbuild/core/compiled/postcss`
|
|
27
30
|
*/
|
|
28
31
|
implementation?: unknown;
|
|
29
32
|
/**
|
|
30
33
|
* Allows to set PostCSS options and plugins.
|
|
34
|
+
* @default undefined
|
|
31
35
|
*/
|
|
32
|
-
postcssOptions?: PostCSSOptions;
|
|
36
|
+
postcssOptions?: PostCSSOptions | ((loaderContext: Rspack.LoaderContext) => PostCSSOptions);
|
|
33
37
|
};
|
|
34
38
|
export type { AcceptedPlugin as PostCSSPlugin } from 'postcss';
|
|
35
39
|
export type CSSLoaderModulesMode = 'local' | 'global' | 'pure' | 'icss' | ((resourcePath: string) => 'local' | 'global' | 'pure' | 'icss');
|