Skip to content

Support Chartist 2 (1.0.1) - #115

Merged
fraserxu merged 1 commit into
masterfrom
chartist-2-support
Oct 22, 2026
Merged

fraserxu merged 1 commit into
masterfrom
chartist-2-support

Conversation

@fraserxu

Copy link
Copy Markdown
Owner

Refs #114

Chartist 2 is out, and the stock ChartistGraph already works with it. The only blocker is the peer range, which makes npm fail with ERESOLVE next to chartist 2. This PR prepares a 1.0.1 patch.

Changes

  • package.json: version 1.0.1, peer "chartist": "^1.5.0 || ^2.0.0". The devDependency stays chartist@^1.5.0, and a new alias dev dependency chartist-2 (npm:chartist@^2.1.0) lets one npm test run cover both majors.
  • test/chartist-2.test.tsx (new): uses vi.mock("chartist", () => import("chartist-2")) so the component runs on Chartist 2 in this file. It checks that v2 is really loaded, that Line, Bar and Pie render an SVG, that detach() is called on unmount, and that draw and created listeners fire with options={{ plugins: [compat] }}.
  • README: new "Chartist 2" section covering the opt-in compat plugin, with an example, a note on memoizing options, a note that the overrides workaround is no longer needed, and a note that SSR/hydration isn't supported yet. Intro and migration notes are updated too.
  • CHANGELOG: 1.0.1 - Unreleased entry.

No changes to src/. SSR/hydration is out of scope.

Verified locally (Node 20.19)

npm run check passed with:

  • chartist 1.5.0 (lockfile default), plus the Chartist 2.2.0 alias tests: 11/11 tests
  • chartist 2.1.0 installed as chartist: 11/11 tests
  • chartist 2.2.0 installed as chartist: 11/11 tests

The README example options={{ plugins: [compat] }} also type-checks without a cast against Chartist 2's types. The test file needs an as unknown as Plugin cast, because tsc sees 1.5's types there and 1.5 types Plugin as a function, while v2's compat is an object.

Suggested follow-up: CI job

This PR doesn't change the workflow, because the token used to push it lacks workflow scope. A job like this would run the full check with v2 as chartist itself, covering v2 types as well as the runtime:

  chartist-2:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          cache: npm
          node-version: "24"
      - run: npm install --global npm@11.18.0
      - run: npm ci
      - run: npm install --no-save chartist@^2.1.0
      - run: npm run check

Release

Merging does not publish. release.yml only runs when a GitHub release is published. Per CONTRIBUTING, set the CHANGELOG date and then create the v1.0.1 release.

Widen the chartist peer range to ^1.5.0 || ^2.0.0, document the opt-in
compat plugin for 1.x-style events, and test against Chartist 2.

Refs #114
@fraserxu
fraserxu merged commit 2f4324a into master Oct 22, 2026
4 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.

1 participant