File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -1891,6 +1891,16 @@ export async function composeCreateRsbuildConfig(
18911891 userConfig . output ??= { } ;
18921892 delete userConfig . output . externals ;
18931893
1894+ // Convert output.distPath to an object to ensure it merges correctly with the built-in constant config
1895+ if (
1896+ userConfig . output . distPath &&
1897+ typeof userConfig . output . distPath === 'string'
1898+ ) {
1899+ userConfig . output . distPath = {
1900+ root : userConfig . output . distPath ,
1901+ } ;
1902+ }
1903+
18941904 const config : RsbuildConfigWithLibInfo = {
18951905 format : libConfig . format ?? 'esm' ,
18961906 // The merge order represents the priority of the configuration
Original file line number Diff line number Diff line change @@ -219,6 +219,51 @@ describe('Should compose create Rsbuild config correctly', () => {
219219 expect ( rsbuildConfig ) . toMatchSnapshot ( 'inspected Rsbuild configs' ) ;
220220 expect ( bundlerConfigs ) . toMatchSnapshot ( 'inspected Rspack configs' ) ;
221221 } ) ;
222+
223+ test ( 'Merge output.distPath correctly' , async ( ) => {
224+ const rslibConfig : RslibConfig = {
225+ lib : [
226+ {
227+ format : 'esm' ,
228+ output : {
229+ distPath : 'dist/esm' ,
230+ } ,
231+ } ,
232+ {
233+ format : 'cjs' ,
234+ output : {
235+ distPath : {
236+ root : 'dist/cjs' ,
237+ } ,
238+ } ,
239+ } ,
240+ ] ,
241+ } ;
242+
243+ const composedRsbuildConfig = await composeCreateRsbuildConfig ( rslibConfig ) ;
244+ expect (
245+ composedRsbuildConfig [ 0 ] ?. config . output ?. distPath ,
246+ ) . toMatchInlineSnapshot ( `
247+ {
248+ "css": "./",
249+ "cssAsync": "./",
250+ "js": "./",
251+ "jsAsync": "./",
252+ "root": "dist/esm",
253+ }
254+ ` ) ;
255+ expect (
256+ composedRsbuildConfig [ 1 ] ?. config . output ?. distPath ,
257+ ) . toMatchInlineSnapshot ( `
258+ {
259+ "css": "./",
260+ "cssAsync": "./",
261+ "js": "./",
262+ "jsAsync": "./",
263+ "root": "dist/cjs",
264+ }
265+ ` ) ;
266+ } ) ;
222267} ) ;
223268
224269describe ( 'syntax' , ( ) => {
You can’t perform that action at this time.
0 commit comments