-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
@astro/image errors "require is not defined" in local development #4568
Comments
Thanks! I'll take a look at this. |
@tony-sull, setting |
@joe-bell in the meantime you can set these as external in your own config which seemed to resolve it in my testing: export default defineConfig({
vite: {
ssr: {
external: ['image-size', 'tiny-glob']
}
}
}); |
@matthewp that works a charm in the meantime, thank you! Note: I did also have to install image-size and tiny-glob as devDependencies for this to work |
Ah, yes, anything that is external needs to be hoisted. I don't know if your monorepo setup allows hoisted all of that example project or not, if so that would avoid needing to individually hoist external packages. |
Can confirm that this is because of hoisting. Due to how Vite works when compiling code, it winds up Other Vite-based frameworks have the same problem, see for example: nuxt/vite#91 So closing as there's not really anything we can do here until the underlying problem is resolved in Vite. |
Thanks @matthewp! |
Just ran into this problem myself! Any chance we could get a note added to the documentation about this? Save people having to search the issues |
What version of
astro
are you using?1.1.2
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
pnpm
What operating system are you using?
Mac
Describe the Bug
Hey friends! Appreciate the work you're doing at Astro – I've been having a blast using it for the last few days
I've been recently building an Astro example for plaiceholder, but stumbled across an issue when trying to use
@astro/image
:joe-bell/plaiceholder#218
When visiting any of these newly added pages locally in
astro dev
, I see:This issue only seems to happen within my local environment, not in Vercel.
Some other details that might help to diagnose:
16.15.1
.npmrc
contents (I don't want to hoist all within my monorepo)I'd love to have this example as a "gold standard" Astro site, so I'd really appreciate any help to investigate :pra
Link to Minimal Reproducible Example
joe-bell/plaiceholder#218
Participation
The text was updated successfully, but these errors were encountered: