antvis/G6

https://unpkg.com/@antv/layout@latest/dist/layout.min.js. G6源码中有用到这个cdn,这个cdn现在资源被移除了,导致线上项目崩溃 #5642

cqg001 posted onGitHub

Describe the bug

https://unpkg.com/@antv/layout@latest/dist/layout.min.js https://unpkg.com/@antv/layout@latest/dist/layout.min.js. G6源码中有用到这个cdn,这个cdn现在资源被移除了,导致线上项目崩溃

Your Example Website or App

https://unpkg.com/@antv/layout@latest/dist/layout.min.js. G6源码中有用到这个cdn,这个cdn现在资源被移除了,导致线上项目崩溃

Steps to Reproduce the Bug or Issue

https://unpkg.com/@antv/layout@latest/dist/layout.min.js. G6源码中有用到这个cdn,这个cdn现在资源被移除了,导致线上项目崩溃

Expected behavior

https://unpkg.com/@antv/layout@latest/dist/layout.min.js. G6源码中有用到这个cdn,这个cdn现在资源被移除了,导致线上项目崩溃

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response


<!-- Answer -->

It appears the CDN link for the @antv/layout package used in your G6 project is no longer accessible, causing your online project to crash. Here are steps to resolve the issue:

  1. Check for an Updated CDN Link: Visit the AntV official website or their GitHub repository for a new CDN link for the @antv/layout package.

  2. Download and Host the Package Locally: To avoid future CDN issues, download the @antv/layout package (via npm install @antv/layout) and serve the layout.min.js file from your server.

  3. Use a Package Manager: Add @antv/layout to your project dependencies using npm or Yarn (npm install @antv/layout or yarn add @antv/layout). This ensures the package is included in your project's build output.

  4. Update Your Import Statements: Reflect the new location of the @antv/layout package in your codebase. For example, after installing the package, you can import it directly in your JavaScript or TypeScript files:

import { DagreLayout } from '@antv/layout';
  1. Fallback to an Alternative CDN: As a temporary fix, search for alternative CDNs like jsDelivr or cdnjs that might host the @antv/layout package.

These steps should help you mitigate the issue with the missing CDN resource and prevent similar problems in the future.

Sources

<!-- Dosu Comment Footer -->

<details> <summary>

About Dosu

</summary>

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

</details>

posted by dosubot[bot] about 1 year ago
posted by Aarebecca about 1 year ago

看起来是 unpkg 服务器的问题,尝试使用:

并不是unpkg服务问题,而是@antv/layout这个包,在0.x的版本是存在layout.min.js文件的,但是latest版本1.x目前文件被移除了。 所以可以配置layout的workerScriptURL属性为:

也可以改成使用本地worker:

new G6.Graph({
  ...,
  layout: {
    ...
    workerScriptURL: new URL('@antv/layout/dist/layout.min.js', import.meta.url).toString(),
  }
});
posted by haoqi0818 9 months ago

Fund this Issue

$0.00
Funded

Pull requests