pratik-desgn opened a new pull request, #21759: URL: https://github.com/apache/echarts/pull/21759
## Brief Information This pull request is in the type of: - [x] bug fixing - [ ] new feature - [ ] others ### 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 - #21757: Fix v5 compatibility theme imports in strict Webpack 5 ESM applications. ## 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 `import` condition for both `echarts/theme/v5` and `echarts/theme/v5.js` now resolves to `theme/v5.mjs`, which registers through the package's ESM core entry. The `require` and `default` conditions remain on `theme/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 - [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. ### Related test cases or examples to use the new APIs Validated with the ECharts 6.1.0 package in Webpack 5.110.3: - The baseline bundle includes the legacy UMD theme wrapper; the patched bundle resolves the ESM entry. - Node ESM imports of both `echarts/theme/v5` and `echarts/theme/v5.js` register 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`, and `git diff --check` pass. The normal `npm run build:lib` check is currently blocked by the checkout's existing TypeScript 4.4/dependency mismatch: installed newer `@types/node` and Babel declarations are rejected before this change is compiled. ### Merging options - [x] Please squash the commits into a single one when merging. ### Other information The commit includes the Apache-recommended `Generated-by: OpenAI Codex` provenance trailer. -- 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]
