fix(core): skip import-equals namespace aliases in native scanner#34947
Merged
AgentEnder merged 1 commit intomasterfrom Mar 23, 2026
Merged
fix(core): skip import-equals namespace aliases in native scanner#34947AgentEnder merged 1 commit intomasterfrom
AgentEnder merged 1 commit intomasterfrom
Conversation
The Rust import scanner was mishandling TypeScript's `import X = Y.Z`
namespace alias syntax. After encountering this pattern, it would scan
forward for string literals and treat them as module specifiers, causing
phantom npm dependencies on case-insensitive filesystems (macOS).
Now the scanner checks if an identifier after `import` is followed by
`=`. If so, it distinguishes `import X = require('module')` (valid
CommonJS import) from `import X = Y.Z` (namespace alias to skip).
Fixes #34644
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit 209c2b8
☁️ Nx Cloud last updated this comment at |
AgentEnder
approved these changes
Mar 23, 2026
FrozenPandaz
added a commit
that referenced
this pull request
Mar 26, 2026
…4947) ## Current Behavior The native Rust import scanner mishandles TypeScript's `import X = Y.Z` namespace alias syntax. When it encounters this pattern, it fails to recognize it as a non-module statement and continues scanning forward for string literals, treating the next one it finds as a module specifier. On case-insensitive filesystems (macOS default HFS+/APFS), this causes phantom npm dependencies in the project graph. For example, `import MyBar = Foo.Bar` followed by `case 'Open':` causes `npm:open` to appear as a static dependency because `node_modules/Open` resolves to `node_modules/open`. This makes `@nx/dependency-checks` impossible to satisfy across platforms — macOS and Linux disagree on whether the phantom package is used. ## Expected Behavior `import X = Y.Z` is a TypeScript namespace alias, not a module import. The scanner should skip it entirely. Only actual module imports (`import X = require('module')`, `import ... from 'module'`, etc.) should produce dependency entries. After this fix: - `import X = Y.Z` is correctly identified as a namespace alias and skipped - `import X = require('module')` continues to work as a valid CommonJS import - String literals in switch/case statements and type aliases are no longer misidentified as imports ## Related Issue(s) Fixes #34644 (cherry picked from commit fbc4e63)
Contributor
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Current Behavior
The native Rust import scanner mishandles TypeScript's
import X = Y.Znamespace alias syntax. When it encounters this pattern, it fails to recognize it as a non-module statement and continues scanning forward for string literals, treating the next one it finds as a module specifier.On case-insensitive filesystems (macOS default HFS+/APFS), this causes phantom npm dependencies in the project graph. For example,
import MyBar = Foo.Barfollowed bycase 'Open':causesnpm:opento appear as a static dependency becausenode_modules/Openresolves tonode_modules/open.This makes
@nx/dependency-checksimpossible to satisfy across platforms — macOS and Linux disagree on whether the phantom package is used.Expected Behavior
import X = Y.Zis a TypeScript namespace alias, not a module import. The scanner should skip it entirely. Only actual module imports (import X = require('module'),import ... from 'module', etc.) should produce dependency entries.After this fix:
import X = Y.Zis correctly identified as a namespace alias and skippedimport X = require('module')continues to work as a valid CommonJS importRelated Issue(s)
Fixes #34644