Skip to content

fix(js-ts): keep the export default Foo; pass linear on comment runs - #24

Merged
maxgfr merged 1 commit into
mainfrom
fix-js-ts-default-id-linear
Sep 30, 2026
Merged

maxgfr merged 1 commit into
mainfrom
fix-js-ts-default-id-linear

Conversation

@maxgfr

@maxgfr maxgfr commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Problem

DEFAULT_ID_RE (added in 7c4a77f, released in v2.31.0) matched the whitespace around an export default Foo; / export = Foo line with \s*. The regex tier blanks comments to spaces and newlines before this pass, so from every line the leading \s* crossed all following blank lines before failing. The pass was quadratic: 20,000 comment lines took ~8 s, 50,000 took ~33 s. A 1.2 MB comment-heavy file went from 50 ms on v2.30.1 to ~12 s, and ultrasec's scan-adapter test timed out.

Fix

Match horizontal whitespace only ([ \t]*) at both ends and end the line on \r?\n, so CRLF files still read. The same 50,000-line input now takes a few ms.

Tests

  • regex-tier.test.ts: export default Foo; and export = Foo in a CRLF file (plus a negative export default Foo.bar;)
  • regex-tier.test.ts: 50,000 comment lines scanned in under 1.5 s. This test fails on main (33 s) and passes with the fix.
  • Rebuilt scripts/engine.mjs / scripts/engine.browser.mjs so check:build stays clean.

DEFAULT_ID_RE matched the whitespace around the line with `\s*`. Comments
are blanked to spaces and newlines before it runs, so from every line the
leading `\s*` crossed all the blank lines after it before failing: 20,000
comment lines took ~8 s, 50,000 ~33 s. Match horizontal whitespace only and
end the line on `\r?\n`, so CRLF files still read.
@maxgfr
maxgfr merged commit 98d9e1b into main Sep 30, 2026
2 checks passed
@maxgfr
maxgfr deleted the fix-js-ts-default-id-linear branch September 30, 2026 17:25
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.31.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant