generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support custom dts transpiler (#697)
- Loading branch information
Showing
7 changed files
with
288 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,32 @@ | ||
"Adapter from the TypeScript CLI to the ts_project#transpiler/declaration_transpiler interface" | ||
|
||
load("@npm//examples:typescript/package_json.bzl", typescript_bin = "bin") | ||
|
||
# tsc configured with --outDir and --emitDeclarationOnly | ||
def tsc_dts(name, srcs, out_dir, **kwargs): | ||
typescript_bin.tsc( | ||
name = name, | ||
srcs = srcs + ["tsconfig.json"], | ||
outs = ["%s/%s" % (out_dir, src.replace(".ts", ".d.ts")) for src in srcs], | ||
args = [ | ||
"-p %s/tsconfig.json" % native.package_name(), | ||
"--emitDeclarationOnly", | ||
"--outDir %s/%s" % (native.package_name(), out_dir), | ||
], | ||
**kwargs | ||
) | ||
|
||
# tsc configured with --outDir and --declaration false | ||
def tsc_js(name, srcs, out_dir, **kwargs): | ||
typescript_bin.tsc( | ||
name = name, | ||
srcs = srcs + ["tsconfig.json"], | ||
outs = ["%s/%s" % (out_dir, src.replace(".ts", ".js")) for src in srcs], | ||
args = [ | ||
"-p %s/tsconfig.json" % native.package_name(), | ||
"--declaration", | ||
"false", | ||
"--outDir %s/%s" % (native.package_name(), out_dir), | ||
], | ||
**kwargs | ||
) |
Oops, something went wrong.