Closed RATIU5 closed 6 months ago
Same for me, in dev mode the error is triggered but when the project is build successfully the error does not appear
I believe it's something in vite when optimizing dependencies in dev mode
try this
export default defineConfig({
integrations: [dynamicImport()],
vite: {
optimizeDeps: {
exclude: ['astro-dynamic-import:internal'],
},
},
});
i guess that a good call should be using the octal numbers ids and virtual name for the imports like the doc says https://vitejs.dev/guide/api-plugin
const virtualModuleId = 'virtual:my-module' const resolvedVirtualModuleId = '\0' + virtualModuleId
Thanks for the reproduction. I see the error on startup of the dev server.
I believe it's something in vite when optimizing dependencies in dev mode
That's a good observation. I notice the error on page request in addition to startup, which is when vite optimization takes place, but this might be helpful in pointing in the right direction.
i guess that a good call should be using the octal numbers ids and virtual name for the imports like the doc says
Yeah, that's a good idea. It didn't make a difference for this error, however.
Tailwind seems to fail whenever I reload with this error occurring.
Do tailwind styles remain broken after page reloads?
Do tailwind styles remain broken after page reloads?
Yes even after reloading the styles remained broken. Not sure if this actually has anything to do with this error, just something I noticed.
try this
That seemed to make the error go away, even after I built and then started the dev server again. Not sure how long it will last or if this is the best solution, but it works for the time being. Thanks.
I don't understand the root cause, but the fix is safe, it will not have any side-effects.
@evertonadame Do you want to open a PR? It can go here, inside the updateConfig()
call:
Pull request opened in https://github.com/lilnasy/gratelets/pull/97
The Problem
I am using the
astro-dynamic-import
library. My project used to work in development. I built, and then I restarted my development server and I got the following error:Replication
If you need to replicate it, here is my StackBlitz project. Simply run
npm install && npm run dev
to see the error. An item to note:astro-dynamic-import
was modified for this projectVersions
Astro version: ^4.7.0 astro-dynamic-import version: ^1.1.0 pnpm version: 8.15.1
About the Error
I did some extensive testing and the only correlation I found was once I build the project and then run the dev server, this error triggers. For me, it happens once, and then I reload my page, and most things return to normal. Tailwind seems to fail whenever I reload with this error occurring. I tried deleting the
dist
folder, that did nothing.I was able to avoid the error when I reverted back to an old commit, then reverted back to the new commit, and then ran the dev server without building the project. Oh, and the project builds successfully. I could not replicate this fix on the sandbox.