chore(scripts): enforce 1-1 symbol presence for node/browser/native exports - #2010
Merged
Conversation
siddsriv
approved these changes
May 6, 2026
trivikr
approved these changes
May 6, 2026
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.
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
nohelps the program build and run successfully.We have bundle and browser e2e tests that catch the runtime issues, and the presence of the
noSymbol can easily be detected in a bundled file without needing to run it.