Skip to content

Conversation

@per4uk
Copy link
Contributor

@per4ukper4uk 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-botnodejs-github-bot added the needs-ci PRs that need a full CI run. label Dec 29, 2023
Co-authored-by: Antoine du Hamel <[email protected]>
@aduh95aduh95 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-actionsgithub-actionsbot 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
ContributorAuthor

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

@aduh95aduh95 merged commit d0e4550 into nodejs:mainJan 10, 2024
@aduh95
Copy link
Contributor

Landed in d0e4550

@aduh95
Copy link
Contributor

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#51312Fixes: nodejs#41000 Reviewed-By: Antoine du Hamel <[email protected]>
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#51312Fixes: nodejs#41000 Reviewed-By: Antoine du Hamel <[email protected]>
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: #51312Fixes: #41000 Reviewed-By: Antoine du Hamel <[email protected]>
@marco-ippolitomarco-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: #51312Fixes: #41000 Reviewed-By: Antoine du Hamel <[email protected]>
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: #51312Fixes: #41000 Reviewed-By: Antoine du Hamel <[email protected]>
@richardlaurichardlau mentioned this pull request Mar 25, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.needs-ciPRs 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

@per4uk@nodejs-github-bot@aduh95