I have a problem using Nivo charts with remix.run. Can't compile, error:
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\tomer\Code\remix-es\node_modules\d3-color\src\index.js from C:\Users\tomer\Code\remix-es\node_modules\@nivo\colors\dist\nivo-colors.cjs.js not supported.
Instead change the require of index.js in C:\Users\tomer\Code\remix-es\node_modules\@nivo\colors\dist\nivo-colors.cjs.js to a dynamic import() which is available in all CommonJS modules.
Well according to this: link, I have to add packages to serverDependenciesToBundle. Here is snippet from remix.config.js:
module.exports = {
tailwind: true,
ignoredRouteFiles: ["**/.*"],
serverDependenciesToBundle: ["d3-color", "d3", "@nivo"],
What is wrong here...
I have a tool that will return the list of ESM packages to add to
serverDependenciesToBundlehttps://github.com/kiliman/rmx-cli#-get-esm-packages
Returns
You can also simplify by using Regex: