Skip to content

fix(pages): the self-hosted Mermaid bundle ships the notices of all 74 packages it contains (#274) - #276

Merged
astrapi69 merged 5 commits into
mainfrom
fix/274-mermaid-notices
Oct 21, 2026
Merged

astrapi69 merged 5 commits into
mainfrom
fix/274-mermaid-notices

Conversation

@astrapi69

@astrapi69 astrapi69 commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Problem

Since #273 the Pages site serves Mermaid's standalone bundle (docs/assets/mermaid.min.js, mermaid 11.16.1) and ships only Mermaid's own licence next to it. The bundle contains the code of 73 other packages, and the site redistributes all of it, so each package's notice has to ship too. One of them is chevrotain, under Apache-2.0, which asks for a copy of the licence itself.

What the bundle contains (measured)

The packages come from the bundle's source maps, not from the dependency tree. Measured on 2026-10-21:

  • mermaid.min.js.map has 1125 sources:
    • 650 from packages in Mermaid's pnpm store, with versions in the paths.
    • 32 pointing into @mermaid-js/parser's own bundle (../../parser/dist/…).
  • The parser's chunk maps name langium 4.2.0, chevrotain 11.1.2 and the vscode-languageserver packages. They also name vscode-uri, whose sources appear only as webpack://LIB/… because vscode-uri is itself a webpack bundle.
  • Total: 74 packages. 25 of them are not installed here at that version. The bundle was built from Mermaid's lockfile (DOMPurify 3.4.0 there, 3.4.13 installed here), and langium and chevrotain are bundled into the parser at its own build time, so they are not installed at all.

A first approach walked the installed dependency tree. It found 110 packages, many of them never bundled (type packages, for one), and still missed langium and chevrotain. It was replaced before commit.

Change

  • scripts/third-party-notices.mjs provides three functions:
    • bundledPackages walks a source map and follows a sibling package's own maps. It fails on any source it cannot attribute, and lists them all.
    • noticeTexts takes each package's licence and NOTICE files from the package installed at that exact version, else from third-party/licenses/. It fails on a package with neither and prints the command that fetches the missing texts.
    • renderNotices writes the file.
  • scripts/mermaid-notices.mjs holds the rules for Mermaid 11's maps:
    • Mermaid's own sources.
    • @mermaid-js/parser's bundled files.
    • vscode-uri's webpack sources: vscode-uri 3.1.0, because langium 4.2.0 asks for ~3.1.0 and 3.1.0 is the only 3.1.x release; and path-browserify 1.0.1, because vscode-uri 3.1.0 asks for ^1.0.1 and 1.0.1 is the only 1.x release.
  • scripts/vendor-licence-texts.mjs fetches texts with npm pack, without installing anything. third-party/licenses/ holds the 25 vendored packages (364 KB). It is not part of the npm package.
  • docs-site/assets/mermaid.min.js.LICENSE.txt now has 74 sections (164 KB). Mermaid's licence comes first, then the others sorted by name.

For a bundle vendored elsewhere

scripts/write-mermaid-notices.mjs runs the same rules on a scratch install of any Mermaid version and fetches the missing texts on request. For adaptive-learner (#3813, Mermaid 11.17.2):

npm install --ignore-scripts mermaid@11.17.2   # in a scratch project
node scripts/write-mermaid-notices.mjs --mermaid-dir <scratch>/node_modules/mermaid \
  --bundle assets/javascripts/mermaid-11.17.2.min.js --out <file> --fetch-missing

The installed 11.17.2 bundle is byte-identical to the one adaptive-learner pins (sha256 581ed7d7…). The result has 75 sections, one for each package the maps name.

fastdom 1.0.12, new in Mermaid 11.17.2, ships its MIT licence only as a README section, with no licence file in the tarball or the repository. The vendoring step takes that section as LICENSE.from-README with a line naming its origin. A copy installed without a licence file no longer hides the vendored one.

Verification

  • src/third-party-notices.test.ts: 15 tests on small maps and package trees. They cover pnpm paths (scoped names, peer suffix), a sibling map, aliases, fail-closed on unattributable sources and missing texts, exact-version selection, the vendored fallback, and the notice-file rule (license-update.mjs is a script, not a licence; cytoscape ships one).
  • src/docs-site.test.ts: the shipped file starts with the notice header, contains Mermaid's licence verbatim and a section for every package the maps name, and carries chevrotain@11.1.2 (Apache-2.0) with the Apache text.
  • make release-check: passed, 77 files, 2074 tests. npm run lint, npm run typecheck, npm run docs:api:check, npm run docs:pages and npm run docs:pages:check are green. make prose-check is OK.

Notes

  • After a Mermaid bump the build may stop and list missing texts; CONTRIBUTING describes the step.
  • adaptive-learner vendors Mermaid 11.17.2 for its docs site with no notice at all (adaptive-learner#3813). The same tool will produce its file next.
  • The fix(pages): the Pages site loads nothing from a third-party host (#272) #273 PR body stated the licence situation wrongly; corrected there in a comment.

Closes #274

🤖 Generated with Claude Code

astrapisixtynine and others added 5 commits October 21, 2026 12:44
…s, with the licence texts (#274)

The docs site redistributes Mermaid's standalone bundle (engine#272) and
shipped only Mermaid's licence. The bundle contains the code of 73 more
packages, so each of their notices has to ship with it.

scripts/third-party-notices.mjs reads the packages from the bundle's
source maps, following a sibling package's own maps and failing on any
source it cannot attribute, and takes each package's licence and NOTICE
files from the package installed at that exact version or from
third-party/licenses/. A first approach walked the installed dependency
tree; it found 110 packages and still missed langium and chevrotain,
which Mermaid's parser bundles at its own build time and which are not
installed at all, so it was replaced before commit.

scripts/vendor-licence-texts.mjs fills third-party/licenses/ with npm
pack; it holds the 25 packages the bundle names at a version npm does
not install here.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… Mermaid bundle (#274)

mermaid.min.js.LICENSE.txt now carries Mermaid's licence and the licence
and NOTICE files of every package the bundle's source maps name, among
them chevrotain under Apache-2.0. scripts/mermaid-notices.mjs holds the
rules for Mermaid 11's maps: its own sources, @mermaid-js/parser's
bundled files, and vscode-uri's webpack sources (vscode-uri 3.1.0 and
path-browserify 1.0.1, the only releases langium 4.2.0's and vscode-uri's
ranges allow).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…TRIBUTING (#274)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
#274)

adaptive-learner vendors Mermaid 11.17.2 for its docs site without any
notice (adaptive-learner#3813). scripts/write-mermaid-notices.mjs runs
the same rules on a scratch install of that version and can fetch the
missing texts first (vendorLicenceTexts, now importable;
missingNoticeTexts lists them without throwing).

fastdom 1.0.12, new in Mermaid 11.17.2, ships its MIT licence only as a
README section: the vendoring step takes that section as
LICENSE.from-README with a line naming its origin, and a copy installed
without a licence file no longer hides a vendored one.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
#274)

chevrotain-allstar ships its licence with CRLF line ends. Git normalises
them on commit, so a notices file pinned by hash in a repository
(adaptive-learner#3813) no longer matched its own checkout. renderNotices
writes LF throughout.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@astrapi69
astrapi69 merged commit 81a35aa into main Oct 21, 2026
4 checks passed
@astrapi69
astrapi69 deleted the fix/274-mermaid-notices branch October 21, 2026 12:25
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.

pages: the self-hosted Mermaid bundle ships without the notices of the libraries it contains

2 participants