-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Use project relative preference for declaration emit #42232
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
Conversation
@typescript-bot test this |
Heya @sheetalkamat, I've started to run the extended test suite on this PR at 85db43e. You can monitor the build here. |
Heya @sheetalkamat, I've started to run the parallelized community code test suite on this PR at 85db43e. You can monitor the build here. |
@@ -191,7 +191,9 @@ namespace ts.moduleSpecifiers { | |||
} | |||
|
|||
if (relativePreference === RelativePreference.ExternalNonRelative) { | |||
const projectDirectory = host.getCurrentDirectory(); | |||
const projectDirectory = compilerOptions.configFilePath ? |
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.
This change is so that it actually uses directory of tsconfig file and not random directory where tsc is invoked from. (eg in test added the current directory is "/")
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
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 added project-relative
as a way to use somewhat looser heuristics for auto-import paths than we do in the compiler generally, namely the existence of package.json files in source directories, which otherwise tsc
would never care about unless node module resolution for a bare specifier resolved to that directory. Does #42224 not fully solve the issue? That is a much more explainable fix, if nothing else, and seems to fit nicely with an existing ethos of reusing input nodes and paths elsewhere in the transformers/emitter.
It does solve the issue but only if file was imported in the file, not otherwise. This would give use better paths in declaration emit. interesting thing is it didn't break anything so i wonder if this is better behavior for those derived paths. may be it is better option if importing file is project reference redirect? |
Please try to avoid making declaration emit dependent on whether the source/destination crosses a boundary expressed specifically as a project reference. Our higher-level tooling (think Lerna etc) constructs multi-project workspaces dynamically. The workspace is just a list of packages you want to develop together live - and the user adds and removes packages frequently in the course of developing or debugging an issue. Meaning a project might have no project references one minute (because it is being built in isolation and so only links to static/published declarations for dependencies via It would be odd if this lightweight switching action resulted in different behavior in declaration emit. |
@typescript-bot pack this |
Heya @sheetalkamat, I've started to run the tarball bundle task on this PR at 28d3a36. You can monitor the build here. |
Hey @sheetalkamat, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@sheetalkamat is this obsolete now that #42224 is in? Or is it worth continuing on? If so, is it ready for review? I couldn't tell from skimming the conversation. |
I dont think this is absolete. There is #42349 which might need this so need to investigate further and add test before this is ready for review. |
28d3a36
to
9d1b450
Compare
@andrewbranch @weswigham i think we should take this PR as this does help many scenarios.. Eg #42349 where there are no project references or |
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’m not completely confident that project-relative
will produce correct results 100% of the time, but I do think it will be better on average. It’s probably fine to move forward and iterate on this if we get feedback about it.
Was fixed upstream in microsoft/TypeScript#42232
Fixes #42349