Skip to content

fix: declare tslib as a runtime dependency - #630

Merged
hustcc merged 1 commit into
hustcc:masterfrom
Sam-Razavi:fix/tslib-runtime-dependency
Nov 7, 2026
Merged

hustcc merged 1 commit into
hustcc:masterfrom
Sam-Razavi:fix/tslib-runtime-dependency

Conversation

@Sam-Razavi

Copy link
Copy Markdown
Contributor

Fixes #512

The build uses importHelpers, so lib/ and esm/ import tslib at runtime (__assign, __awaiter, __extends, __generator and __rest, plus __importDefault and __importStar in the CJS build). tslib isn't declared as a dependency, so it only resolves when another package, usually echarts, happens to put it within reach of echarts-for-react.

This adds tslib: ^2.3.0 to dependencies, the same range echarts 5 and 6 use, so package managers can share one copy.

Tested by packing the package before and after and installing each with pnpm 9, React 19 and echarts 6:

  • pnpm with hoist=false: before, require('echarts-for-react') fails with Cannot find module 'tslib'. After, it loads.
  • pnpm with default settings: it loads in both cases, which is probably why this only shows up in some setups.

Jest passes (13/13). The only lint errors are the two existing @ts-ignore ones in __tests__/charts/simple-spec.tsx, which are on master too.

#494 made the same change in 2022 and was closed without a comment. If there's a reason to prefer another approach, for example raising the build target so the helpers aren't needed, I'm happy to switch.

The build uses importHelpers, so lib/ and esm/ import tslib at runtime,
but it was not declared. It only resolved when another package happened
to put it within reach, and failed under strict installs such as pnpm
with hoist=false.

Fixes hustcc#512
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.737%. remained the same — Sam-Razavi:fix/tslib-runtime-dependency into hustcc:master

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change declaring tslib as a runtime dependency.

No open issues 🎉

What changed in this PR

Addresses #512 by declaring tslib as a runtime dependency, so the compiled library no longer relies on another package making TypeScript helpers available through dependency hoisting.

Changes:

  • Adds tslib: ^2.3.0 to runtime dependencies, matching the range used by echarts 5 and 6.
File Description
package.json Declares the runtime dependency required by the compiled CommonJS and ES module builds.

Review effort: Balanced

@hustcc
hustcc merged commit e13be90 into hustcc:master Nov 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tslib as dependency

4 participants