Skip to content

Conversation

@shulaoda
Copy link
Member

@shulaoda shulaoda commented Nov 4, 2025

Description

If you want to enable these new native plugins, you need to set enableNativePlugin: true, the default value is 'v1'. The v2 native plugins include assetPlugin, assetImportMetaUrlPlugin, cssPlugin, htmlPlugin, and htmlInlineProxyPlugin.

In addition, the v2 update also improves nativeBuildImportAnalysisPlugin and nativeManifestPlugin. These changes fix the execution order mismatch between transform and transform_ast hooks, which previously prevented user plugins from running after built-in plugins even with post enforcement, making it impossible to access the fully processed code (#373).

Note

There may be a slight performance overhead since v2 plugins parse modules individually instead of reusing the AST from transform_ast. However, the impact should be minimal due to filtering logic that skips unnecessary parsing.

@shulaoda shulaoda marked this pull request as draft November 4, 2025 15:57
@shulaoda shulaoda force-pushed the 10-20-stable-v2-native-plugins branch 2 times, most recently from ecc5731 to 165a101 Compare November 5, 2025 10:03
@shulaoda shulaoda force-pushed the 10-20-stable-v2-native-plugins branch 12 times, most recently from 097a16d to 747c24e Compare November 17, 2025 01:01
@shulaoda shulaoda force-pushed the 10-20-stable-v2-native-plugins branch 7 times, most recently from ce51c11 to 9ee6920 Compare November 26, 2025 09:41
@shulaoda shulaoda force-pushed the 10-20-stable-v2-native-plugins branch 6 times, most recently from dba3281 to d6b9c56 Compare December 3, 2025 01:14
@shulaoda shulaoda force-pushed the 10-20-stable-v2-native-plugins branch from d6b9c56 to 6eddf7b Compare December 3, 2025 01:21
@shulaoda shulaoda force-pushed the 10-20-stable-v2-native-plugins branch from 6eddf7b to 689f9ba Compare December 3, 2025 01:23
renderBuiltUrl: undefined,
hmrPartialAccept: false,
enableNativePlugin: process.env._VITE_TEST_JS_PLUGIN ? false : 'v1',
enableNativePlugin: process.env._VITE_TEST_JS_PLUGIN ? false : true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be reverted before merging.

@shulaoda shulaoda force-pushed the 10-20-stable-v2-native-plugins branch from 689f9ba to 122013a Compare December 3, 2025 01:42
@shulaoda shulaoda marked this pull request as ready for review December 3, 2025 01:52
@shulaoda shulaoda requested a review from sapphi-red December 3, 2025 01:52
case 'v1':
case true:
return 1
case true:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case true:
case 'v2':
case true:

We should also update the jsdoc of enableNativePlugin option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm considering adding a v2 option since the v2 implementation is still experimental and not fully stabilized. My current idea is to treat enableNativePlugin: true as enabling v2, while the default behavior continues to use v1. 🤔

@shulaoda shulaoda force-pushed the 10-20-stable-v2-native-plugins branch 2 times, most recently from f627dd0 to 4c5f53a Compare December 3, 2025 07:26
@shulaoda shulaoda requested a review from sapphi-red December 3, 2025 07:26
@shulaoda shulaoda force-pushed the 10-20-stable-v2-native-plugins branch 3 times, most recently from 51dfefc to 0b387c5 Compare December 3, 2025 07:32
@shulaoda shulaoda marked this pull request as draft December 3, 2025 07:39
@vitejs vitejs deleted a comment from sapphi-red Dec 9, 2025
@shulaoda shulaoda force-pushed the 10-20-stable-v2-native-plugins branch from 0b387c5 to 97a4abe Compare December 10, 2025 09:33
@shulaoda
Copy link
Member Author

@sapphi-red Could you help me trigger the ecosystem CI? It seems I don’t have permission to do it.

@sapphi-red
Copy link
Member

Triggered here: https://github.com/vitejs/vite-ecosystem-ci/actions/runs/20097924150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants