diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 32623e152013af..63ff50e34c85ba 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -788,19 +788,6 @@ export function resolveRolldownOptions( (typeof input === 'string' || Object.keys(input).length === 1)) ? false : undefined), - comments: - typeof output.comments === 'boolean' - ? output.comments - : { - // Do not minify whitespace for ES lib output since that would remove - // pure annotations and break tree-shaking - annotation: - !options.minify || - (libOptions && (format === 'es' || format === 'esm')), - jsdoc: !options.minify, - legal: !options.minify, - ...output.comments, - }, minify: options.minify === 'oxc' ? libOptions && (format === 'es' || format === 'esm') @@ -817,6 +804,19 @@ export function resolveRolldownOptions( : false, topLevelVar: true, ...output, + comments: + typeof output.comments === 'boolean' + ? output.comments + : { + // Do not minify whitespace for ES lib output since that would remove + // pure annotations and break tree-shaking + annotation: + !options.minify || + (libOptions && (format === 'es' || format === 'esm')), + jsdoc: !options.minify, + legal: !options.minify, + ...output.comments, + }, } }