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

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

Closed
7 tasks done
hi-ogawa opened this issue Feb 1, 2025 · 0 comments · Fixed by #19331
Labels
feat: ssr p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@hi-ogawa
Copy link
Collaborator

hi-ogawa commented Feb 1, 2025

Describe the bug

The issue is initially reported on vitest vitest-dev/vitest#7394. It looks like ssr transform panics for the following input:

import * as x from 'x'; 
export * as x from 'x';
Error: Cannot split a chunk that has already been edited (5:12 – "export * as x from 'x';")
    at MagicString._splitChunk (file:///home/projects/github-pnyojxdr/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:4876:10)
    at MagicString._split (file:///home/projects/github-pnyojxdr/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:4866:43)
    at MagicString.update (file:///home/projects/github-pnyojxdr/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:4608:8)
    at onIdentifier (file:///home/projects/github-pnyojxdr/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:31422:11)
    at eval (file:///home/projects/github-pnyojxdr/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:31587:39)
    at walk (file:///home/projects/github-pnyojxdr/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:31586:15)
    at ssrTransformScript (file:///home/projects/github-pnyojxdr/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:31388:3)
    at async loadAndTransform (file:///home/projects/github-pnyojxdr/node_modules/vite/dist/node/chunks/dep-M1IYMR16.js:41310:65)

Reproduction

https://stackblitz.com/edit/github-pnyojxdr?file=fs.js

Steps to reproduce

Open stackblitz and run node repro-vite.js

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vite: ^6 => 6.0.11

Used Package Manager

npm

Logs

No response

Validations

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: ssr p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant