Self-host ECharts runtime asset - #1284
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
ECharts was loaded from jsDelivr at runtime, which makes chart rendering depend on a third-party CDN hostname that may be blocked by Malaysian ISPs or other network filters. Serving the runtime as a first-party build asset keeps the lazy-loading behaviour while making the script available through the normal frontend deployment and Cloudflare proxy.
Lessons learnt
SvelteKit emits
?urlpackage assets under/_app/immutable/assets/with content-hashed filenames and long-lived immutable cache headers. The built Node adapter returnscache-control: public,max-age=31536000,immutablefor the emitted ECharts bundle, so Cloudflare can cache it safely as a first-party static asset.Summary
echarts@5.6.0as a dependency and loadecharts/dist/echarts.min.jsthrough Vite instead of jsDelivr.resolveEChartsScriptUrl()as the single helper for changing the runtime location later./_app/immutable/assets/.