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

Dynamic raw import fails in production build #8787

Closed
7 tasks done
orange-buffalo opened this issue Jun 26, 2022 · 2 comments
Closed
7 tasks done

Dynamic raw import fails in production build #8787

orange-buffalo opened this issue Jun 26, 2022 · 2 comments

Comments

@orange-buffalo
Copy link

Describe the bug

When using a dynamic raw import (e.g. import(``./resource-${key}.json?raw``)), it is resolved properly in the dev mode, but fails when built for production:

Unknown variable dynamic import: ./resource-a.json?raw

Similar resolved issues: #4252, #3222.

Reproducer

In dev mode (npm run dev), the import is loaded successfully (main.ts).

In production mode (npm run build), the import fails:

index.50b9332a.js:1 Uncaught (in promise) Error: Unknown variable dynamic import: ./resource-a.json?raw
    at index.50b9332a.js:1:858
    at new Promise (<anonymous>)
    at l (index.50b9332a.js:1:758)
    at index.50b9332a.js:1:957

Reproduction

https://github.com/orange-buffalo/reproducer-vite-dynamic-raw-import

System Info

System:
    OS: Linux 5.13 KDE neon 5.24
    CPU: (8) x64 Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
    Memory: 2.61 GB / 15.55 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.15.0 - /usr/bin/node
    Yarn: 1.22.4 - /usr/bin/yarn
    npm: 8.5.5 - /usr/bin/npm
  Browsers:
    Brave Browser: 100.1.37.109
    Firefox: 98.0.2
  npmPackages:
    vite: ^2.9.9 => 2.9.12

Used Package Manager

npm

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented Jun 26, 2022

I believe this is supported in Vite 3 with #7756

@bluwy bluwy closed this as completed Jun 26, 2022
@orange-buffalo
Copy link
Author

Thanks for the quick update, @bluwy. I confirm - upgrading to 3.0.0-beta.2 fixed the problem (but broke storybook in the project, so not yet ready for us, unfortunately).

@github-actions github-actions bot locked and limited conversation to collaborators Jul 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants