Skip to content

fix(core): skip import-equals namespace aliases in native scanner#34947

Merged
AgentEnder merged 1 commit intomasterfrom
fix/34644-import-equals-scanner
Mar 23, 2026
Merged

fix(core): skip import-equals namespace aliases in native scanner#34947
AgentEnder merged 1 commit intomasterfrom
fix/34644-import-equals-scanner

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

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

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
@FrozenPandaz FrozenPandaz requested a review from a team as a code owner March 21, 2026 04:20
@FrozenPandaz FrozenPandaz requested a review from MaxKless March 21, 2026 04:20
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 21, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 209c2b8
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69be1c853bdb81000822bca0
😎 Deploy Preview https://deploy-preview-34947--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 21, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 209c2b8
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69be1c8517e3990008243a3d
😎 Deploy Preview https://deploy-preview-34947--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Mar 21, 2026

View your CI Pipeline Execution ↗ for commit 209c2b8

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 47m 12s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 8s View ↗
nx-cloud record -- pnpm nx conformance:check ✅ Succeeded 8s View ↗
nx build workspace-plugin ✅ Succeeded 4m 22s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-21 05:16:13 UTC

@AgentEnder AgentEnder merged commit fbc4e63 into master Mar 23, 2026
24 checks passed
@AgentEnder AgentEnder deleted the fix/34644-import-equals-scanner branch March 23, 2026 19:30
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)
@github-actions
Copy link
Copy Markdown
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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native Rust scanner misparses string literals as imports after import = syntax on case-insensitive filesystems (macOS)

2 participants