From dfd18c59511b0deee2335b292b93925df07bdf3f Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 11 Nov 2024 19:12:40 +0900 Subject: [PATCH] fix: use createBuiltinPluginWithEnvironmentSupport for transformPlugin --- packages/vite/src/node/plugins/index.ts | 18 ++++++++++++------ .../src/node/server/environments/rolldown.ts | 3 +-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/vite/src/node/plugins/index.ts b/packages/vite/src/node/plugins/index.ts index 2e741c6f764484..0975d52cfe07df 100644 --- a/packages/vite/src/node/plugins/index.ts +++ b/packages/vite/src/node/plugins/index.ts @@ -125,12 +125,18 @@ export async function resolvePlugins( htmlInlineProxyPlugin(config), cssPlugin(config), config.oxc !== false - ? enableNativePlugin - ? nativeTransformPlugin({ - // TODO: how to jsx dev? - reactRefresh: rolldownDev?.reactRefresh, - }) - : oxcPlugin(config) + ? rolldownDev + ? createBuiltinPluginWithEnvironmentSupport( + 'native:transform', + (environment) => + nativeTransformPlugin({ + reactRefresh: + environment.name === 'client' && rolldownDev?.reactRefresh, + }), + ) + : enableNativePlugin + ? nativeTransformPlugin() + : oxcPlugin(config) : null, enableNativePlugin ? nativeJsonPlugin({ diff --git a/packages/vite/src/node/server/environments/rolldown.ts b/packages/vite/src/node/server/environments/rolldown.ts index cb25fcc40d5e35..1846fdc5e5a90b 100644 --- a/packages/vite/src/node/server/environments/rolldown.ts +++ b/packages/vite/src/node/server/environments/rolldown.ts @@ -221,8 +221,7 @@ class RolldownEnvironment extends DevEnvironment { // all plugins are shared like Vite 6 `sharedConfigBuild`. let plugins = this._plugins! - // enable some core plugins - // TODO: adopt more (should we filter inside `resolvePlugins`?) + // TODO: enable more core plugins plugins = plugins.filter( (p) => !(typeof p.name === 'number' || p.name?.startsWith('vite:')) ||