Skip to content

fix(parser): preserve export tokens and empty reexports - #133

Open
BridgeAR wants to merge 2 commits into
mainfrom
BridgeAR/2026-10-05-cjs-export-parity
Open

BridgeAR wants to merge 2 commits into
mainfrom
BridgeAR/2026-10-05-cjs-export-parity

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Oct 6, 2026

Copy link
Copy Markdown
Member

Object-literal detection records getter and async prefixes before checking the following token, so it returns phantom export names. The JavaScript identifier check compares a numeric code point with a string, and Wasm permits a leading identifier escape. The Wasm adapter also discards empty reexport strings through a truthiness check.

@guybedford guybedford left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally: the three fixes are real JS/Wasm parity bugs, the new tests fail on main and pass on this branch in all three test modes, and lib/lexer.wasm rebuilds byte-identical from src/lexer.c. As bug fixes these fit the policy to land.

One inline note on a test that enshrines a bug rather than fixing it.

Comment thread test/_unit.js Outdated
Object-literal detection records getter and async prefixes before checking the
following token, so it returns phantom export names. The JavaScript identifier
check compares a numeric code point with a string, and Wasm permits a leading
identifier escape. The Wasm adapter also discards empty reexport strings
through a truthiness check.

Signed-off-by: Ruben Bridgewater <ruben.bridgewater@datadoghq.com>
An identifier escape in an object property value stops detection before the
parser records its key. Keep the key and stop detecting later properties, as
with member expressions.

Signed-off-by: Ruben Bridgewater <ruben.bridgewater@datadoghq.com>
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-10-05-cjs-export-parity branch from 646a71c to dc088cc Compare October 11, 2026 03:21
@BridgeAR
BridgeAR marked this pull request as ready for review October 11, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants