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

fix(core): resolve symbolic links #879

Merged
merged 1 commit into from
Mar 8, 2025

Conversation

nabetti1720
Copy link
Contributor

@nabetti1720 nabetti1720 commented Mar 8, 2025

Issue # (if available)

Fixed #875

Description of changes

Fixed an issue where paths could not be resolved correctly in require/import when the base path contained a symbolic link.

% pwd
/Users/shinya/Workspaces/llrt-test/symlink

% ls -lFa .    
total 16
drwxr-xr-x   5 shinya  staff   160  3  8 22:36 ./
drwxr-xr-x  90 shinya  staff  2880  3  8 12:27 ../
-rw-r--r--   1 shinya  staff    72  3  8 12:28 bar.js
drwxr-xr-x   7 shinya  staff   224  3  8 22:37 bin/
-rw-r--r--   1 shinya  staff    42  3  8 22:29 foo.js

% ls -lFa bin
total 16
drwxr-xr-x  7 shinya  staff  224  3  8 22:37 ./
drwxr-xr-x  5 shinya  staff  160  3  8 22:36 ../
lrwxr-xr-x  1 shinya  staff   54  3  8 22:37 absolute@ -> /Users/shinya/Workspaces/llrt-test/symlink/bin/hoge.js
lrwxr-xr-x  1 shinya  staff    9  3  8 12:29 foo@ -> ../foo.js
-rw-r--r--  1 shinya  staff   75  3  8 22:26 fuga.js
lrwxr-xr-x  1 shinya  staff    9  3  8 22:31 hoge@ -> ./hoge.js
-rw-r--r--  1 shinya  staff   45  3  8 22:30 hoge.js
File contents
% cat bin/fuga.js
function fuga() {
    console.log('fuga.js');
}
module.exports = {
    fuga
};

% cat bin/hoge.js
const { fuga } = require("./fuga");

fuga();

cat bar.js
function bar() {
    console.log('bar.js');
}
module.exports = {
    bar
};

% cat foo.js
const { bar } = require("./bar");

bar();

Result:

% llrt bin/foo
bar.js

% llrt bin/hoge
fuga.js

% llrt bin/absolute 
fuga.js

NOTE:
I couldn't create a reproducible environment in the fixtures directory because it contains symbolic links, so I couldn't write test code.

Checklist

  • Created unit tests in tests/unit and/or in Rust for my feature if needed
  • Ran make fix to format JS and apply Clippy auto fixes
  • Made sure my code didn't add any additional warnings: make check
  • Added relevant type info in types/ directory
  • Updated documentation if needed (API.md/README.md/Other)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Collaborator

@richarddavison richarddavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@richarddavison richarddavison merged commit e4d51e3 into awslabs:main Mar 8, 2025
11 checks passed
@nabetti1720 nabetti1720 deleted the fix/resolver branch March 8, 2025 21:33
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.

symlink is not resolved
2 participants