@@ -390,8 +390,6 @@ export function resolveBuildEnvironmentOptions(
390390 raw : BuildEnvironmentOptions ,
391391 logger : Logger ,
392392 consumer : 'client' | 'server' | undefined ,
393- // Backward compatibility
394- isSsrTargetWebworkerEnvironment ?: boolean ,
395393) : ResolvedBuildEnvironmentOptions {
396394 const deprecatedPolyfillModulePreload = raw ?. polyfillModulePreload
397395 const { polyfillModulePreload, ...rest } = raw
@@ -453,19 +451,6 @@ export function resolveBuildEnvironmentOptions(
453451 } ,
454452 }
455453
456- if ( isSsrTargetWebworkerEnvironment ) {
457- resolved . rollupOptions ??= { }
458- resolved . rollupOptions . output ??= { }
459- const output = resolved . rollupOptions . output
460- for ( const out of arraify ( output ) ) {
461- out . entryFileNames ??= `[name].js`
462- out . chunkFileNames ??= `[name]-[hash].js`
463- const input = resolved . rollupOptions . input
464- out . inlineDynamicImports ??=
465- ! input || typeof input === 'string' || Object . keys ( input ) . length === 1
466- }
467- }
468-
469454 return resolved
470455}
471456
@@ -677,6 +662,10 @@ async function buildEnvironment(
677662 logger . error ( e . message , { error : e } )
678663 }
679664
665+ const isSsrTargetWebworkerEnvironment =
666+ environment . name === 'ssr' &&
667+ environment . getTopLevelConfig ( ) . ssr ?. target === 'webworker'
668+
680669 let bundle : RollupBuild | undefined
681670 let startTime : number | undefined
682671 try {
@@ -706,7 +695,7 @@ async function buildEnvironment(
706695
707696 const format = output . format || 'es'
708697 const jsExt =
709- environment . config . consumer === 'server' || libOptions
698+ ( ssr && ! isSsrTargetWebworkerEnvironment ) || libOptions
710699 ? resolveOutputJsExtension (
711700 format ,
712701 findNearestPackageData ( root , packageCache ) ?. data . type ,
@@ -744,7 +733,10 @@ async function buildEnvironment(
744733 ? `[name].[ext]`
745734 : path . posix . join ( options . assetsDir , `[name]-[hash].[ext]` ) ,
746735 inlineDynamicImports :
747- output . format === 'umd' || output . format === 'iife' ,
736+ output . format === 'umd' ||
737+ output . format === 'iife' ||
738+ ( isSsrTargetWebworkerEnvironment &&
739+ ( typeof input === 'string' || Object . keys ( input ) . length === 1 ) ) ,
748740 ...output ,
749741 }
750742 }
0 commit comments