Skip to content

chore(scripts): enforce 1-1 symbol presence for node/browser/native exports - #2010

Merged
kuhe merged 1 commit into
mainfrom
kuhe/chore/bundlers
May 6, 2026
Merged

chore(scripts): enforce 1-1 symbol presence for node/browser/native exports#2010
kuhe merged 1 commit into
mainfrom
kuhe/chore/bundlers

Conversation

@kuhe

@kuhe kuhe commented May 6, 2026

Copy link
Copy Markdown
Contributor

Issue #, if available:

#1980

Description of changes:

Rather than having the variant indices export differently shaped API surfaces, potentially confusing static analysis (bundlers), all node/browser/native indices will export all symbols, but use const no = Symbol.for("node-only"); for a symbol that is not present in a given environment.

Would this cause problems for browser bundlers?

The symbols that are not available in a particular environment have the value no. This is trivially tree-shakable and will not impact bundling.

This shifts bundling configuration errors from compile-time to runtime, that's bad?

Some bundlers need to verify all expected symbols exist, even though the program will run without them. In this case stubbing the symbol as no helps the program build and run successfully.

We have bundle and browser e2e tests that catch the runtime issues, and the presence of the no Symbol can easily be detected in a bundled file without needing to run it.

@kuhe
kuhe requested a review from a team as a code owner May 6, 2026 16:59
@kuhe
kuhe force-pushed the kuhe/chore/bundlers branch from 1d2623c to d13a6a5 Compare May 6, 2026 17:01
@kuhe
kuhe force-pushed the kuhe/chore/bundlers branch from d13a6a5 to 1693aa7 Compare May 6, 2026 17:15
@kuhe
kuhe merged commit 7fd6ac0 into main May 6, 2026
15 checks passed
@kuhe
kuhe deleted the kuhe/chore/bundlers branch May 6, 2026 17:28
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.

3 participants