Skip to content
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

lib: fix --preserve-symlinks-main #51312

Merged
merged 3 commits into from
Jan 10, 2024
Merged

lib: fix --preserve-symlinks-main #51312

merged 3 commits into from
Jan 10, 2024

Conversation

per4uk
Copy link
Contributor

@per4uk per4uk commented Dec 29, 2023

lib: fix --preserve-symlinks-main

When the --preserve-symlinks-main flag is used when running a node, the main file path is resolved to the target path instead of the symlink path. This cause issues with relative imports. This problem occurs when the called symlink does not contain a file extension(i.e. node package, node package/file).

In the loader.js file, there is a function called tryExtensions which in turn calls tryFile. The tryFile function originally only had a check for the --preserve-symlinks flag, so I have added a check for --preserve-symlinks-main as well.

Fixes: #41000

Fixed resolving relative imports when symlink to main file called without file extension

Fixies: nodejs#41000
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Dec 29, 2023
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Dec 30, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 30, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@per4uk
Copy link
Contributor Author

per4uk commented Jan 10, 2024

Is it necessary to amend the commit message, or will it be fixed during the merge process?

@aduh95 aduh95 merged commit d0e4550 into nodejs:main Jan 10, 2024
52 of 53 checks passed
@aduh95
Copy link
Contributor

aduh95 commented Jan 10, 2024

Landed in d0e4550

@aduh95
Copy link
Contributor

aduh95 commented Jan 10, 2024

Is it necessary to amend the commit message, or will it be fixed during the merge process?

Collaborators can specify a different commit message by landing manually the PR. If you fix it yourself, we can use automation to land the PR quicker, but it's no biggie. Thanks for the contribution!

marco-ippolito pushed a commit to marco-ippolito/node that referenced this pull request Jan 12, 2024
Fixes resolving main module when the `argv[1]` was pointing to a symlink
without its file extension.

PR-URL: nodejs#51312
Fixes: nodejs#41000
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Medhansh404 pushed a commit to Medhansh404/node that referenced this pull request Jan 19, 2024
Fixes resolving main module when the `argv[1]` was pointing to a symlink
without its file extension.

PR-URL: nodejs#51312
Fixes: nodejs#41000
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
targos pushed a commit that referenced this pull request Feb 15, 2024
Fixes resolving main module when the `argv[1]` was pointing to a symlink
without its file extension.

PR-URL: #51312
Fixes: #41000
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@marco-ippolito marco-ippolito mentioned this pull request Mar 1, 2024
richardlau pushed a commit that referenced this pull request Mar 25, 2024
Fixes resolving main module when the `argv[1]` was pointing to a symlink
without its file extension.

PR-URL: #51312
Fixes: #41000
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
richardlau pushed a commit that referenced this pull request Mar 25, 2024
Fixes resolving main module when the `argv[1]` was pointing to a symlink
without its file extension.

PR-URL: #51312
Fixes: #41000
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@richardlau richardlau mentioned this pull request Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--preserve-symlinks-main doesn't work
3 participants