fix(vite): mask comments before scanning module export names - #11473
Merged
NathanWalker merged 2 commits intoSep 29, 2026
Merged
Conversation
|
View your CI Pipeline Execution ↗ for commit 70357c0
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
A quote inside a regex literal (e.g. /["']/) desynced string tracking, so a later string containing /* or // was treated as a comment and real export declarations were blanked.
NathanWalker
approved these changes
Sep 29, 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.
PR Checklist
What is the current behavior?
extractDirectExportedNamesscans module source forexportdeclarations using regexes over raw text — comments are never masked. A CJS module containing a commented-out declaration such asproduces a phantom export name. Downstream,
expandStarExportsthen emitswhich fails at link time on device because the served module never provides that binding (
SyntaxErrorduring HTTP-ESM instantiation; the boot aborts).Same class of bug exists in
scanModuleExportSurface'sexport */export {} fromregexes and inextractExportMetadata, which scan raw text independently.Real-world trigger:
@nativescript-community/ui-imageshipsindex-common.jswith a commented-out// export const roundRadiusProperty = ...— any app depending on it can't boot a dev session.What is the new behavior?
New
maskJsCommentshelper blanks//and/* */comment regions in-place while leaving string literals untouched (newlines preserved so match positions stay meaningful). Applied insideextractDirectExportedNames(the shared primitive) and at the top ofscanModuleExportSurfaceandextractExportMetadata.Fixes #11471.
Testing note
Added a regression spec in
websocket-star-export-expansion.spec.ts— a star-export target carrying commented-outexportlines no longer leaks the phantom name into the emitted import list. Verified locally via the bundled output (the workspace's full Nx setup wasn't available in my env). Minimal standalone repro: https://github.com/aleclarson/repro/tree/nativescript-11471