Skip to content

fix: handle rolldown and rollup in resolveRolldownOptions#22034

Closed
florian-lefebvre wants to merge 1 commit into
vitejs:mainfrom
florian-lefebvre:fix/issue-22033
Closed

fix: handle rolldown and rollup in resolveRolldownOptions#22034
florian-lefebvre wants to merge 1 commit into
vitejs:mainfrom
florian-lefebvre:fix/issue-22033

Conversation

@florian-lefebvre

@florian-lefebvre florian-lefebvre commented Mar 26, 2026

Copy link
Copy Markdown

@sapphi-red

Copy link
Copy Markdown
Member

Vite sets rolldownOptions and rollupOptions to the same object, so this shouldn't be needed.

export function setupRollupOptionCompat<
T extends Pick<BuildEnvironmentOptions, 'rollupOptions' | 'rolldownOptions'>,
>(
buildConfig: T,
path: string,
): asserts buildConfig is T & {
rolldownOptions: Exclude<T['rolldownOptions'], undefined>
} {
// if both rollupOptions and rolldownOptions are present,
// ignore rollupOptions and use rolldownOptions
buildConfig.rolldownOptions ??= buildConfig.rollupOptions
if (
runtimeDeprecatedPath.has(path) &&
buildConfig.rollupOptions &&
buildConfig.rolldownOptions !== buildConfig.rollupOptions
) {
rollupOptionsDeprecationCall()
}
// proxy rolldownOptions to rollupOptions
Object.defineProperty(buildConfig, 'rollupOptions', {
get() {
return buildConfig.rolldownOptions
},
set(newValue) {
if (runtimeDeprecatedPath.has(path)) {
rollupOptionsDeprecationCall()
}
buildConfig.rolldownOptions = newValue
},
configurable: true,
enumerable: true,
})
}

I guess there's a code that breaks that somewhere.

@florian-lefebvre

Copy link
Copy Markdown
Author

I just tested quickly and this is because in my reproduction, the whole rolldownOptions object is reassigned. If instead only properties are, it works:

		// doesn't work
      builder.environments.client.config.build.rolldownOptions = {
       input: 'src/client.js',
       output: {
         entryFileNames: '__test__',
       },
      };

		// works
      builder.environments.client.config.build.rolldownOptions.input =
        "src/client.js";
      builder.environments.client.config.build.rolldownOptions.output = {
        entryFileNames: "__test__",
      };

@sapphi-red

Copy link
Copy Markdown
Member

Since the compat code adds rolldownOptions as a getter, it should work even if the whole rolldownOptions object is reassigned.

@florian-lefebvre

Copy link
Copy Markdown
Author

I unfortunately cannot work on this anymore so I'm going to close it, thanks for the help! At least that's context for anyone working on the linked issue in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client environment looks for index.html when mutating rolldownOptions.input

2 participants