Skip to content

can not use export * as variable from "./somefile" and import * as variable from "./somefile" in same file with vite v6 #7394

@trim21

Description

@trim21

Describe the bug

Since I upgrade vitest to v3 and vite to v6 it can't load a file with these content:

import * as schema from './schema.ts';
export * as schema from './schema.ts';

console.log(schema)

If I downgrade vite to <6.0.0 and it will work again

❯❯ ~/proj/vitest-vite6-bug-reproduce (master) pnpm run test

> app@0.12.3 test C:\Users\Trim21\proj\vitest-vite6-bug-reproduce
> vitest --run


 RUN  v3.0.4 C:/Users/Trim21/proj/vitest-vite6-bug-reproduce

 ❯ tests/auth.test.ts (0 test)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  tests/auth.test.ts [ tests/auth.test.ts ]
Error: Cannot split a chunk that has already been edited (23:12 – "export * as schema from "/drizzle/schema.ts";")
 ❯ MagicString._splitChunk node_modules/.pnpm/vite@6.0.11_@types+node@22.12.0_jiti@2.4.2_tsx@4.19.2/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:4815:10
 ❯ MagicString._split node_modules/.pnpm/vite@6.0.11_@types+node@22.12.0_jiti@2.4.2_tsx@4.19.2/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:4805:43
 ❯ MagicString.update node_modules/.pnpm/vite@6.0.11_@types+node@22.12.0_jiti@2.4.2_tsx@4.19.2/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:4547:8
 ❯ onIdentifier node_modules/.pnpm/vite@6.0.11_@types+node@22.12.0_jiti@2.4.2_tsx@4.19.2/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:31361:11
 ❯ node_modules/.pnpm/vite@6.0.11_@types+node@22.12.0_jiti@2.4.2_tsx@4.19.2/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:31526:39
 ❯ walk node_modules/.pnpm/vite@6.0.11_@types+node@22.12.0_jiti@2.4.2_tsx@4.19.2/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:31525:15
 ❯ ssrTransformScript node_modules/.pnpm/vite@6.0.11_@types+node@22.12.0_jiti@2.4.2_tsx@4.19.2/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:31327:3
 ❯ loadAndTransform node_modules/.pnpm/vite@6.0.11_@types+node@22.12.0_jiti@2.4.2_tsx@4.19.2/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:41249:65

this work with vitest@3 and vite@6, but I don't think the code above is invalid javascript file?:

import * as schema from './schema.ts';
export { schema };

console.log(schema)

Reproduction

https://github.com/trim21/vitest-vite6-bug-reproduce

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
    Memory: 4.27 GB / 15.87 GB
  Binaries:
    Node: 22.13.1 - ~\scoop\apps\nodejs-lts\current\node.EXE
    Yarn: 1.22.19 - ~\scoop\apps\nodejs-lts\current\bin\yarn.CMD
    npm: 11.0.0 - ~\scoop\apps\nodejs-lts\current\bin\npm.CMD
    pnpm: 9.15.4 - ~\scoop\apps\nodejs-lts\current\pnpm.CMD
  Browsers:
    Edge: Chromium (129.0.2792.89)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @vitest/coverage-v8: ^3.0.4 => 3.0.4
    vite: ^6.0.0 => 6.0.11
    vitest: ^3.0.4 => 3.0.4

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)upstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions