-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Project References docs/example are missing rootDirs (?) #37257
Comments
I think this may be asking the same thing as #27572 which was closed without a resolution. |
I am embarrassed to ask whether you meant to discuss |
copying from a discussion with Daniel, here's an attempt at a simpler explanation:
foo and bar are separate projects where bar references foo. If the sources for foo (src/foo/abc.ts) aren't present, this currently fails. |
Having chatted on a call, it sounded like you're finding some issue where project references don't play well with a segmented source and output root.
In this scenario, the idea is that // src/foo/abc.ts
import * as def from "../bar/def.js"; Maybe what you were seeing is that in that case, resolution doesn't seem to be jumping to the output
However, I think that at compile-time we must be doing "the right thing" by rebuilding nothing and rechecking against the You can tell that the original let fs = require("fs");
let output = "function foo0() { return 100 }";
for (let i = 1; i < 100000; i++) {
void (output += `function foo${i}() { return foo${i-1}(); }\n`)
}
fs.writeFileSync("./src/bar/def.ts", output + ";export {};") tsc --build ./foo As a side note: the workaround you were trying for not finding the |
It's true that everything is working as intended when the referenced My problem is that those
|
My last caveat there raises a possible solution: always make the I'll leave this open as I still think it's reasonable to expect that module resolution should succeed given the structure on disk I pointed to, and given that Ryan had thought of such a scenario in that It turns out that passing |
Any tips/workarounds here? |
@aryeh-looker if you're asking about using TypeScript with Bazel, you might want to look at https://github.com/aspect-build/rules_ts which no longer needs any |
I'm working on a prototype to rebuild the Bazel TypeScript support on top of Project References, basically following the paragraph
https://www.typescriptlang.org/docs/handbook/project-references.html
where msbuild is replaced by Bazel. Seems very promising so far, however there's a snag.
Looking at Ryan's demo
https://github.com/RyanCavanaugh/project-references-demo
we see that each project uses an
outDir
setting to avoid sprinkling build outputs in the sources (yay)https://github.com/RyanCavanaugh/project-references-demo/blob/master/core/tsconfig.json#L4
However in dependent projects there is no matching
rootDirs
optionhttps://github.com/RyanCavanaugh/project-references-demo/blob/master/animals/tsconfig.json
According to the README, the
empty-sleeves
branch deletes the code from the dependent project, so I would expect TS resolves from the.d.ts
in the outDir. So I'm not understanding how the compiler could find/lib/core/utilities.d.ts
to resolve imports likeimport { makeRandomName } from '../core/utilities';
that appear in/animals/dog.ts
.Indeed checking out the
empty-sleeves
branch, it doesn't seem to compile, seems like it's just out-of-date prototype codeAnother way to observe my problem: In my minimal Proof-of-Concept I am forced to specify a
rootDirs
setting.https://github.com/alexeagle/ts_composite/blob/master/tsconfig-base.json#L7-L8
and in this case since Bazel creates output directory with the platform name in it, I can't really check in this file and keep the project portable between mac/linux/windows.
So the question is, does TS have some way of resolving the outDir from project references that I'm missing? Or is the
rootDirs
setting required to make this work?The text was updated successfully, but these errors were encountered: