A script whose type was the module keyword with spaces around it was listed as a classic script, and a whitespace-only type was listed too, although browsers run neither. The keyword and the empty attribute are now matched exactly, before the whitespace trimming that classic script types get. Checked in a Chromium 156 page: padded and tab-prefixed module types and a whitespace-only type did not run.
On the lexer fallback, `import("./data.json", { with: { type: "json" } })` lost its dependency, because only a closing parenthesis was accepted after the path. A comma after a dynamic import's literal path is now accepted, and a method called `import` on an object is no longer taken for one.
The operation reader accepted a raw CR inside a regular quoted GraphQL string, and a raw line break after a backslash, both invalid GraphQL. Both line terminators are now checked before an escape is processed; block strings keep their multi-line grammar.
Browsers also close a comment at `--!>`, `<!-->` and `<!--->`. The scanner looked only for `-->`, so it missed scripts and preloads after such a comment. It now resumes at the first ending a browser recognises, and still hides what is inside ordinary and unfinished comments.
Recovering `with ({undefined: 42}) { result = void 0; }` rewrote `void 0` to `undefined`, which the `with` object can supply, changing the result. Files containing a `with` statement keep their `void` expressions; other rewrites stay on.
The lexer fallback reported `const hook = trpc.users.list.useQuery` as a client call although it only reads a property. An opening call parenthesis (or an optional call) is now required.
The lexer fallback read `require("./\141pp.js")` as a different module path and mis-decoded zero-padded braced Unicode escapes. Legacy octal escapes, every escaped line terminator and braced escapes of any length are now decoded, with checked arithmetic.
A comment between an operation keyword and its name hid the name, and a parenthesis inside a header comment could hide the whole operation. Comments and ignored separators are now skipped before header tokens are read.
The lexer fallback, used for sources too large or too deep to parse, dropped side-effect imports such as import "./polyfill.js", which the syntax-tree path records. A string straight after the import keyword is now recorded as a static dependency with its location. Every fallback import goes through one helper that marks the list truncated past its cap and records a .node specifier as a native module, as the syntax-tree pass does.
A banner such as /*! @scope/pkg@1.2.3 */ was recorded as package pkg, losing its scope. A word that starts with @ now keeps its slash, so @scope/pkg@1.2.3 and @scope/pkg v1.2.3 keep the full name; every other word is still split on slashes, so a banner that names a package by its URL reads as before.
Recovering a webpack factory renames its parameters (e, t, n) to module, exports and __webpack_require__, but code inside a direct eval still used the old names, so the recovered factory threw a ReferenceError. A factory with a possible direct eval call now keeps its parameter names; indirect and optional eval calls, and mere mentions of eval, still allow the rename.
A URL with no path has its first slash in the query or fragment, so https://auth.example.test?next=/graphql was read as a GraphQL endpoint; and a :// in a query made /api/graphql?next=https://x.test lose its path. A scheme now counts only before any /, ? or #, the host ends at the first of those, and run-time text in a partly literal URL ends neither.
Text read through constants joined both sides of every + as written, so '/v' + (1 + 2) read as /v12 and '/w' + 0x10 as /w0x10, both marked literal. Two numbers now add, a number literal reads as JavaScript turns it into text (0x10 is 16), and a + whose sides are neither known text nor two numbers is no longer reported as literal.
A push of [[ids], {one property}] was read as a webpack chunk whatever the object held, so ordinary code such as queue.push([[1], { callback }]) became a webpack module and marked the file as bundled. A one-property object now counts only when the property is a module factory and the file names webpack or uses its chunk-global push.
An export list marked functions exported by name among those seen so far: a list before the declaration marked nothing, and one after it marked every function of that name, nested ones included. Listed names are now resolved to bindings and matched to functions after the walk, whether the function was declared, initialised a variable or was assigned to one.
.cts and .mts got the same source type as .ts, where the parser decides between module and script from the syntax, so their reported source kind could be wrong. As in Node and TypeScript, .cts is now always CommonJS and .mts always an ES module.
Four shapes still estimated one or two levels and then overflowed the parser's stack: an else-if chain whose links end with ";", a class extends chain, a run of prefix ++, and brackets hidden in a false regex after an update operator or a member name. The estimate now counts each, and "/" after those tokens is read as division. A regex after yield is read only when it closes on the line; its brackets and operators are counted too, and a source where the regex and division readings can't be told apart takes the lexer fallback.
Concatenating a constant with itself doubled its text with each declaration, so a file under 1 KB could ask for gigabytes. Text built from several parts is now at most 4 KiB, and all constants in a file share a budget of the source's size plus 1 MiB; longer text reads as not literal. A redeclared name drops its earlier value once the new initializer has been read.
Calls, index reads and tagged templates that follow one another, and labels in a row, each nest the syntax tree one level, but the estimate stayed flat, so a source with millions of links was sent to the parser and overflowed its stack. The estimate now counts each link, keeps the count across a closed bracket the expression goes on after, and skips comments. The tokenizer also treats JavaScript's non-ASCII spaces and the vertical tab as whitespace.
The JavaScript analyzer had its own copy of the sourceMappingURL reader, which missed #1731's fix: it now uses the formats one, so the no-space annotation is found, tabs and repeated spaces are accepted, a URL with whitespace is refused, and an annotation up to 64 lines from the end is seen, on the parsed and lexer paths alike.
When a bundle is too large or can't be parsed, the token-level fallback now caps its fetch calls, URL literals and exposeInMainWorld objects at the same list limit the syntax-tree pass uses, and records endpoints as truncated when a fetch call is dropped, so a huge bundle can't grow those lists without limit.
The tokenizer matched punctuators against a four-byte string window, which came out empty when it ended inside a multi-byte character, so a===日本 split the operator. It now matches on the bytes from that point, so ===, >>, => and !== stay whole before any character.
The tokenizer split 1e+5 and 2.5E-3 into three tokens, because a number ended at the sign. A + or - right after e or E, followed by a digit, now stays in the number, except in hex, binary and octal literals, where 0x1e+5 is still 0x1e, +, 5.
The token scanner ended `//` comments only at LF. A bare CR, U+2028 or U+2029 therefore hid following executable code inside the comment. That dropped imports, IPC and fetch facts in lexer fallback and prevented the parser admission check from seeing excessive nesting after the comment. Recognize every JavaScript line terminator when scanning line comments, skip Unicode terminators before charging the token budget, and stop identifiers at those boundaries. Strings, templates and block comments keep their existing handling.
A module keyed by `0x10` and a loader call written as `16` produced different identities. Numeric separators and exponent notation caused the same problem, including dangling `requires` targets in the application graph. Different spellings of one numeric dependency could also occupy separate list entries. Use the existing syntax library's JavaScript number conversion for numeric module keys, loader arguments, browserify mappings and chunk IDs. Explicitly enable its already-present `to_js_string` feature. String identifiers retain their literal spelling, including strings such as `"0x10"` that identify a different property from numeric `0x10`.
A webpack wrapper can have a loader parameter named `r` while a nested function uses its own unrelated parameter with the same spelling. The dependency visitor treated both calls as module loads, adding false `requires` edges to the application graph. Resolve loader calls against the wrapper parameter's semantic binding. This retains closures that capture the real loader, distinguishes function/arrow parameters, block and catch bindings, and avoids treating the placeholder for a destructured parameter as an actual loader name. First-seen ordering and dependency deduplication stay intact.
Recovered modules are named after their sanitized id, and a collision added eight characters of the content hash once. Three modules with the same id and body gave the second and third the same path, so extraction refused the third and left that module out; a later module's id could also equal an earlier generated name. Each generated name is now checked against the names already used: the first collision keeps its existing name, and any further one gets an occurrence suffix.
Unminifying split a comma sequence into separate statements, so in function f(){"hello","use strict";return this;} the two strings became a directive prologue, turned on strict mode and changed what this is. A sequence that starts with a string literal now stays together, and ordinary call sequences still split. Tests cover function and script bodies.
HTML inspection returned a page title as written in the source, so <title>Fish & Chips</title> read "Fish & Chips". The title now goes through the existing character-reference decoder once before the 200-character limit. Unknown references stay as written, and the limit counts the decoded characters.
Whitespace no longer counts against the tokenizer's limit, a CRLF line continuation stays in its string, and unescape handles CR and CRLF continuations, \b, \f and \v, and \u surrogate pairs.
Supersedes #1197, #1194, #1188, #1154 and #1148.
Co-authored-by: NetterSilver <133535268+Silvertree2010@users.noreply.github.com>
JavaScript analysis reads a source map comment from the last eight lines of the whole script and keeps its full URL, so originals are restored from large inline source maps.
Replays #591–#596. The HTML scanner reads rel token lists, decodes asset URLs once, keeps script and title text through lookalike closing tags, and skips raw-text elements, markup inside attribute values and custom tag names.
Co-authored-by: Afloat <132809511+Afloat16@users.noreply.github.com>