You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
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.
I think there is no mistake here. ts can be inlined in the development environment might be because:
The development server directly processes .ts files through Vite's built-in TypeScript transformation feature.
The production environment requires complete TypeScript compilation, type checking, ensuring code optimization and compatibility, and might involve other build tools (e.g., tsc).
Related plugins
plugin-vue
plugin-vue-jsx
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 buildI'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
Used Package Manager
pnpm
Logs
No response
Validations
Tasks
The text was updated successfully, but these errors were encountered: