G6
G6 copied to clipboard
[email protected] 开发环境下加载远程代码导致无法使用
[email protected] 开发环境下加载远程代码导致无法使用,可能跟这个别名设置有关 182c345,导致输出的npm包里也有加载远程的代码。

- 代码示例
import G6 from '@antv/g6';
console.log(G6);
- 报错信息
./node_modules/@antv/g6/dist/g6.min.js
Module not found: Can't resolve 'https://cdn.jsdelivr.net/npm/@webgpu/[email protected]/dist/web-devel/glslang.js' in '/home/react-app/node_modules/@antv/g6/dist'
同样的问题
./node_modules/@antv/g6/dist/g6.min.js
Module not found: Error: Can't resolve 'https://cdn.jsdelivr.net/npm/@webgpu/[email protected]/dist/web-devel/glslang.js' in 'D:\zhuiyi\nlp-platform-web\node_modules\@antv\g6\dist'
+1
+1
+1
问题是依赖的 g-webgpu 造成的,已经发布了 v0.5.1 修复。
原因是 g-webgpu 使用了 ESModule 的 import 语法动态加载编译 shader 用的 glslang.js,通过 magic comment 让 webpack 忽略掉这个依赖的解析。但 g6 构建的 CDN 版本 dist/g6.min.js 显然会去除掉这个注释,导致开发模式下 webpack 报找不到依赖的错误。
改动之后不再使用 import。
g6 不需要做任何改动,只需要重新构建下 CDN 版本的 dist/g6.min.js,发布 bugfix 版本 v4.0.1即可。
4.0.1 已发布,麻烦更新到 4.0.1,多谢!