Skip to content

[bug]: can not work with vite8 #618

@lisonge

Description

@lisonge

Describe the bug

    "unplugin-auto-import": "21.0.0",
    "vite": "8.0.0",
// vite.config.ts
import { defineConfig } from 'vite';
import autoImport from 'unplugin-auto-import/vite';

export default defineConfig({
  plugins: [
    autoImport({
      imports: [
        {
          vue: ['h', 'Teleport', 'ref'],
        },
      ],
    }),
  ],
});
// main.ts
export const x = () => {
  const h = 1;
  const Teleport = 1;
};
document.body.innerText = JSON.stringify({
  h: typeof h,
  Teleport: typeof Teleport,
  ref: typeof ref,
});

output

{
    "h": "undefined",
    "Teleport": "undefined",
    "ref": "function"
}

Reproduction

https://stackblitz.com/edit/vitejs-vite-ck7bskoq

System Info

System:
    OS: Windows 11 10.0.26200
    CPU: (32) x64 Intel(R) Core(TM) i9-14900HX
    Memory: 10.67 GB / 31.71 GB
  Binaries:
    Node: 24.8.0 - C:\Users\lisonge\scoop\apps\volta\current\appdata\tools\image\node\24.8.0\node.EXE
    npm: 11.6.0 - C:\Users\lisonge\scoop\apps\volta\current\appdata\tools\image\node\24.8.0\npm.CMD
    pnpm: 10.23.0 - C:\Users\lisonge\scoop\apps\volta\current\appdata\tools\image\pnpm\10.23.0\bin\pnpm.CMD
    Deno: 2.6.6 - C:\Users\lisonge\scoop\shims\deno.EXE
  Browsers:
    Edge: Chromium (143.0.3650.75)
    Internet Explorer: 11.0.26100.7309

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions