-
Notifications
You must be signed in to change notification settings - Fork 522
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
Import from parent directory causes: Cannot find module #3284
Comments
https://github.com/bazelbuild/rules_nodejs/wiki/Debugging-problems-with-ts_project is my usual procedure for figuring these out. Adding
and the compilation succeeds. However The reason is the The root cause is the workaround for an upstream TypeScript bug. The workaround is in your tsconfig.json file
However the locations here are for configurations "fastbuild" and "dbg". With transitions, an additional configuration is created, so that list isn't exhaustive anymore. As the error message from Bazel running
the I think the main question here is whether the hash What this really demonstrates is that our workaround for microsoft/TypeScript#37378 is not scaling. We don't want to tell TypeScript an exhaustive list of all the places it needs to look for outputs of the deps (project references in TS lingo). We just told it where those outputs are in the Maybe we can push harder to get some movement there, likely by finding someone in the Bazel community willing to make the PR to typescript, and someone at Microsoft to approve. |
@alexeagle you are a legend! I would have never came to this conclusion. |
Let's keep it open until we're sure the workaround is stable. Based on https://github.com/bazelbuild/bazel/pull/14251/files I think @fmeum is our expert here - Fabian do you have an estimate of how stable these hashes are? If users put |
Those are just cherry-picks of commits by the real expert for this domain, @sdtwigg. But I will try to summarize what I know. Currently, the hash is computed in FunctionTransitionUtil. It is essentially a truncated SHA256 hash of all build settings that have been changed by transitions at some point on the path from the top-level targets to the current target. Using Bazel's Fingerprint class, these hashes could be precomputed for any given set of settings. Doing this from Starlark would be difficult though due to the lack of a SHA256 function. There are ongoing efforts to improve this scheme, e.g., make it less sensitive to configuration changes that are meaningless for the build outputs (see bazelbuild/bazel#14023). The current status seems to be that these changes would be gated behind However, there is one major restriction: These hashes can only be precomputed for the case where the rules_nodejs or rules_docker targets are not themselves subject to transitions coming from a higher-level target. I don't know its use cases well enough to decide whether that can happen, but if it were, the hashes would no longer be static. Summarized: I wouldn't worry about Bazel releases breaking these hashes too much in the short- to mid-term, but the rising adoption of transitions by rulesets could become a more serious problem. I would personally suggest to keep trying to get a change landed into the TS compiler. |
Bumped into the similar issue when trying to upgrade from
I found that now bazel output folders include auto-generated hashes i.e. We have a number of webpack and nextjs targets that rely on this |
@abrmv that hash should be stable, as @fmeum says it's
We're making progress in the root cause issue microsoft/TypeScript#37378 so I'm hopeful we'll get a release of TypeScript where this stops being necessary. |
I can't get it to work even with the |
@alexeagle Would using https://github.com/aspect-build/rules_ts be the solution to this problem? |
I will close this because of inactivity. The best solution would probably be to use https://github.com/aspect-build/rules_ts |
🐞 bug report
Affected Rule
The issue is caused by the rule: ts_project
Is this a regression?
Yes, the previous version in which this bug was not present was: 4.6.1
Description
After upgrading to 5.0, imports from a parent directory (from a different
ts_project
), like below, broke.🔬 Minimal Reproduction
https://github.com/flolu/cannot-find-module
🔥 Exception or Error
The text was updated successfully, but these errors were encountered: