Skip to content

chore: upgrade to Langium v4 and TypeScript v5.8#7377

Merged
aloisklink merged 6 commits intomermaid-js:masterfrom
aloisklink:chore/upgrade-to-langium-v4
Feb 16, 2026
Merged

chore: upgrade to Langium v4 and TypeScript v5.8#7377
aloisklink merged 6 commits intomermaid-js:masterfrom
aloisklink:chore/upgrade-to-langium-v4

Conversation

@aloisklink
Copy link
Copy Markdown
Member

@aloisklink aloisklink commented Feb 5, 2026

📑 Summary

Note

This PR targets the master branch, not develop.

Upgrade the @mermaid-js/parser package to use Langium v4.

There were a couple of breaking changes we had to fix to do this upgrade:

  • Rename all the grammers from Abc to AbcGrammar, as rules within grammars cannot have the same name as the grammar.
  • Update the tests, since the generated type names from ast.ts have been moved from <typeName> to <typeName>.$type.
  • Turn the EOL fragment into a rule, as in Langium v4, it's no longer allowed and throws an error.
  • Upgrade to using TypeScript v5.8, since Langium v4 is not compatible with older versions
    • TypeScript v5.8 also required switching our import assertions with import attributes.

v3.5.0 of Langium also had a breaking change with treemap diagrams, but I've moved the terminal INDENTATION in front of the hidden terminal WS and that seems to have fixed it!

Because of this, I've made the changeset for @mermaid-js/parser to be a major version, so we'd release v1.0.0 of it.

However, I don't believe any of these changes will be breaking to any user of mermaid, since mermaid doesn't re-export anything from @mermaid-js/parser, so just the default patch release that changeset makes would be okay for it.

Resolves #7345

📏 Design Decisions

Since there's some merge conflicts with develop and the master branch, I've also made https://github.com/aloisklink/mermaid/tree/chore/upgrade-to-langium-v4-develop so we can easily merge the changes into develop.

Also, due to @argos-ci failing, I've updated it so we can see the status of it on this PR.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
    • Our existing tests cover this
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
    • Not needed, other than the changeset entry.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 5, 2026

🦋 Changeset detected

Latest commit: 426a616

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@mermaid-js/parser Major
mermaid Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the Type: Other Not an enhancement or a bug label Feb 5, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.59%. Comparing base (1f8669a) to head (426a616).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
...ackages/mermaid/src/diagrams/git/gitGraphParser.ts 0.00% 6 Missing ⚠️
packages/mermaid/src/diagrams/info/infoDb.ts 0.00% 1 Missing ⚠️
packages/mermaid/src/docs/.vitepress/config.ts 0.00% 1 Missing ⚠️
packages/mermaid/src/mermaidAPI.ts 0.00% 1 Missing ⚠️
...ackages/parser/src/language/architecture/module.ts 0.00% 1 Missing ⚠️
packages/parser/src/language/gitGraph/module.ts 0.00% 1 Missing ⚠️
packages/parser/src/language/info/module.ts 0.00% 1 Missing ⚠️
packages/parser/src/language/packet/module.ts 0.00% 1 Missing ⚠️
packages/parser/src/language/pie/module.ts 0.00% 1 Missing ⚠️
packages/parser/src/language/radar/module.ts 0.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #7377      +/-   ##
=========================================
- Coverage    3.59%   3.59%   -0.01%     
=========================================
  Files         474     475       +1     
  Lines       47168   47185      +17     
  Branches      734     734              
=========================================
  Hits         1696    1696              
- Misses      45472   45489      +17     
Flag Coverage Δ
unit 3.59% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/parser/src/language/index.ts 0.00% <ø> (ø)
packages/mermaid/src/diagrams/info/infoDb.ts 14.28% <0.00%> (ø)
packages/mermaid/src/docs/.vitepress/config.ts 0.40% <0.00%> (ø)
packages/mermaid/src/mermaidAPI.ts 0.30% <0.00%> (ø)
...ackages/parser/src/language/architecture/module.ts 4.54% <0.00%> (ø)
packages/parser/src/language/gitGraph/module.ts 4.76% <0.00%> (ø)
packages/parser/src/language/info/module.ts 5.00% <0.00%> (ø)
packages/parser/src/language/packet/module.ts 4.76% <0.00%> (ø)
packages/parser/src/language/pie/module.ts 5.00% <0.00%> (ø)
packages/parser/src/language/radar/module.ts 5.00% <0.00%> (ø)
... and 2 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aloisklink
Copy link
Copy Markdown
Member Author

I'm moving this into draft. Argos CI doesn't seem to be working since this PR is a) from a fork, and b) using an older version of Argos.

But when testing this manually with git clean -fxd && clear && pnpm install && pnpm run e2e; git switch chore/upgrade-to-langium-v4 && pnpm install && pnpm run e2e, there seems to be some sort of regression with treemap diagrams:

Treemap-Diagram-8c-should-handle-dollar-sign-with-decimal-places diff

@aloisklink aloisklink marked this pull request as draft February 10, 2026 07:53
This is now required by TypeScript v5.8 and Node.js 22, and was
officially added to ECMAScript 2025 🥳
This is required to upgrade to Langium v4.
I've also unpinned the dependency and instead added a caret to the
specifier, so that any future security updates mean we won't need to
make a new release of the `@mermaid-js/parser` package.

I'm not sure why, but something between Langium v3.4.0 and v3.5.0
breaks indentation in treemaps, so we need to move the rule before
the `hidden terminal WS` rule.
Updates the `@mermaid-js/parser` to Langium v4.

There were a couple of breaking changes we had to fix to do this
upgrade:

- Rename all the grammers from Abc to AbcGrammar, as rules
  within grammars cannot have the same name as the grammar.
- Update the tests, since the generated type names from `ast.ts` have
  been moved from `<typeName>` to `<typeName>.$type`.
- Turn the EOL fragment into a rule, as in Langium v4, it's no longer
  allowed and throws an error.

As this is a **BREAKING CHANGE** for users, I've made a new major
release in the changeset (and it means we can finally get a v1.0.0 of
`@mermaid-js/parser`).
This pulls part of the following changes from `develop`:

- 99f17be (fix: update @argos-ci/cypress to version 6.1.3, 2025-10-07)
- 15e2824 (fix(deps): update all patch dependencies, 2025-11-06)
- 847b3aa (fix(deps): update all patch dependencies, 2025-11-10)
- 3c75242 (chore(deps): update all patch dependencies, 2025-11-19)

But, this is needed to get Argos working properly for PRs to `master`.
@aloisklink aloisklink force-pushed the chore/upgrade-to-langium-v4 branch from 478473b to 426a616 Compare February 13, 2026 12:02
@argos-ci
Copy link
Copy Markdown

argos-ci bot commented Feb 13, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 2 changed Feb 13, 2026, 12:14 PM

@aloisklink aloisklink marked this pull request as ready for review February 13, 2026 12:17
@aloisklink
Copy link
Copy Markdown
Member Author

Marking this as ready for review again! I went through and fixed a bunch of issues in treemap diagrams before finally finding the one that was breaking this. Apparently, the INDENTATION terminal was never being triggered (instead the hidden terminal WS was being triggered), so none of the treemap entries had any indentation associated with them.

I've also updated @argos-ci in this PR, just so we can see the result.

@aloisklink aloisklink merged commit 3735098 into mermaid-js:master Feb 16, 2026
16 of 17 checks passed
@github-actions github-actions bot mentioned this pull request Feb 16, 2026
@slorber
Copy link
Copy Markdown

slorber commented Mar 19, 2026

Not a big deal for us, but upgrading to Langium in a minor release means requiring a newer Node version, which is kind of a breaking change for Mermaid consumers (see facebook/docusaurus#11812)

error [email protected]: The engine "node" is incompatible with this module. Expected version ">=20.10.0". Got "20.0.0"

I'm not sure what your commitment to semver is, but maybe it could be useful to use GitHub actions with node matrices with min/max supported versions so that you detect early when a dependency require.

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

Labels

Type: Other Not an enhancement or a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants