Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import { type A } from './types' triggers error during build #514

Open
8 of 9 tasks
Deckluhm opened this issue Jan 20, 2025 · 0 comments
Open
8 of 9 tasks

import { type A } from './types' triggers error during build #514

Deckluhm opened this issue Jan 20, 2025 · 0 comments

Comments

@Deckluhm
Copy link

Deckluhm commented Jan 20, 2025

Related plugins

Describe the bug

I recently upgraded an app I'm working on:

  • vite from 5.3.3 to 6.0.7
  • @vitejs/plugin-vue from 5.0.5 to 5.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

> [email protected] 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

  1. Open reproduction
  2. 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

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

No branches or pull requests

1 participant