Repository navigation
Conversation
`parse()` reports `extractorType` from `extractor.constructor.name`, but the browser bundles are minified, so consumers of `dist/index.js` and `dist/index.full.js` got `a`, `i` or `v` instead of `github`, `twitter` or `youtube`. The unbundled CJS keeps the names, which is why Node was unaffected. Terser now keeps the names of the classes that end in `Extractor`, so the `temml` classes the bundles also carry are still mangled. Measured cost: `dist/index.js` 90.2 → 90.4 KB gzip and `dist/index.full.js` 206.9 → 207.1 KB, both inside the existing budgets, so no budget change is needed. Nothing in the test suite could see this: vitest runs on the TypeScript source and the build job only ran `build` + `size`. Added `scripts/check-extractor-names.mjs` (`npm run lint:extractor-names`, wired into the build job and the release checks) so dropping the option fails CI instead of shipping. Verified by loading the built full bundle with jsdom against a minimal LWN page: without this change the probe prints `extractorType = "a"`, with it `"lwn"`. The new check fails with the option removed and passes with it, and `npx vitest run` reports 789 passing tests.
paoValle
force-pushed
the
fix/keep-extractor-names
branch
from
October 24, 2026 17:11
e4f5cca to
643dc40
Compare
Author
|
Rebased onto The only conflict was Re-run after the rebase, with
The CI run on this branch is |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Keeps extractor class names in the browser bundles, so
parse()reportsextractorType: 'github'instead of'a'for anyone consumingdist/index.jsordist/index.full.js.Fixes #414.
Why
extractorTypeis derived fromconstructor.name, which Terser replaces with short names. Node loads the unbundled CJS and reports the site correctly, so the defect only shows up in a browser extension or any bundler that consumes the published bundles — where the field is documented to name the extractor that ran, and came back asa,iorv.What changed
keep_classnames: /Extractor$/on theTerserPluginminimizer both bundles share, so only the classes the field depends on are kept and the bundle's other classes still minify. Measured cost,npm run build+npm run size:dist/index.js90.2 → 90.4 KB gzip,dist/index.full.js206.9 → 207.1 KB, both inside the budgets inscripts/check-bundle-size.mjs(92 and 215 KB), so no budget change.scripts/check-extractor-names.mjsasserts the built bundles still contain the extractor class names, asnpm run lint:extractor-names, wired into the build job and the release checks next to the size budget. Vitest runs on the TypeScript source, so nothing in the suite could notice this disappearing.I went with the build option rather than a static name per extractor because the latter means touching every extractor and guarding the convention anyway; if you would prefer that shape, say so and I will redo it.
Verification
npm run buildthen a probe that loads the built full bundle with jsdom against a minimal LWN page and printsresult.extractorType:"a"before this change,"lwn"after.npm run lint:extractor-names→ passes with the option, fails (✗ dist/index.js is missing BaseExtractor, GitHubExtractor, YoutubeExtractor) with it removed.npx vitest run→ 789 tests passed. The sixwebsitetest files fail to load in a fresh clone (Cannot find package '@lezer/html',@lezer/highlight) and fail the same way with this change stashed.One path this does not cover:
website/scripts/build.mjsbundles the worker with esbuild (minify: true) and nokeepNames, so the playground and the worker may still see a mangled name. It is a one-line change there, but it is a separate build with its own dependencies, so I left it out of this PR — happy to add it or open a follow-up if you want it.