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

String exports aren't resolved on wildcard imports #5851

Closed
6 tasks done
LorisSigrist opened this issue Jun 6, 2024 · 2 comments
Closed
6 tasks done

String exports aren't resolved on wildcard imports #5851

LorisSigrist opened this issue Jun 6, 2024 · 2 comments
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) upstream

Comments

@LorisSigrist
Copy link

LorisSigrist commented Jun 6, 2024

Describe the bug

JS allows you to export/import as arbitrary strings. However, in vitest, wildcard imports do not import these string-exports.

// file-1.js
const something = "Something"
export { something as "arbitrary string" };

// file-2.js
import * as T from "./file-1.js"
console.log(T["arbitrary string"]) // expected: log "Something"

If this is executed via node it works as expected. If that same code is executed via vitest undefined is logged instead.

vite bundles this code correctly

Reproduction

https://github.com/LorisSigrist/vitest-string-exports-wildcard-reproduction (basically the code example above)

System Info

System:
    OS: macOS 14.4.1
    CPU: (14) arm64 Apple M3 Max
    Memory: 2.54 GB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.2.0 - /opt/homebrew/bin/node
    npm: 10.7.0 - /opt/homebrew/bin/npm
    pnpm: 9.1.4 - /opt/homebrew/bin/pnpm
    bun: 1.1.8 - /opt/homebrew/bin/bun
  Browsers:
    Safari: 17.4.1
  npmPackages:
    vitest: ^1.6.0 => 1.6.0

Used Package Manager

pnpm

Validations

@LorisSigrist LorisSigrist changed the title String exports/imports aren't resolved on wildcard imports String exports aren't resolved on wildcard imports Jun 6, 2024
@hi-ogawa
Copy link
Contributor

hi-ogawa commented Jun 9, 2024

Thanks for the reproduction! This looks like an issue in Vite SSR, so I reported to there by adjusting your code

@hi-ogawa hi-ogawa added upstream p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Jun 9, 2024
@sheremet-va
Copy link
Member

The fix was merged in vitejs/vite#17446 as part of 5.3.0, so if you update your Vite version manually or revalidate the lockfile, it should work.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) upstream
Projects
None yet
Development

No branches or pull requests

3 participants