-
-
Notifications
You must be signed in to change notification settings - Fork 75
fix: source dts files outputted to outDir #804
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
base: main
Are you sure you want to change the base?
Conversation
d4d076a
to
7c24865
Compare
|
7c24865
to
a4d9238
Compare
output_types.append(s) | ||
else: | ||
# Add DTS inputs that are not transpiled by tsc yet should be copied to the out_dir | ||
# See https://github.com/microsoft/TypeScript/issues/39231 for tsc request to add this feature |
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 tsc doesn't support this... should rules_ts? Overall I feel like this workflow makes sense so it's odd tsc seems to not support it. Does the use of ts within bazel make this issue more common which would justify adding this feature despite tsc not supporting it? (imo the answer is yes)
As I understand it the scenario would be:
src/
a.ts
types.d.ts
Then ts_project(root_dir="src", out_dir="dist")
.
If the types within types.d.ts
are public then the ts_project
output really does need them (because a.d.ts
probably imports types.d.ts
).
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.
Generally the principle here is that we behave the same as tsc
as much as possible.
If someone needs to do this, can't they do it in userspace?
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 think users would have to use copy_to_bin
or ts_project(assets)
to copy the file to the bindir while moving it from rootDir
to outDir
. But then it won't be in JsInfo.types
so it probably won't work when depended on.
That just seems odd. I think this only works outside bazel because the file will still be referenced in src all the time?
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.
That's a lot of "probably" and asking questions, are you asking me to answer those questions?
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 looking for feedback and opinions because I'm uncertain about this change. I don't like adding functionality, but I don't think such a standard use case should require an ugly workaround in userspace.
This also partially (but incorrectly) worked in the past before #746, and it still (correctly) works if out_dir == root_dir
.
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.
So tsc explicitly doesn't not copy .d.ts
files, unlike .js
when allowJs
. This was intentional from the beginning: microsoft/TypeScript#5112 (comment)
Outside bazel this normally isn't an issue because a) no sandboxing (so you can access the .d.ts
even if it isn't outputted to outDir
) and b) pnpm symlinks directly into the source for references between projects so these .d.ts
are available there as well.
In bazel the non-copied .d.ts
are not accessible at all: they are not in the sandbox, they are not in npm packages. Yet they would be copied if in js_library(srcs)
which makes this even more odd...?
#746 changed this logic to align with outputted .js files which I think makes sense. However js also has the
allowJs
logic while dts files do not.Changes are visible to end-users: yes
Test plan