Skip to content

fix(theme): export v5 theme for ESM bundles - #21758

Open
acdn-tsmith wants to merge 1 commit into
apache:masterfrom
acdn-tsmith:fix-21757
Open

acdn-tsmith wants to merge 1 commit into
apache:masterfrom
acdn-tsmith:fix-21757

Conversation

@acdn-tsmith

@acdn-tsmith acdn-tsmith commented Sep 18, 2026

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • 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

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.js is 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 #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 Webpack 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

  • 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

Merging options

  • Please squash the commits into a single one when merging.

Other information

N.A.

@echarts-bot

echarts-bot Bot commented Sep 18, 2026

Copy link
Copy Markdown

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] v6 migration guide v5 theme import fails in Webpack 5

1 participant