You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve developer experience by changing message "failed to load module for ssr" #10002
As an indirect user of Vite by using Astro, I would like the failed to load module for ssr to express why the module failed to load.
I believe there are multiple conditions that can trigger this - the one I experience often is a wrong path to a file. It's only through past experience of this error that I know, in my case at least, that this usually means the file was not found.
This error can also happen when a type is imported without import type, as shown in withastro/astro#5333
As a downstream person in this, the information I'd love to have when this error happen are the following:
Where the error actually happened (including line numbers, if possible), in Astro we sometimes have this error when loading a .astro file that loads another file where the issue is caused and we currently can't know where the error happened exactly, just that it happened while loading a .astro module
Why the error happened, did the file not exist? Did it get incorrectly bundled because of a missing type-only import?
I know this issue is assigned to @bluwy, but just in case I'm definitely willing to contribute to this, though I might need a bit of guidance on Vite's internals.
Happy to chat and sync to go through the internals! May be better to run the debugger too to see where it's silently fail in case i'm making a wrong guess 😅
Activity
bluwy commentedon Sep 6, 2022
Hi, can you provide a repro to test this one out? I tried to bring this edgecase out in the past but couldn't get it to reach the error.
bluwy commentedon Oct 24, 2022
Repro: https://stackblitz.com/edit/github-ad1c93?file=test.js
Princesseuh commentedon Nov 9, 2022
This error can also happen when a type is imported without
import type, as shown in withastro/astro#5333As a downstream person in this, the information I'd love to have when this error happen are the following:
.astrofile that loads another file where the issue is caused and we currently can't know where the error happened exactly, just that it happened while loading a.astromoduleI know this issue is assigned to @bluwy, but just in case I'm definitely willing to contribute to this, though I might need a bit of guidance on Vite's internals.
bluwy commentedon Nov 9, 2022
I haven't started yet so feel free to take it too. The issue is likely that
transformRequest(and some child function) is swallowing the errorvite/packages/vite/src/node/ssr/ssrModuleLoader.ts
Line 88 in d5fe92c
Based on the behaviour so far, where importing something wrongly causes the vague error, I'm guessing it's failing the runtime import phase
vite/packages/vite/src/node/ssr/ssrModuleLoader.ts
Lines 137 to 164 in d5fe92c
The
ssrImportis called for eachimport bla from 'ha', by transforming the imports into a runtimessrImportcall, throughvite/packages/vite/src/node/ssr/ssrTransform.ts
Line 63 in d5fe92c
Happy to chat and sync to go through the internals! May be better to run the debugger too to see where it's silently fail in case i'm making a wrong guess 😅