Repository navigation
fix(wasm): the types failed to compile without the esnext lib - #130
Merged
Merged
Conversation
The .d.ts files use Symbol.dispose, which TypeScript knows only with lib esnext.disposable, so a project that didn't list it got TS2550. build.sh now puts a reference to that lib at the top of both. The README said free() wasn't needed, as the garbage collector frees what you drop. It does that between turns of the event loop, so a loop that parses and never yields grows memory until it traps, and a node still alive keeps its document. The README now says when to free, with a `using` example, and that WebAssembly memory never shrinks. Smaller fixes: package.json exports ./package.json and has a main; nodeType's docs list 4 and 7; tests/browser.rs names the browser CI uses; the size is the current build's.
- One dependency: the core has two, memchr and url, 34 crates in all. - The C API never crashing: input nested deep enough still overflows the stack, which ends the process. - Hostile inputs in time proportional to length: a few patterns are still quadratic. - The WebAssembly size was an older build's. - The CSS WPT counts left the skipped cases out of the totals; each now says how many were skipped and why.
jamesconwaydev
enabled auto-merge (squash)
November 20, 2026 18:16
foothillsdigital
approved these changes
Nov 20, 2026
foothillsdigital
left a comment
Collaborator
There was a problem hiding this comment.
Checked 04d1d0b:
- The WPT totals add up. 14,758 + 135 + 129 = 15,022. In each of media queries (1,370 + 14 = 1,384), computed values (12,111 + 355 = 12,466) and cascade (1,474 + 199 = 1,673), the new total is the old one plus the skips, so the failures (0, 755, 131) are unchanged.
- Two dependencies:
crates/parsec/Cargo.tomlhasmemchrandurl.cargo tree -p parsec-html-core -e normalhas 35 unique crates including itself, so "34 crates in all" is right. nodeType: the match returns 4 forCdata, 7 forProcessingInstruction, and 11 forFragmentandShadowRoot, as the doc now says.package.json:mainis./node/parsec_html.js, the same file as thenodeexport, andnode/is infiles../package.jsonis exported, and the new test checks both.build.sh: the reference directive goes first in both.d.tsfiles, which is where TypeScript requires it, and the test checks it.- The README's new limits (quadratic attribute and end-tag patterns,
<template>nesting overflowing the stack) are honest, and the C API claim no longer overstates it. The WASM README'susingexample frees the node and its document, as its text says it must.
Approving.
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.
Problem
.d.tsfiles useSymbol.dispose. TypeScript only knows that withlib: esnext.disposable, so a project that doesn't list it failed with TS2550.free(), because the garbage collector frees what you drop. The collector does that between turns of the event loop, though. A loop that parses page after page without yielding grows WebAssembly memory until it traps at 4 GB. A node that's still alive also keeps its whole document. And WebAssembly memory never shrinks, which the README didn't say.package.jsondidn't export./package.json, had nomain, thenodeTypedocs left out 4 and 7, andtests/browser.rsnamed Chrome where CI runs Firefox.memchrandurl), a C API that never crashes (deep<template>nesting still overflows the stack), hostile inputs in time proportional to their length (a few patterns are still quadratic), a WebAssembly size from an older build, and CSS WPT totals that left out the skipped cases.Change
build.shputs/// <reference lib="esnext.disposable" />at the top of both.d.tsfiles.using, with an example. It also says memory only grows. Measured with the current build: sixty 2 MB pages in one loop, reading a node from each, reach 1.4 GB of WebAssembly memory without frees and 40 MB with them. Freeing only the document leaves it at 1.4 GB.package.jsongains"./package.json"inexportsand"main": "./node/parsec_html.js"; thenodeTypedoc comment lists every value it returns;tests/browser.rssays how CI runs it.Tests
tests/package.test.mjs: both.d.tsfiles start with the reference;parsec-html/package.jsoncan be required andmainresolves to the filerequiregets.tsc7.0.2: a consumer withlib: ["es2022", "dom"]compiles against the new package, and fails with TS2550 once the reference line is removed.wasm-pack test --node,cargo clippy --target wasm32-unknown-unknown --all-targets -- -D warnings,cargo fmt --check,./build.shandnode --test tests/package.test.mjs(13 of 13).