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
Issue with vitePluginAnalyzer #7116
Comments
@lilnasy possible this is related to the changes made for inlining stylesheets? |
I doubt it, but I'll look into it. |
@lukeshiru You've linked the production website, but I'll need the source code of a minimal project to investigate. |
@lilnasy Sorry, but It's a private project. I added you as a collaborator so you can check it out. There's a |
@lukeshiru looking into it now |
@lukeshiru Can't reproduce; tested on node 16, 18, and 19. Note the commit hash. |
@lilnasy I'm on node |
|
Thanks for digging into it so quickly and explaining it so clearly, @lilnasy! I'll keep the |
This patch won't go live. The root cause is Vite inserting import statements for modules that are completely unrelated: the referenced and the referee scripts are authored in two separate astro components, neither of which import anything. Maybe it's trying to ensure sequence: one should be executed before the other. |
Oh yeah, sorry if I expressed myself incorrectly. I meant I'll keep that until it's fixed anywhere it needs to be fixed. Thanks again for the explanation! I'II close! ✨ |
What version of
astro
are you using?2.4.5
Are you using an SSR adapter? If so, which one?
Vercel
What package manager are you using?
pnpm
What operating system are you using?
MacOS
What browser are you using?
Chrome
Describe the Bug
I found a bizarre bug with Astro's build: Sometimes, some hoisted JS files are imported but don't exist. What I mean by this is the produced hoisted js has something like:
But that
hoisted.somehash.js
file doesn't exist at all. After digging for hours, I discovered thatvitePluginAnalyzer
from Astro is telling Vite to generate those hoisted references but is not considering Vite'sbuild.assetsInlineLimit
. So the problem was that, for some reason, my script inlined in an astro file was in the threshold of thatbuild.assetsInlineLimit
, and Vite was inlining it, so that's the reason it didn't exist in the final build.The "solution" for now is to use
vite.build.assetsInlineLimit
in the Astro config and set it to0
so everything "exists" for the imports defined by Astro, but I think it should be solved more elegantly.This issue is weird because, for some reason, I can't reproduce it in Stackblitz, but maybe you all can figure it out. The link to reproduce is a Vercel deployment of my site with the
assetsInlineLimit
unset (which produces the broken state). You can see in the DevTools terminal the error with the missing hoisted file.Here's the JS static log from Vercel:
I'm willing to pair with anyone on the team, maybe through Discord, to show you the build output and help you folks out ^_^
Link to Minimal Reproducible Example
https://luke-hs72bavte-lukeshiru.vercel.app/
Participation
The text was updated successfully, but these errors were encountered: