Skip to content

Commit d86c3bd

Browse files
authored
feat(native-plugin): use js modulepreload polyfill plugin in dev environment (#237)
1 parent e2e1f11 commit d86c3bd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/vite/src/node/plugins/modulePreloadPolyfill.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ export const modulePreloadPolyfillId = 'vite/modulepreload-polyfill'
88
const resolvedModulePreloadPolyfillId = '\0' + modulePreloadPolyfillId + '.js'
99

1010
export function modulePreloadPolyfillPlugin(config: ResolvedConfig): Plugin {
11-
if (config.experimental.enableNativePlugin === true) {
11+
if (
12+
config.experimental.enableNativePlugin === true &&
13+
config.command === 'build'
14+
) {
1215
return perEnvironmentPlugin(
1316
'native:modulepreload-polyfill',
1417
(environment) => {
15-
if (
16-
config.command !== 'build' ||
17-
environment.config.consumer !== 'client'
18-
)
19-
return false
20-
return nativeModulePreloadPolyfillPlugin()
18+
return nativeModulePreloadPolyfillPlugin({
19+
isServer: environment.config.consumer !== 'client',
20+
})
2121
},
2222
)
2323
}

0 commit comments

Comments
 (0)