Skip to content

Commit f222910

Browse files
authored
feat(native-plugin): support native webWorkerPostPlugin (#183)
1 parent 707778e commit f222910

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/vite/src/node/build.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
loadFallbackPlugin as nativeLoadFallbackPlugin,
2828
manifestPlugin as nativeManifestPlugin,
2929
reporterPlugin as nativeReporterPlugin,
30+
webWorkerPostPlugin as nativeWebWorkerPostPlugin,
3031
} from 'rolldown/experimental'
3132
import type { RollupCommonJSOptions } from 'dep-types/commonjs'
3233
import type { RollupDynamicImportVarsOptions } from 'dep-types/dynamicImportVars'
@@ -494,7 +495,20 @@ export async function resolveBuildPlugins(config: ResolvedConfig): Promise<{
494495
)
495496
).filter(Boolean) as Plugin[],
496497
),
497-
...(config.isWorker ? [webWorkerPostPlugin()] : []),
498+
...(config.isWorker
499+
? [
500+
enableNativePlugin === true
501+
? perEnvironmentPlugin(
502+
'native:web-worker-post-plugin',
503+
(environment) => {
504+
if (environment.config.worker.format === 'iife') {
505+
return nativeWebWorkerPostPlugin()
506+
}
507+
},
508+
)
509+
: webWorkerPostPlugin(),
510+
]
511+
: []),
498512
],
499513
post: [
500514
buildImportAnalysisPlugin(config),

0 commit comments

Comments
 (0)