forked from bazel-contrib/rules_nodejs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow multiple tsconfig inputs to a ts_library
Fixes bazel-contrib#41 Closes bazel-contrib#42 PiperOrigin-RevId: 169476478
- Loading branch information
Showing
7 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/concatjs/third_party/google3/rules_typescript/examples/tsconfig_extends/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2017 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("//:defs.bzl", "ts_config", "ts_library") | ||
|
||
# Because our tsconfig.json has an extends property, we must also tell the | ||
# ts_library to include the extended tsconfig file in compilations. | ||
# The ts_library rule will generate its own tsconfig which extends from the | ||
# src file. | ||
ts_config( | ||
name = "tsconfig", | ||
src = "tsconfig.json", | ||
deps = ["tsconfig-base.json"], | ||
) | ||
|
||
ts_library( | ||
name = "tsconfig_extends", | ||
srcs = [ | ||
"uses_promise.ts", | ||
], | ||
tsconfig = ":tsconfig", | ||
) |
5 changes: 5 additions & 0 deletions
5
...oncatjs/third_party/google3/rules_typescript/examples/tsconfig_extends/tsconfig-base.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2015.promise", "es5"] | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...ges/concatjs/third_party/google3/rules_typescript/examples/tsconfig_extends/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig-base" | ||
} | ||
|
3 changes: 3 additions & 0 deletions
3
...s/concatjs/third_party/google3/rules_typescript/examples/tsconfig_extends/uses_promise.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function hiLater(): Promise<string> { | ||
return Promise.resolve('hi'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/concatjs/third_party/google3/rules_typescript/internal/ts_config.bzl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2017 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""The ts_config rule allows users to express tsconfig.json file groups. | ||
""" | ||
|
||
TsConfig = provider() | ||
|
||
def _ts_config_impl(ctx): | ||
files = depset() | ||
files += [ctx.file.src] | ||
return [DefaultInfo(files = files), TsConfig(deps = ctx.files.deps)] | ||
|
||
ts_config = rule( | ||
implementation = _ts_config_impl, | ||
attrs = { | ||
"src": attr.label(allow_files = True, single_file = True, mandatory = True), | ||
"deps": attr.label_list(allow_files = True, mandatory = True), | ||
}, | ||
) |