-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Vite (using ESBuild) fails with 'require() of ES Module not supported' #2602
Comments
Perhaps a useful article on how to make the library work well for both |
You might also want to switch from |
I think it's a duplicate of #2310. |
Could be but everyone wants to discontinue the commonjs version while the |
There are many tools out there, some with their own way of loading things, I think that's a bold assumption. |
I'm going to close this issue, as it's clearly related. |
The suggested Vite config addition from the other ticket actually worked wonders. Thx. ssr: {
noExternal: [/^d3.*$/, /^@nivo.*$/],
}, |
Describe/explain the bug
When creating a Remix site with Vite and using the @nivo packages it fails to run with the Vite development server. It leads to the following error:
This probably has to do with Vite using ESBuild for development builds, which doesn't understand whether the packages are
CommonJs
orESM
and hence treating it incorrectly. It thinksnivo-core.cjs.js
is anESM
file, while it's aCommonJS
file in reality.This can (partially) be fixed by adding
type
andexports
to the packages as follows:but then leads to a following error:
To Reproduce
Steps to reproduce the behavior:
npx create-remix@latest --template remix-run/remix/templates/cloudflare
cd my-remix-app
npm i @nivo/[email protected] @nivo/[email protected]
app/routes/_index.tsx
withnpm run dev
and open the url tohttp://localhost:5173/
that shows in the output (port number can be different)Expected behavior
Show the same as when running
npm run build
followed bynpm run start
and then opening the localhost site url shown in the logs. Vite usestsc
instead ofesbuild
for creating production artifact leading to a different outcome.Desktop (please complete the following information):
Zorin 17.1
Chrome
Version 125.0.6422.112 (Official Build) (64-bit)
Additional context
https://publint.dev/@nivo/[email protected] show a number of issues with the packages that should be fixed.
The text was updated successfully, but these errors were encountered: