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] Error [ERR_REQUIRE_ESM]: require() of ES Module. dynamic import() which is available in all CommonJS modules. #40644
Comments
This is an issue of remix because it has a commonjs ssr entry. |
@luo3house If you add code to the package.json:
then everything works. In the terminal: npm ls @antv/path-util
@antv/path-util@3.0.1 version causes a bug. @antv/path-util@2.0.15 version works fine. |
Related: antvis/G#1282 Seems
Therefore, here is a Remix workaround to pre-bundle them into CJS for your reproduction: // remix.config.js
module.exports = {
ignoredRouteFiles: ["**/.*"],
+ serverDependenciesToBundle: [
+ /@ant-design\/*/,
+ /@antv\/*/,
+ /d3-interpolate/,
+ /d3-color/,
+ /lodash-es/,
+ ],
// ...
};
|
@luo3house Thank you! It works! |
@luo3house can u provide a solution for non remix repos. I use vite with react I use react spa and uses latest vite and typescript |
Facing same with next js |
Facing the same issue with Nextjs. Error [ERR_REQUIRE_ESM]: require() of ES Module D:\Github\LunaraApp\node_modules\d3-interpolate\src\index.js from D:\Github\LunaraApp\node_modules@antv\g-base\lib\animate\timeline.js not supported What's the solution? |
For Nextjs, if CSR isn't an issue. You can try Dynamic CSR import. This solved the issue for me.
|
const DynamicBullet = dynamic(() => import('@nivo/bullet').then(res => res.ResponsiveBullet), { This works for me. |
There are 2 possible solutions, if you are using NEXT. If there are any imports in your project from or write the following line in your package json to override the dependencies of your antd plot dependency.
|
for people using React with Vite, load your component lazily will solve this issue, for example, if you are using the Line or Pie component from @ant-design/plots, import the component lazily as following: const Line = React.lazy(() => import("@ant-design/plots").then((module) => ({ default: module.Line }))); and then wrap the Line component with Suspense in your functional component as such: <Suspense fallback={<div>Loading...</div>}>
<Line {...config} />
</Suspense> |
Thank you! Solved the problem with "output: 'standalone'" in next.js |
Reproduction link
https://github.com/EvgeniyBudaev/remix-ant/blob/main/app/routes/index.tsx
Steps to reproduce
I have created a simple project. https://github.com/EvgeniyBudaev/remix-ant/blob/main/app/routes/index.tsx
What is expected?
The WordCloud component is displayed.
What is actually happening?
I get an error:
Error [ERR_REQUIRE_ESM]: require() of ES Module \remix-ant\node_modules\d3-interpolate\src\index.js from \remix-ant\node_modules@antv\g-base\lib\animate\timeline.js not supported.
Instead change the require of index.js in \remix-ant\node_modules@antv\g-base\lib\animate\timeline.js to a dynamic import() which is available in all CommonJS modules.
The text was updated successfully, but these errors were encountered: