antvis/G2

服务端渲染示例在最新node下报错 #6592

Mleijian posted onGitHub

我使用文档的示例运行错误,我对前端接触不多,修正一下文档或bug var d3 = require('d3-color'); ^

Error [ERR_REQUIRE_ESM]: require() of ES Module E:\test\node_modules\d3-color\src\index.js from E:\test\node_modules@antv\g-lite\dist\index.js not supported. Instead change the require of E:\test\node_modules\d3-color\src\index.js in E:\test\node_modules@antv\g-lite\dist\index.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (E:\test\node_modules@antv\g-lite\dist\index.js:24:10) { code: 'ERR_REQUIRE_ESM' }

Node.js v20.12.0

我修改require未import后,依然不行 const chart = new Chart({ ^

ReferenceError: Chart is not defined at Object.<anonymous> (E:\test\index.js:46:15) at Module._compile (node:internal/modules/cjs/loader:1369:14) at Module._extensions..js (node:internal/modules/cjs/loader:1427:10) at Module.load (node:internal/modules/cjs/loader:1206:32) at Module._load (node:internal/modules/cjs/loader:1022:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49


锁死 d3 所有库依赖为^2,这个问题已经在解决中了,年前应该能解决。https://github.com/antvis/G2/pull/6594

posted by hustcc 3 months ago

另外想了解下你用 node ssr 的场景是啥?后面也想开放 ssr 的服务接口出来给社区用,不知道用户量,使用方式如何?

posted by hustcc 3 months ago

@hustcc 生成简报图片,然后通过邮件或者消息发送

posted by Mleijian 3 months ago

@hustcc 生成简报图片,然后通过邮件或者消息发送

了解了,那我们内部是一样的,如果我们提供对外服务,会愿意使用吗?比如考虑到数据安全不使用之类的。

posted by hustcc 3 months ago

@hustcc 就是因为考虑到数据安全,我们才生成图片,不止是使用图表,还会有表格

posted by Mleijian 3 months ago

@Mleijian 了解了,那就是图表 ssr,页面类型的就是 Puppeteer 了。

posted by hustcc 3 months ago
posted by hustcc 2 months ago

Fund this Issue

$0.00
Funded

Pull requests