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.
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, theremarkLfmpreset and every plugin, hex-code citations included, with no Node imports. Open Graph fetching is left out; theogFetchoption is ignored there, with a warning.npm publishing:
pnpm lfm:npm, included inpnpm lfm:publish, andpublish-npm.yml, which publishes with provenance onv*tags.A guide: In the browser, and a README section.
Once a version is on npm:
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.tsascreateRemarkLfm(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.mjsbundlesdist/browser.jswith esbuild forplatform: '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
remarkLfmin one processor skips LFM's transforms, so the docs render in two steps.package.json:binandrepository.urlin the formnpm publishnormalizes them to, so publishing prints no warnings.
