Description
Related plugins
Describe the bug
When building a component library using Vite and plugin-vue, I've noticed that when script block is set lang="ts"
, a Vue SFC would be compiled into two files:
The second file with Options API contains all options and would be used in the first file, As shown in Text3.
The second file with Composition API contains only a simple import and output statements, and is not USED.
After reviewing source code of this plugin, I've noticed that on packages/plugin-vue/src/script.ts
Line 112, canInlineMain function returns false when script language is ts in production mode. Is it a mistake? The comment said that If the script is js/ts and has no external src, it can be directly placed in the main module. Skip for build
I've made a reproduction repo,please feel free to use it. Thank you!
Reproduction
https://github.com/zhuha0yu/temp-vite-plugin-vue-issue
Steps to reproduce
just run pnpm run build
and watch for build results.
System Info
System:
OS: Windows 10 10.0.19045
CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12600KF
Memory: 33.27 GB / 63.81 GB
npmPackages:
@vitejs/plugin-vue: ^5.2.1 => 5.2.1
vite: ^6.0.5 => 6.0.7
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.