acdn-tsmith opened a new pull request, #21758:
URL: https://github.com/apache/echarts/pull/21758

   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   ### 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
   
   - #21757: the documented v5 theme side-effect import can register on a 
private ECharts instance in two-stage library/application bundles.
   
   ## Details
   
   ### Before: What was the problem?
   
   `theme/v5.js` is a UMD module whose CommonJS branch registers through 
`echarts/lib/echarts`. When a reusable library is bundled before its consuming 
application, that deep dependency can become a private ECharts module instance. 
The theme is then registered on the private instance while the application 
silently retains the ECharts 6 theme.
   
   The minimal two-stage Rollup reproduction reports `#5070dd` instead of the 
expected v5 color `#5470c6`: 
https://gist.github.com/acdn-tsmith/e3f426c844217682dd6a2aedd4821b88
   
   ### After: How does it behave after the fixing?
   
   Package export conditions select a small ESM facade for `import 
'echarts/theme/v5'` and `import 'echarts/theme/v5.js'`, while `require` and 
direct browser-script users retain the existing UMD module. The ESM facade 
registers the exported theme through the public bare `echarts` entry, 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 two-stage reproduction and a direct 
Node ESM registration check. Verification also includes:
   
   - `TZ=UTC npm test` — 195 tests passed
   - `npm run test:dts` — TypeScript 4.7 through 5.9 passed
   - `npm run checktype`
   - `npm run lint`
   - `npm run checkheader`
   
   ## Document Info
   
   - [x] This PR doesn't relate to document changes
   - [ ] The document should be updated later
   - [ ] The document changes have been made in apache/echarts-doc#xxx
   
   ## Misc
   
   ### Security Checking
   
   - [ ] This PR uses security-sensitive Web APIs.
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   - Unit coverage verifies that the UMD theme exports and registers the same 
v5 theme object.
   - Declaration coverage verifies the exported `v5Theme` can be registered 
through the public API.
   - Two-stage package reproduction: 
https://gist.github.com/acdn-tsmith/e3f426c844217682dd6a2aedd4821b88
   
   ### Merging options
   
   - [x] Please squash the commits into a single one when merging.
   
   ### Other information
   
   N.A.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to