Add support for symlinks to fake filesystem #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for symlinks to emulated filesystem in fs.ts. The main motivation is for compiling projects where the
node_modules
folder is heavily symlinked, like with pnpm.The only real changes required were adding
readlink
and updatinglstat
to return the symlink inode entry vs the real file/folder.Only part of this PR that I was having trouble with was updating the web UI to show symlinks in a nice way. I hacked around it by making
resetFileSystem
create symlinks when the file content started with// symlink:
, and that worked pretty nicely. (like here https://esbuild.github.io/try/index.html#YgAwLjIxLjUALS1idW5kbGUKLS1vdXRmaWxlPW91dC5qcwotLXNvdXJjZW1hcAotLW1ldGFmaWxlAGUAZW50cnkudHMALy8gVGhpcyBpbXBvcnQgd2lsbCBiZSBpbmxpbmVkIGJ5IHRoZSBidW5kbGVyCmltcG9ydCB7IHRlc3RGdW5jIH0gZnJvbSAnZm9vJwoKCnRlc3RGdW5jKCk7AABub2RlX21vZHVsZXMALy8gc3ltbGluazogcmVhbF9tb2R1bGVzAAByZWFsX21vZHVsZXMvZm9vL2luZGV4LmpzAGV4cG9ydCBmdW5jdGlvbiB0ZXN0RnVuYygpIHsKICByZXR1cm4gMTsKfQ)