Open
Description
Related plugins
Describe the bug
I recently upgraded an app I'm working on:
vite
from5.3.3
to6.0.7
@vitejs/plugin-vue
from5.0.5
to5.2.1
And the following code:
import { type A } from './types'
raised an error during build
(the build-only
phase, not the type-check
one):
❯ npm run build
> vite-vue-typescript-starter@0.0.0 build
> vue-tsc -b && vite build
vite v6.0.9 building for production...
✓ 17 modules transformed.
x Build failed in 1.16s
error during build:
Could not resolve "./types" from "src/App.vue?vue&type=script&setup=true&lang.ts"
file: /home/projects/vitejs-vite-xaslukcp/src/App.vue?vue&type=script&setup=true&lang.ts
at getRollupError (file:///home/projects/vitejs-vite-xaslukcp/node_modules/rollup/dist/es/shared/parseAst.js:558:41)
at error (file:///home/projects/vitejs-vite-xaslukcp/node_modules/rollup/dist/es/shared/parseAst.js:554:42)
at handleInvalidResolvedId (file:///home/projects/vitejs-vite-xaslukcp/node_modules/rollup/dist/es/shared/node-entry.js:20239:37)
at getResolveStaticDependencyPromises/< (file:///home/projects/vitejs-vite-xaslukcp/node_modules/rollup/dist/es/shared/node-entry.js:20199:26)
Reproduction
https://stackblitz.com/edit/vitejs-vite-xaslukcp
Steps to reproduce
- Open reproduction
- Run
npm run build
in terminal
You can then change the import
on line 3 of src/App.vue
:
- import { type ID } from './types';
+ import type { ID } from './types';
and run npm run build
again to make it work.
According to https://www.typescriptlang.org/docs/handbook/2/modules.html#import-type, both syntaxes are valid.
Also I don't know if it helps but the following Vanilla Vite project doesn't have the issue so I guess that's a problem with the Vue plugin.
System Info
System:
OS: Linux 5.15 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600KF
Memory: 14.53 GB / 15.53 GB
Container: Yes
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.6.0 - ~/.nvm/versions/node/v23.6.0/bin/node
npm: 10.9.2 - ~/.nvm/versions/node/v23.6.0/bin/npm
bun: 1.1.45 - ~/.bun/bin/bun
Used Package Manager
npm (in reproduction), bun (locally)
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.