-
-
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
🐛 BUG: Importing the astro.config.mjs file in a js/.jsx causes problems when using vite-imagetools #2200
Comments
Interesting. I’m not sure how Vite handles Node binary add-ons, but perhaps this can be configured. @natemoo-re, would you know? |
@jonathantneal Vite uses ESBuild to optimize the dependencies, and ESBuild doesn't support loading |
So, I think to get rid of these weird behaviors we can simply add a loader for |
Hey, this issue is out of date and may have been fixed in the latest version of Astro. If you can still reproduce the issue with the latest version of astro ( We think this one is actually likely handled by the Vite upgrade included in |
What version of
astro
are you using?0.21.12
What package manager are you using?
yarn
What operating system are you using?
Ubuntu
Describe the Bug
I am facing the following issue when importing the
astro.config.mjs
file inside a.js|.jsx
file when usingvite-imagetools
.Interestingly the problem doesn't happen in
.astro
component or even inside.ts|.tsx
files/components. It doesn't matter whether you import the file into a component or not (Vite checks for import statements inside the complete project, so it's normal I think).You can solve the problem either by removing the import or by adding
vite-imagetools
to thevite.optimizeDeps.exclude
array.So, what I think is, maybe the default config set by Vite (or Astro) is ignored when you import the
astro.config.mjs
file inside a.js|.jsx
file. It doesn't matter whether you usevite-imagetools
or not. I think in my case I am receiving the error because the default setting excluded the imported plugins from optimization automatically. As a result, it was able to avoid the fact that ESBuild doesn't support loading.node
files. So, a regular user may not experience this issue when importing the config file.(The below reproduction won't work until you clone it into your machine as StackBlitz doesn't support
sharp
)Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ap7kc8?file=src%2Fscripts%2FimportConfig.js
The text was updated successfully, but these errors were encountered: