Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit ec4b8a4

Browse files
gregmagolanalexeagle
authored andcommitted
Update to new npm fined grained deps targets
Closes #295 PiperOrigin-RevId: 215735317
1 parent e067308 commit ec4b8a4

File tree

25 files changed

+154
-130
lines changed

25 files changed

+154
-130
lines changed

BUILD.bazel

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ gazelle(
4141
js_library(
4242
name = "protobufjs_bootstrap_scripts",
4343
srcs = [
44-
"@build_bazel_rules_typescript_protobufs_compiletime_deps//:node_modules/long/dist/long.js",
45-
"@build_bazel_rules_typescript_protobufs_compiletime_deps//:node_modules/protobufjs/dist/minimal/protobuf.min.js",
44+
"@build_bazel_rules_typescript_protobufs_compiletime_deps//node_modules/long:dist/long.js",
45+
"@build_bazel_rules_typescript_protobufs_compiletime_deps//node_modules/protobufjs:dist/minimal/protobuf.min.js",
4646
],
4747
# Make devmode loading work when it does require("protobufjs/minimal")
4848
# so this is shimmed to define it to equal global.protobuf
@@ -56,15 +56,15 @@ js_library(
5656
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
5757

5858
# A nodejs_binary for @bazel/typescript/tsc_wrapped to use by default in
59-
# ts_library that depends on @npm//:@bazel/typescript instead of the
59+
# ts_library that depends on @npm//@bazel/typescript instead of the
6060
# output of the //internal/tsc_wrapped ts_library rule. This
61-
# default is for downstream users that depend on the @bazel/karma npm
62-
# package. The generated @npm//:@bazel/typescript/tsc_wrapped target
61+
# default is for downstream users that depend on the @bazel/typescript npm
62+
# package. The generated @npm//@bazel/typescript/bin:tsc_wrapped target
6363
# does not work because it does not have the node `--expose-gc` flag
6464
# set which is required to support the call to `global.gc()`.
6565
nodejs_binary(
6666
name = "@bazel/typescript/tsc_wrapped",
67-
data = ["@npm//:@bazel/typescript"],
67+
data = ["@npm//@bazel/typescript"],
6868
entry_point = "@bazel/typescript/tsc_wrapped/tsc_wrapped.js",
6969
install_source_map_support = False,
7070
templated_args = ["--node_options=--expose-gc"],

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ ts_library(
183183
name = "my_code",
184184
srcs = glob(["*.ts"]),
185185
deps = [
186-
"@npm//:@types/node",
187-
"@npm//:@types/foo",
188-
"@npm//:foo",
186+
"@npm//@types/node",
187+
"@npm//@types/foo",
188+
"@npm//foo",
189189
"//path/to/other:library",
190190
],
191191
)
192192
```
193193

194-
You can also you the `@npm//:@types` target which will include all
194+
You can also you the `@npm//@types` target which will include all
195195
packages in the `@types` scope as dependencies.
196196

197197
If you are using self-managed npm dependencies, you can use the

WORKSPACE

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,15 @@ yarn_install(
4242
# Install a hermetic version of node.
4343
node_repositories(preserve_symlinks = True)
4444

45+
# Note: We depend on @bazel/typescript in package.json
46+
# so that the target @npm//@bazel/typescript is defined
47+
# as it is referenced in /BUILD.bazel for use downstream.
48+
# This target and package is not used locally so
49+
# the version of this dependency does not matter.
4550
yarn_install(
4651
name = "npm",
4752
package_json = "//:package.json",
4853
yarn_lock = "//:yarn.lock",
49-
manual_build_file_contents = """
50-
filegroup(
51-
name = "@bazel/typescript",
52-
srcs = [],
53-
)
54-
55-
filegroup(
56-
name = "@bazel/karma",
57-
srcs = [],
58-
)
59-
""",
6054
)
6155

6256
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")

examples/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ ts_library(
4040
":foo_ts_library",
4141
"//examples/generated_ts",
4242
"//examples/some_library:lib",
43-
"@npm//:typescript",
44-
# Example of using the `@npm//:@types` target to depend on all
43+
"@npm//typescript",
44+
# Example of using the `@npm//@types` target to depend on all
4545
# @types packages and with the types attribute of tsconfig not
4646
# specified. In this case, typescript will automatically discover
4747
# all types under node_modules/@types and included them in the compile.
4848
# See getAutomaticTypeDirectiveNames in
4949
# https://github.com/Microsoft/TypeScript/blob/master/src/compiler/moduleNameResolver.ts.
50-
"@npm//:@types",
50+
"@npm//@types",
5151
],
5252
)
5353

examples/app/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ ts_library(
4141
srcs = ["app_e2e_test.ts"],
4242
tsconfig = "//examples:tsconfig-test",
4343
deps = [
44-
"@npm//:@types/jasmine",
45-
"@npm//:@types/node",
46-
"@npm//:protractor",
44+
"@npm//@types/jasmine",
45+
"@npm//@types/node",
46+
"@npm//protractor",
4747
],
4848
)

examples/googmodule/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jasmine_node_test(
2020
srcs = ["googmodule_output_test.js"],
2121
data = [
2222
":es5_output",
23-
"@npm//:jasmine",
23+
"@npm//jasmine",
2424
],
2525
)

examples/protocol_buffers/BUILD.bazel

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ ts_library(
3131
tsconfig = "//examples:tsconfig-test",
3232
deps = [
3333
":car",
34-
"@npm//:@types/jasmine",
35-
"@npm//:@types/long",
36-
"@npm//:@types/node",
37-
"@npm//:long",
34+
"@npm//@types/jasmine",
35+
"@npm//@types/long",
36+
"@npm//@types/node",
37+
"@npm//long",
3838
],
3939
)
4040

@@ -83,8 +83,8 @@ rollup_bundle(
8383
genrule(
8484
name = "protobufjs",
8585
srcs = [
86-
"@build_bazel_rules_typescript_protobufs_compiletime_deps//:node_modules/protobufjs/dist/minimal/protobuf.min.js",
87-
"@build_bazel_rules_typescript_protobufs_compiletime_deps//:node_modules/long/dist/long.js",
86+
"@build_bazel_rules_typescript_protobufs_compiletime_deps//node_modules/protobufjs:dist/minimal/protobuf.min.js",
87+
"@build_bazel_rules_typescript_protobufs_compiletime_deps//node_modules/long:dist/long.js",
8888
],
8989
outs = [
9090
"protobuf.min.js",
@@ -108,8 +108,8 @@ ts_library(
108108
srcs = ["app_e2e_test.ts"],
109109
tsconfig = "//examples:tsconfig-test",
110110
deps = [
111-
"@npm//:@types/jasmine",
112-
"@npm//:@types/node",
113-
"@npm//:protractor",
111+
"@npm//@types/jasmine",
112+
"@npm//@types/node",
113+
"@npm//protractor",
114114
],
115115
)

examples/testing/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ ts_library(
1212
tsconfig = "//examples:tsconfig-test",
1313
deps = [
1414
":lib",
15-
"@npm//:@types/jasmine",
16-
"@npm//:@types/node",
15+
"@npm//@types/jasmine",
16+
"@npm//@types/node",
1717
],
1818
)
1919

examples/tsconfig-bar.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"strict": true,
44
"lib": ["es2015.promise", "dom", "es5"],
55
// Auto-discover all types in this configuration since we don't
6-
// specify `types = []` and the ts_library rule depends on `@npm//:@types`.
6+
// specify `types = []` and the ts_library rule depends on `@npm//@types`.
77
// Typescript will automatically discover all types under node_modules/@types
88
// and included them in the build. See getAutomaticTypeDirectiveNames in
99
// https://github.com/Microsoft/TypeScript/blob/master/src/compiler/moduleNameResolver.ts.

internal/BUILD.bazel

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "jasmine_node_test
3131
nodejs_binary(
3232
name = "tsc",
3333
data = [
34-
"@npm//:source-map-support",
35-
"@npm//:typescript",
34+
"@npm//source-map-support",
35+
"@npm//typescript",
3636
],
3737
entry_point = "typescript/lib/tsc.js",
3838
visibility = ["//internal:__subpackages__"],
@@ -65,25 +65,25 @@ ts_library(
6565
# work with vanilla tsc.
6666
# Workaround for https://github.com/Microsoft/TypeScript/issues/22208
6767
deps = [
68-
"@npm//:@types/node",
69-
"@npm//:tsickle",
70-
"@npm//:tsutils",
71-
"@npm//:typescript",
68+
"@npm//@types/node",
69+
"@npm//tsickle",
70+
"@npm//tsutils",
71+
"@npm//typescript",
7272
],
7373
)
7474

7575
# Other ts_library rules will use this custom compiler, which calls the
7676
# TypeScript APIs to act like tsc, but adds capabilities like Bazel workers.
77-
# TODO(gregmagolan): make @npm//:tsickle dependency optional
77+
# TODO(gregmagolan): make @npm//tsickle dependency optional
7878
nodejs_binary(
7979
name = "tsc_wrapped_bin",
8080
data = [
8181
":tsc_wrapped",
82-
"@npm//:protobufjs",
83-
"@npm//:source-map-support",
84-
"@npm//:tsickle",
85-
"@npm//:tsutils",
86-
"@npm//:typescript",
82+
"@npm//protobufjs",
83+
"@npm//source-map-support",
84+
"@npm//tsickle",
85+
"@npm//tsutils",
86+
"@npm//typescript",
8787
],
8888
entry_point = "build_bazel_rules_typescript/internal/tsc_wrapped/tsc_wrapped.js",
8989
templated_args = ["--node_options=--expose-gc"],
@@ -96,9 +96,9 @@ ts_library(
9696
tsconfig = "//internal:tsc_wrapped/tsconfig.json",
9797
deps = [
9898
":tsc_wrapped",
99-
"@npm//:@types/jasmine",
100-
"@npm//:@types/node",
101-
"@npm//:typescript",
99+
"@npm//@types/jasmine",
100+
"@npm//@types/node",
101+
"@npm//typescript",
102102
],
103103
)
104104

@@ -107,8 +107,8 @@ jasmine_node_test(
107107
srcs = [],
108108
deps = [
109109
":test_lib",
110-
"@npm//:jasmine",
111-
"@npm//:typescript",
110+
"@npm//jasmine",
111+
"@npm//typescript",
112112
],
113113
)
114114

0 commit comments

Comments
 (0)