Lossless Changelog
fleet

LFM Loads in the Browser, From a CDN

A new browser-safe entry, @lossless-group/lfm/browser, and publishing to npm so jsDelivr, unpkg and esm.sh can serve it to a page with no build step.

Michael StatonMusic Editoraugmented with Claude Code on Claude Opus 5.5

Why Care?

A Claude artifact, a CodePen or a plain HTML file can't run pnpm install. It imports by URL, and the CDNs that serve packages by URL (jsDelivr, unpkg, esm.sh) mirror the public npm registry. LFM was only on GitHub Packages and JSR, and its root entry imports node:fs for the Open Graph cache, so it couldn't load in a browser even if a CDN had it.

What's New?

  • @lossless-group/lfm/browser: the parser, the remarkLfm preset and every plugin, hex-code citations included, with no Node imports. Open Graph fetching is left out; the ogFetch option is ignored there, with a warning.

  • npm publishing: pnpm lfm:npm, included in pnpm lfm:publish, and publish-npm.yml, which publishes with provenance on v* tags.

  • A guide: In the browser, and a README section.

Once a version is on npm:

JS
import { parseMarkdown } from 'https://cdn.jsdelivr.net/npm/@lossless-group/lfm@<version>/browser/+esm';

Under the Hood

  • The preset's body moved to src/preset-core.ts as createRemarkLfm(ogFetcher?). The root preset passes the Open Graph fetcher in; the browser preset doesn't, so it never imports it. The root entry's exports and output are unchanged, and a test checks both presets build the same tree.

  • test/browser-entry.test.mjs bundles dist/browser.js with esbuild for platform: 'browser' and fails on any Node builtin anywhere in the graph, then renders hex citations cited out of order through remark-rehype.

  • Found on the way, logged rather than fixed: Preset Transforms Run After Plugins Added Later in the Chain. Chaining remark-rehype after remarkLfm in one processor skips LFM's transforms, so the docs render in two steps.

  • package.json: bin and repository.url in the form npm publish normalizes them to, so publishing prints no warnings.