← 输入框|github.com|刷新
Skip to content

fix(vite): resolve a file before a same-named directory - #11464

Merged
NathanWalker merged 2 commits into
mainfrom
fix/vite-resolve-file-before-directory
Sep 29, 2026
Merged

NathanWalker merged 2 commits into
mainfrom
fix/vite-resolve-file-before-directory

Conversation

@triniwiz

Copy link
Copy Markdown
Member

PR Checklist

What is the current behavior?

resolveNativeScriptPlatformFile checks a directory barrel (base/index.<platform>.ext) before the plain file (base.ext). When a package ships both platform.js and a platform/ directory, import './platform' resolves to the directory instead of the file, unlike Node and webpack.

What is the new behavior?

Files come before directories, as in Node and webpack: base.<platform>.ext, then base.ext, then base/index.<platform>.ext. esbuild, which builds the deps bundle, already tries extensions before directories, so only this helper changes.

Tests: packages/vite/helpers/utils.spec.ts (4) covers file-over-directory, platform file over plain file, the directory barrel fallback and no match. The first case fails without the fix.

@nx-cloud

nx-cloud Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit a63c607

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 2m 45s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-09-29 22:04:53 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11464
npm i https://pkg.pr.new/@nativescript/vite@11464
npm i https://pkg.pr.new/@nativescript/webpack@11464

commit: a63c607

@triniwiz
triniwiz force-pushed the fix/vite-resolve-file-before-directory branch from 977256b to f664460 Compare September 28, 2026 04:56
@triniwiz
triniwiz changed the base branch from feat/windows to main September 28, 2026 04:56
The resolver plugins looped extensions outermost, so platform.js next to
platform/index.ios.ts still resolved to the directory on the .ts pass.
@NathanWalker
NathanWalker merged commit 89014ec into main Sep 29, 2026
10 checks passed
@NathanWalker
NathanWalker deleted the fix/vite-resolve-file-before-directory branch September 29, 2026 22:23
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.

2 participants