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.
feat(typescript): generate tsconfig.json for ts_project
This is an experimental, opt-in feature where ts_project will generate a tsconfig.json file in place of the user specifying one in the source directory. I expect a long tail of compatibility bugs since any path appearing in this generated file needs to point from bazel-out back to the source directory. Fixes bazel-contrib#2058
- Loading branch information
Alex Eagle
committed
Aug 27, 2020
1 parent
ef97299
commit 9d34089
Showing
30 changed files
with
403 additions
and
46 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
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
43 changes: 43 additions & 0 deletions
43
packages/typescript/test/ts_project/generated_tsconfig/config/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,43 @@ | ||
"Test that properties in the tsconfig dict are honored" | ||
|
||
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") | ||
load("//packages/typescript:index.bzl", "ts_project") | ||
|
||
ts_project( | ||
tsconfig = { | ||
"compilerOptions": { | ||
"declaration": True, | ||
"declarationDir": "types", | ||
"declarationMap": True, | ||
"module": "esnext", | ||
"outDir": "out", | ||
"rootDir": "src", | ||
"sourceMap": True, | ||
"types": [], | ||
}, | ||
}, | ||
) | ||
|
||
generated_file_test( | ||
name = "test", | ||
src = "expected.js_", | ||
generated = ":out/a.js", | ||
) | ||
|
||
generated_file_test( | ||
name = "test_map", | ||
src = "expected.js.map_", | ||
generated = ":out/a.js.map", | ||
) | ||
|
||
generated_file_test( | ||
name = "test_dts", | ||
src = "expected.d.ts_", | ||
generated = ":types/a.d.ts", | ||
) | ||
|
||
generated_file_test( | ||
name = "test_dtsmap", | ||
src = "expected.d.ts.map_", | ||
generated = ":types/a.d.ts.map", | ||
) |
1 change: 1 addition & 0 deletions
1
packages/typescript/test/ts_project/generated_tsconfig/config/expected.d.ts.map_
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 @@ | ||
{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/typescript/test/ts_project/generated_tsconfig/config/src/a.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,CAAC,EAAE,MAAsB,CAAC"} |
2 changes: 2 additions & 0 deletions
2
packages/typescript/test/ts_project/generated_tsconfig/config/expected.d.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,2 @@ | ||
export declare const a: string; | ||
//# sourceMappingURL=a.d.ts.map |
1 change: 1 addition & 0 deletions
1
packages/typescript/test/ts_project/generated_tsconfig/config/expected.js.map_
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 @@ | ||
{"version":3,"file":"a.js","sourceRoot":"","sources":["../../../../../../../../../../packages/typescript/test/ts_project/generated_tsconfig/config/src/a.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,CAAC,GAAW,aAAa,CAAC"} |
2 changes: 2 additions & 0 deletions
2
packages/typescript/test/ts_project/generated_tsconfig/config/expected.js_
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,2 @@ | ||
export var a = 'hello world'; | ||
//# sourceMappingURL=a.js.map |
1 change: 1 addition & 0 deletions
1
packages/typescript/test/ts_project/generated_tsconfig/config/src/a.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 @@ | ||
export const a: string = 'hello world'; |
43 changes: 43 additions & 0 deletions
43
packages/typescript/test/ts_project/generated_tsconfig/config_attrs/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,43 @@ | ||
"Test that attributes set on ts_project are honored" | ||
|
||
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") | ||
load("//packages/typescript:index.bzl", "ts_project") | ||
|
||
ts_project( | ||
declaration = True, | ||
declaration_dir = "types", | ||
declaration_map = True, | ||
out_dir = "out", | ||
root_dir = "src", | ||
source_map = True, | ||
tsconfig = { | ||
"compilerOptions": { | ||
"module": "esnext", | ||
"types": [], | ||
}, | ||
}, | ||
) | ||
|
||
generated_file_test( | ||
name = "test", | ||
src = "expected.js_", | ||
generated = ":out/a.js", | ||
) | ||
|
||
generated_file_test( | ||
name = "test_map", | ||
src = "expected.js.map_", | ||
generated = ":out/a.js.map", | ||
) | ||
|
||
generated_file_test( | ||
name = "test_dts", | ||
src = "expected.d.ts_", | ||
generated = ":types/a.d.ts", | ||
) | ||
|
||
generated_file_test( | ||
name = "test_dtsmap", | ||
src = "expected.d.ts.map_", | ||
generated = ":types/a.d.ts.map", | ||
) |
1 change: 1 addition & 0 deletions
1
packages/typescript/test/ts_project/generated_tsconfig/config_attrs/expected.d.ts.map_
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 @@ | ||
{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/typescript/test/ts_project/generated_tsconfig/config_attrs/src/a.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,CAAC,EAAE,MAAsB,CAAC"} |
Oops, something went wrong.