Skip to content

Commit 74d54bd

Browse files
authored
refactor: update to rules_js 1.0.0-rc.4 (#113)
1 parent 5f8079f commit 74d54bd

File tree

13 files changed

+81
-66
lines changed

13 files changed

+81
-66
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ module(
88

99
bazel_dep(name = "bazel_skylib", version = "1.1.1")
1010
bazel_dep(name = "rules_nodejs", version = "5.5.0")
11-
bazel_dep(name = "aspect_rules_js", version = "0.13.0")
11+
bazel_dep(name = "aspect_rules_js", version = "0.14.0")
1212
bazel_dep(name = "aspect_bazel_lib", version = "1.9.2")

docs/repositories.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/rules.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ npm_link_package(
2222
src = "//examples/deps_lib",
2323
root_package = "examples",
2424
visibility = ["//examples:__subpackages__"],
25-
# TODO: propagate this dependency from //examples/deps_lib: https://github.com/aspect-build/rules_ts/issues/96
26-
deps = {":.aspect_rules_js/node_modules/date-fns/2.29.1": ""},
2725
)
2826

2927
# This macro expands to a npm_link_package for each third-party package in package.json

examples/deps_lib/BUILD.bazel

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ ts_config(
1010
ts_project(
1111
name = "deps_ts",
1212
srcs = ["index.ts"],
13+
data = [
14+
# Also propagate the date-fns npm package downstream so it is an runtime dependency
15+
# of any linked npm_package that this target is used by.
16+
"//examples:node_modules/date-fns",
17+
],
1318
declaration = True,
1419
# TODO: fix worker mode flaky bug when there are multiple ts_project targets in a package
1520
supports_workers = False,
@@ -23,10 +28,6 @@ npm_package(
2328
name = "deps_lib",
2429
srcs = [
2530
":deps_ts",
26-
# TODO: This seems undesirable to have to specify the transitive closure of ts_project
27-
# targets. However, if npm_package is meant to use DefaultInfo then this _is_ technically
28-
# the correct behavior.
29-
"//examples/deps_lib:b",
3031
],
3132
package = "@myorg/deps_lib",
3233
visibility = ["//examples:__subpackages__"],

ts/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ bzl_library(
1515
"@aspect_rules_js//js:defs",
1616
"@bazel_skylib//lib:partial",
1717
"@bazel_skylib//rules:build_test",
18-
"@rules_nodejs//nodejs/private:bzl", # keep
1918
],
2019
)
2120

ts/defs.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def ts_project(
400400
native.filegroup(
401401
name = typecheck_target_name,
402402
srcs = [tsc_target_name],
403-
# This causes the DeclarationInfo to be produced, which in turn triggers the tsc action to typecheck
403+
# This causes the declarations to be produced, which in turn triggers the tsc action to typecheck
404404
output_group = "types",
405405
**common_kwargs
406406
)
@@ -416,7 +416,7 @@ def ts_project(
416416
js_library(
417417
name = name,
418418
# Include the tsc target in srcs to pick-up both the direct & transitive declaration outputs so
419-
# that this js_library can be a valid dep for downstream ts_project or other DeclarationInfo-aware rules.
419+
# that this js_library can be a valid dep for downstream ts_project or other rules_js derivative rules.
420420
srcs = js_outs + map_outs + [tsc_target_name],
421421
deps = deps,
422422
**common_kwargs

ts/private/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ bzl_library(
2424
":ts_validate_options",
2525
"@aspect_bazel_lib//lib:copy_to_bin",
2626
"@aspect_bazel_lib//lib:utils",
27+
"@aspect_rules_js//js:libs",
28+
"@aspect_rules_js//js:providers",
2729
"@bazel_skylib//lib:dicts",
28-
"@rules_nodejs//nodejs/private/providers:bzl", # keep
2930
],
3031
)
3132

@@ -40,7 +41,7 @@ bzl_library(
4041
name = "ts_lib",
4142
srcs = ["ts_lib.bzl"],
4243
visibility = ["//ts:__subpackages__"],
43-
deps = ["@rules_nodejs//nodejs:bzl"], # keep
44+
deps = ["@aspect_rules_js//js:providers"],
4445
)
4546

4647
bzl_library(

ts/private/npm_repositories.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def _http_archive_version_impl(rctx):
2626
elif "dependencies" in p.keys() and "typescript" in p["dependencies"]:
2727
ts = p["dependencies"]["typescript"]
2828
else:
29-
fail("key `typescript` not found in either dependencies or devDependencies of %s" % json_path)
29+
fail("key 'typescript' not found in either dependencies or devDependencies of %s" % json_path)
3030
if any([not seg.isdigit() for seg in ts.split(".")]):
3131
fail("""typescript version in package.json must be exactly specified, not a semver range: %s.
32-
You can supply an exact `ts_version` attribute to `rules_ts_dependencies` to bypass this check.""" % ts)
32+
You can supply an exact 'ts_version' attribute to 'rules_ts_dependencies' to bypass this check.""" % ts)
3333
version = ts
3434

3535
if rctx.attr.integrity:
@@ -38,7 +38,7 @@ def _http_archive_version_impl(rctx):
3838
integrity = TS_VERSIONS[version]
3939
else:
4040
fail("""typescript version {} is not mirrored in rules_ts, is this a real version?
41-
If so, you must manually set `ts_integrity`.
41+
If so, you must manually set 'ts_integrity'.
4242
See documentation on rules_ts_dependencies.""".format(version))
4343

4444
rctx.download_and_extract(
@@ -70,7 +70,7 @@ http_archive_version = repository_rule(
7070
# buildifier: disable=function-docstring
7171
def npm_dependencies(ts_version_from = None, ts_version = None, ts_integrity = None):
7272
if (ts_version and ts_version_from) or (not ts_version_from and not ts_version):
73-
fail("""Exactly one of `ts_version` or `ts_version_from` must be set.""")
73+
fail("""Exactly one of 'ts_version' or 'ts_version_from' must be set.""")
7474

7575
maybe(
7676
http_archive,

ts/private/ts_lib.bzl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"Utilities functions for selecting and filtering ts and other files"
22

3-
load("@rules_nodejs//nodejs:providers.bzl", "DeclarationInfo")
3+
load("@aspect_rules_js//js:providers.bzl", "JsInfo")
4+
load("@aspect_rules_js//js:libs.bzl", "js_lib_helpers")
45

56
ValidOptionsInfo = provider(
67
doc = "Internal: whether the validator ran successfully",
@@ -12,7 +13,7 @@ ValidOptionsInfo = provider(
1213

1314
# Targets in deps must provide one or the other of these
1415
DEPS_PROVIDERS = [
15-
[DeclarationInfo],
16+
[JsInfo],
1617
[ValidOptionsInfo],
1718
]
1819

@@ -21,11 +22,7 @@ STD_ATTRS = {
2122
"args": attr.string_list(
2223
doc = "https://www.typescriptlang.org/docs/handbook/compiler-options.html",
2324
),
24-
"data": attr.label_list(
25-
doc = "Runtime dependencies to include in binaries/tests that depend on this TS code",
26-
default = [],
27-
allow_files = True,
28-
),
25+
"data": js_lib_helpers.JS_LIBRARY_DATA_ATTR,
2926
"declaration_dir": attr.string(
3027
doc = "https://www.typescriptlang.org/tsconfig#declarationDir",
3128
),

0 commit comments

Comments
 (0)