fix(theme): support ESM import for v5 compatibility theme - #21759
Open
pratik-desgn wants to merge 1 commit into
Open
pratik-desgn wants to merge 1 commit into
pratik-desgn wants to merge 1 commit into
Conversation
Generated-by: OpenAI Codex
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. |
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.
Brief Information
This pull request is in the type of:
What does this PR do?
Adds an ESM-compatible v5 theme entry and conditional package exports so ESM imports register the theme on the application's ECharts module instance while existing CommonJS, AMD, and browser-global consumers keep using the current UMD entry.
Fixed issues
Details
Before: What was the problem?
The v5 theme entry is a UMD/CommonJS file that imports
echarts/lib/echarts. When an application imports the ESM ECharts entry, Webpack can bundle a second ECharts module instance for the theme. The theme is then registered on that second instance and the chart continues using the ECharts 6 defaults.The extensionless package export also has no concrete target.
After: How does it behave after the fixing?
The
importcondition for bothecharts/theme/v5andecharts/theme/v5.jsnow resolves totheme/v5.mjs, which registers through the package's ESM core entry. Therequireanddefaultconditions remain ontheme/v5.js, preserving the existing non-ESM entry points. The ESM file is marked as a side effect so bundlers retain the registration.Document Info
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
Validated with the ECharts 6.1.0 package in Webpack 5.110.3:
echarts/theme/v5andecharts/theme/v5.jsregister the expected v5 palette.TZ=UTC npm test -- --runInBand: 26 suites, 194 tests passed.node --check theme/v5.mjs,node build/checkHeader.js,npm pack --dry-run --ignore-scripts, andgit diff --checkpass.The normal
npm run build:libcheck is currently blocked by the checkout's existing TypeScript 4.4/dependency mismatch: installed newer@types/nodeand Babel declarations are rejected before this change is compiled.Merging options
Other information
The commit includes the Apache-recommended
Generated-by: OpenAI Codexprovenance trailer.