fix(theme): export v5 theme for ESM bundles - #21758
Open
acdn-tsmith wants to merge 1 commit into
Open
acdn-tsmith wants to merge 1 commit into
acdn-tsmith wants to merge 1 commit into
Conversation
|
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 v5 theme entry that registers the compatibility theme on the public ECharts module instance while preserving existing UMD, CommonJS, and browser-script behavior.
Fixed issues
Closes #21757
The documented v5 theme side-effect import can register on a different ECharts instance in Webpack 5 applications.
Details
Before: What was the problem?
theme/v5.jsis a UMD module. In a direct Webpack 5 application, its AMD/CommonJS dependency can resolve to a different ECharts entry from the public ESM import used by the application. The theme is then registered on that second module instance while the application silently retains the ECharts 6 theme.The minimal Webpack reproduction reports
#5070ddinstead of the expected v5 color#5470c6: https://gist.github.com/acdn-tsmith/e3f426c844217682dd6a2aedd4821b88After: How does it behave after the fixing?
Package export conditions select a small ESM facade for
import 'echarts/theme/v5'andimport 'echarts/theme/v5.js', whilerequireand direct browser-script users retain the existing UMD module. The ESM facade registers the exported theme through the public bareechartsentry, so the registration targets the consuming application's module instance.The v5 theme object is also exported with a declaration for consumers that need explicit registration. The ESM facade is marked as side-effectful so bundlers do not remove the documented import.
The packed package passes the linked Webpack reproduction and a direct Node ESM registration check. Verification also includes:
TZ=UTC npm test— 195 tests passednpm run test:dts— TypeScript 4.7 through 5.9 passednpm run checktypenpm run lintnpm run checkheaderDocument Info
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
v5Themecan be registered through the public API.Merging options
Other information
N.A.