Skip to content

Commit

Permalink
Revert "fix(builtin): add transitive typings to runfiles provider pro…
Browse files Browse the repository at this point in the history
…duced by js_library (#2547)"

This wasn't actually a fix - it causes type-checking to happen eagerly
when a js_library target is built, even if the typings aren't needed.

This prevents a transpile-only dev workflow.

As noted in the PR #2547
this is easily accomplished in tsc_test by explicitly gathering typings
inputs with output_group = types

This reverts commit 41117fa.
  • Loading branch information
alexeagle committed Jan 6, 2022
1 parent dc0dc8f commit 0eb6587
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/TypeScript.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ type-checking and not for producing any build outputs.
To use it, add the load statement `load("@npm//typescript:index.bzl", "tsc_test")` to your BUILD file.
(Possibly replacing `@npm` with the name of the repository where you installed dependencies)

To get the typings available in the test (as "runfiles"), you may need to gather them from dependencies if they
are not included as default outputs of those dependencies, like so:

```starlark
filegroup(name = "types", srcs = ["//some:js_library"], output_group = "types")
```

And then include the `:types` target in the `data` of the `tsc_test`.

See example in https://github.com/bazelbuild/rules_nodejs/tree/stable/packages/typescript/test/tsc_test

### Option 3: ts_project
Expand Down
2 changes: 1 addition & 1 deletion internal/js_library/js_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def _impl(ctx):
runfiles = ctx.runfiles(
files = all_files,
transitive_files = depset(
transitive = files_depsets + typings_depsets,
transitive = files_depsets,
),
)
deps_runfiles = [d[DefaultInfo].default_runfiles for d in ctx.attr.deps]
Expand Down
9 changes: 9 additions & 0 deletions packages/typescript/index.docs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ type-checking and not for producing any build outputs.
To use it, add the load statement `load("@npm//typescript:index.bzl", "tsc_test")` to your BUILD file.
(Possibly replacing `@npm` with the name of the repository where you installed dependencies)
To get the typings available in the test (as "runfiles"), you may need to gather them from dependencies if they
are not included as default outputs of those dependencies, like so:
```starlark
filegroup(name = "types", srcs = ["//some:js_library"], output_group = "types")
```
And then include the `:types` target in the `data` of the `tsc_test`.
See example in https://github.com/bazelbuild/rules_nodejs/tree/stable/packages/typescript/test/tsc_test
### Option 3: ts_project
Expand Down

0 comments on commit 0eb6587

Please sign in to comment.