Open AnzhiZhang opened 4 months ago
在 Nuxt 官方提供的指导下(https://nuxt.com/docs/guide/concepts/esm#transpiling-libraries),设置 transpile
,暂时可以使用了
build: {
transpile: [
"@antv",
],
},
但是该文档还提到
If you encounter these errors, the issue is almost certainly with the upstream library. They need to fix their library to support being imported by Node.
方便的话还是烦请帮忙检查一下 CJS 的语法问题
🐛 Question description [Please make everyone to understand it]
Nuxt 是一个 Vue SSR 框架,我在使用 G2Plot 时,遇到了以下错误:
timeline.js 的相关代码:
根据 Nuxt 的说明(https://nuxt.com/docs/guide/concepts/esm),这种情况可能是由于在 ESM 模块中使用了 CJS 语法。
我查到了相关的几个 issue:antvis/G2Plot#1894, antvis/G6#4646
https://github.com/antvis/G6/issues/4646#issuecomment-1593999758 这个解决方案可以解决
d3-interpolate
库的问题,但是还会有新的问题,也是因为使用了require
:以前的相关修复:antvis/G2#3141
请问是否可以协助确认,是否是 g2 生态的库使用了 cjs 语法导致的问题,以及能否建议一定的解决方案?如果能解决 esm 模块中的 cjs 导入就好了。
💻 Link to minimal reproduction
https://stackblitz.com/edit/github-cibroa?file=app.vue
🏞 Expected result
可以正常引入 G2Plot 并使用。
🚑 Any additional [like screenshots]