Skip to content
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

require() of ES Module Error when Using @antv/g2 with Vitest #6486

Open
222chaos opened this issue Oct 9, 2024 · 2 comments
Open

require() of ES Module Error when Using @antv/g2 with Vitest #6486

222chaos opened this issue Oct 9, 2024 · 2 comments

Comments

@222chaos
Copy link

222chaos commented Oct 9, 2024

问题描述

在使用 @antv/g2 库时,遇到了以下错误:
Error: require() of ES Module /path/to/project/node_modules/d3-array/src/index.js from /path/to/project/node_modules/@antv/g2/lib/transform/utils/order.js not supported.
Instead change the require of index.js in /path/to/project/node_modules/@antv/g2/lib/transform/utils/order.js to a dynamic import() which is available in all CommonJS modules.

重现链接

No response

重现步骤

1.使用 vitest 进行单元测试。

2.项目中引入了 @ant-design/plots 和 @ant-design/charts。

3.运行测试时,报错与 @antv/g2 依赖 d3-array 模块不兼容。

预期行为

@antv/g2 应该能够正确处理 ES 模块的导入,避免使用 require() 导入 ES 模块,改为使用 import() 来确保兼容性。

平台

No response

屏幕截图或视频(可选)

No response

补充说明(可选)

可能的解决方案是将 require() 替换为动态 import(),以兼容 ES 模块环境。

@lxfu1
Copy link
Member

lxfu1 commented Oct 10, 2024

#6456

@hustcc
Copy link
Member

hustcc commented Oct 10, 2024

参考:d3/d3-array#218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants