@@ -6,7 +6,7 @@ import type { InlineConfig, PluginOption } from '..'
66import type { UserConfig , UserConfigExport } from '../config'
77import { defineConfig , loadConfigFromFile , resolveConfig } from '../config'
88import { resolveEnvPrefix } from '../env'
9- import { mergeConfig } from '../utils'
9+ import { hasBothRollupOptionsAndRolldownOptions , mergeConfig } from '../utils'
1010import { createLogger } from '../logger'
1111
1212describe ( 'mergeConfig' , ( ) => {
@@ -560,6 +560,46 @@ describe('mergeConfig', () => {
560560 expect ( downOutput . hashCharacters ) . toBe ( 'base36' )
561561 } )
562562
563+ test ( 'hasBothRollupOptionsAndRolldownOptions returns false when only rollupOptions is set' , ( ) => {
564+ // When mergeConfig is called with only rollupOptions in the override,
565+ // setupRollupOptionCompat creates a proxy where rollupOptions === rolldownOptions.
566+ // hasBothRollupOptionsAndRolldownOptions should return false in this case
567+ // to avoid false positive warnings.
568+ const baseConfig = defineConfig ( {
569+ build : { } , // Need existing build object for recursive merge to happen
570+ } )
571+ const newConfig = defineConfig ( {
572+ build : {
573+ rollupOptions : {
574+ treeshake : false ,
575+ } ,
576+ } ,
577+ } )
578+ const mergedConfig : UserConfig = mergeConfig ( baseConfig , newConfig )
579+
580+ expect ( mergedConfig . build ! . rollupOptions ) . toBeDefined ( )
581+ expect ( mergedConfig . build ! . rolldownOptions ) . toBeDefined ( )
582+ expect ( mergedConfig . build ! . rollupOptions ) . toBe (
583+ mergedConfig . build ! . rolldownOptions ,
584+ )
585+
586+ expect ( hasBothRollupOptionsAndRolldownOptions ( mergedConfig ) ) . toBe ( false )
587+ } )
588+
589+ test ( 'hasBothRollupOptionsAndRolldownOptions returns true when both are explicitly set to different values' , ( ) => {
590+ const config = defineConfig ( {
591+ build : {
592+ rollupOptions : {
593+ treeshake : false ,
594+ } ,
595+ rolldownOptions : {
596+ platform : 'neutral' ,
597+ } ,
598+ } ,
599+ } )
600+ expect ( hasBothRollupOptionsAndRolldownOptions ( config ) ) . toBe ( true )
601+ } )
602+
563603 test ( 'rollupOptions/rolldownOptions.platform' , async ( ) => {
564604 const testRollupOptions = await resolveConfig (
565605 {
0 commit comments