-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: resolve symlinks when checking entrypoint in isMain #666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -99,7 +99,11 @@ export async function writeRouteManifest( | |||||
| export const isMain = (meta: ImportMeta): boolean => { | ||||||
| if (!meta) return false; | ||||||
| if (!process.argv[1]) return false; | ||||||
| return process.argv[1] === fileURLToPath(meta.url); | ||||||
| try { | ||||||
| return fsExtra.realpathSync(process.argv[1]) === fileURLToPath(meta.url); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To ensure maximum robustness, both paths should be resolved to their real paths. If the module itself is loaded via a symlink (which is common in monorepos or when running with
Suggested change
|
||||||
| } catch { | ||||||
| return false; | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ensure maximum robustness, both paths should be resolved to their real paths. If the module itself is loaded via a symlink (which is common in monorepos or when running with
--preserve-symlinks),fileURLToPath(meta.url)might return the symlinked path rather than the real path, causing the comparison to fail. Resolving both sides withfsExtra.realpathSyncguarantees a correct comparison of the actual physical files on disk.