-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Production Build Failed for Dynamic Import of ?raw
Files
#3222
Comments
?raw
Files?raw
Files
I think there are two important factors here. First, we should be able to trust that if our app works in dev, it should work in production build as well. This bug is kind of an edge case, but also breaks this promise. Second, this feature of using dynamic imports with markdown is an amazing tool when building an app based off folder based content a la NextJs or Astro but using Vite instead. |
You can submit a PR if you know the fix/enhancement for this issue/feature! |
Fixed via #5545 |
Describe the bug
I want to dynamically import content from a Markdown file, and use them as string. I won't also know if the file exists or not.
Thus, with @patak-js's help, I first created glob import of all the files in that folder and then customized the module created by glob import, by appending
?raw
to the import.During the development, this workaround works; however whenever those dynamically imports are triggered, I got a warning that Vite cannot analyze the dynamic import.
So, I wondered if it is because the custom append on line does not satisfy the dynamic import format requirement.
I fixed the customization above to below and the warning disappeared!
However, in both of the above cases, I got the build error below.
I tried it out with both Vite
v2.0.5
andv2.2.3
, and the same behavior for both versions.How can I resolve this issue and let me know if you need any more information from me to reproduce the issue.
Reproduction
https://github.com/Penguinlay/reproduction-viteDynamicImportBug
System Info
Output of
npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
:Used package manager: yarn
v1.22.10
Logs
yarn cache clean; rm -rf node_modules; rm yarn.lock; yarn; yarn vite --debug
yarn cache clean; rm -rf node_modules; rm yarn.lock; yarn; yarn build --debug
Before submitting the issue, please make sure you do the following
The text was updated successfully, but these errors were encountered: