-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Use symlinks when looking for module names for declaration emit #24874
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
Use symlinks when looking for module names for declaration emit #24874
Conversation
src/harness/harness.ts
Outdated
|
||
for (const line of lines) { | ||
const testMetaData = optionRegex.exec(line); | ||
if (testMetaData) { | ||
const linkMetaData = linkRegex.exec(line); |
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.
Why match this as both and option and a link? I would recommend moving the const testMetaData …
line into the else branch.
@@ -1244,6 +1247,14 @@ namespace Harness { | |||
|
|||
const docs = inputFiles.concat(otherFiles).map(documents.TextDocument.fromTestFile); | |||
const fs = vfs.createFromFileSystem(IO, !useCaseSensitiveFileNames, { documents: docs, cwd: currentDirectory }); | |||
if (symlinks) { |
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.
If symlinks
were a vfs.FileSet
, you could just call fs.apply(symlinks)
.
src/harness/harness.ts
Outdated
|
||
for (const line of lines) { | ||
const testMetaData = optionRegex.exec(line); | ||
if (testMetaData) { | ||
const linkMetaData = linkRegex.exec(line); | ||
if (linkMetaData) { |
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.
If symlinks
was a vfs.FileSet
, you could just do:
if (!symlinks) symlinks = {};
symlinks[linkMetaData[2].trim()] = new vfs.Symlink(linkMetaData[1].trim());
@rbuckton 👍 👎? |
src/compiler/moduleSpecifiers.ts
Outdated
for (const path of paths) { | ||
const resolved = links.get(path)!; | ||
if (startsWith(target, resolved + "/")) { | ||
const relative = getRelativePathFromFile(resolved + "/file.ts", target, getCanonicalFileName); |
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.
i would create a new a new getRelativePath
that takes two folders.
} | ||
const resolvedtarget = host.getCurrentDirectory ? resolvePath(host.getCurrentDirectory(), target) : target; | ||
if (options) { | ||
options.push(resolvedtarget); // Since these are speculative, we also include the original resolved name as a possibility |
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.
not sure i understand why we are adding the original name?
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.
When we find a symlinked path that we know is correct, we make a choice to ignore the original path and not present is as an option. Since the file in this case wasn't imported directly via a symlink in the compilation already, in this case I think it's more appropriate to keep it around, that way you can still get, eg ./foo
as an option even though module/foo
is possible.
Introduce indirect symlink lookup to specifier deriver Use fileset, move exec vfs path resolution :shakes fist: Apply files symlink relative to dirname Use directory function
e44785d
to
d0c0d1c
Compare
merge conflicts |
@mhegazy Is the fix released with typescript@2.9.2? If so, the problem is getting even worse:
Please note the relative path has two issues:
|
Assuming all those leading @raymondfeng do you have any other path-related settings enabled for your build ( |
My repo is managed by
|
Right, and your TS build settings? |
The |
Including indirect ones (ie, where the directory is linked and the module's resolution came in as anormal resolution through the parent), which previously we would have ignored, even had we used
getModuleSpecifiers
.Fixes #24829
cc @rbuckton for the changes to the compiler harness to support directory/arbitrary symlinks