-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Fail to import ESM dependencies in config file #4455
Comments
more info on unified package: vitejs/vite-plugin-react#30 |
@dominikg the linked issue and further ones linked to it don't have the ERR_REQUIRE_ESM as far as I can see, even though it might be the same underlying problem. |
It's kinda tricky. The To use it as an actual ES module, you'll need to rename it to Note that, in that case, you might encounter some other issues due to Node.js ESM-CJS interop restrictions. |
It's not a bug, though. |
@sodatea Did you try any one of your solutions in the codesandbox?
Will open another bug with that in this case. If vite could prevent this without having to use What about vitejs/vite-plugin-react#30 #3024 sveltejs/kit#1961?Are they related? |
Anyways, thanks for having a look 👍🏻 I'll dig deeper into my problems with setting |
The config in CodeSandbox seems to be different than the one you described in the issue.
Don't use This can be considered a small bug of Vite. It currently only recognizes
2 problems here:
That is, // vite.config.mjs
import { defineConfig } from "vite";
import preact from "@preact/preset-vite";
export default defineConfig({
plugins: [preact.default()]
}); |
@sodatea thanks! ❤️ |
Is there an issue tracking this? I'm currently using multiple config files to get around an issue with the https://github.com/bensmithett/tropical/blob/main/package.json#L39-L40 ...but I don't think I can update a dependency (rehype-slug) to its latest ESM-only version until I can pass an |
Describe the bug
Related to #1166 - this time with a reproduction.
Given the following
vite.config.js
file:results in
[ERR_REQUIRE_ESM]: Must use import to load ES Module
error, as at least one of the imported packages (here:unified
) is an ESM package.I'm not sure why that happens, but the reasoning in #1166 seems understandable. Looking at that issue, it's supposed to be fixed in
2.x
, but it seems like it isn't.Reproduction
https://codesandbox.io/s/vite-config-esm-problem-mlill
System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: