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 23, 2020
1 parent
660b456
commit 096345c
Showing
24 changed files
with
287 additions
and
42 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 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( | ||
tsconfig = { | ||
"compilerOptions": { | ||
"declaration": True, | ||
"declarationDir": "types", | ||
"declarationMap": True, | ||
"listEmittedFiles": True, | ||
"module": "esnext", | ||
"outDir": "out", | ||
"rootDir": "src", | ||
"sourceMap": True, | ||
}, | ||
}, | ||
) | ||
|
||
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'; |
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
"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", | ||
}, | ||
}, | ||
) | ||
|
||
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"} |
2 changes: 2 additions & 0 deletions
2
packages/typescript/test/ts_project/generated_tsconfig/config_attrs/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_attrs/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_attrs/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_attrs/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_attrs/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'; |
19 changes: 19 additions & 0 deletions
19
packages/typescript/test/ts_project/generated_tsconfig/decl_only/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,19 @@ | ||
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") | ||
load("//packages/typescript:index.bzl", "ts_project") | ||
|
||
ts_project( | ||
name = "compile", | ||
tsconfig = { | ||
"compilerOptions": { | ||
"declaration": True, | ||
"emitDeclarationOnly": True, | ||
}, | ||
}, | ||
) | ||
|
||
generated_file_test( | ||
name = "test", | ||
src = "a.d.ts", | ||
# test the default output of the ts_project | ||
generated = "compile", | ||
) |
1 change: 1 addition & 0 deletions
1
packages/typescript/test/ts_project/generated_tsconfig/decl_only/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'; |
1 change: 1 addition & 0 deletions
1
packages/typescript/test/ts_project/generated_tsconfig/decl_only/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 @@ | ||
export declare const a: string; |
12 changes: 12 additions & 0 deletions
12
packages/typescript/test/ts_project/generated_tsconfig/default/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,12 @@ | ||
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") | ||
load("//packages/typescript:index.bzl", "ts_project") | ||
|
||
ts_project( | ||
tsconfig = {}, | ||
) | ||
|
||
generated_file_test( | ||
name = "test", | ||
src = "expected.js_", | ||
generated = ":a.js", | ||
) |
1 change: 1 addition & 0 deletions
1
packages/typescript/test/ts_project/generated_tsconfig/default/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'; |
3 changes: 3 additions & 0 deletions
3
packages/typescript/test/ts_project/generated_tsconfig/default/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,3 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.a = 'hello world'; |
18 changes: 18 additions & 0 deletions
18
packages/typescript/test/ts_project/generated_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,18 @@ | ||
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") | ||
load("//packages/typescript:index.bzl", "ts_project") | ||
|
||
ts_project( | ||
extends = ["//packages/typescript/test/ts_project:tsconfig-base.json"], | ||
tsconfig = { | ||
"compilerOptions": { | ||
"declaration": True, | ||
}, | ||
}, | ||
) | ||
|
||
generated_file_test( | ||
name = "test", | ||
# test the default output of the ts_project | ||
src = "expected.js_", | ||
generated = "a.js", | ||
) |
1 change: 1 addition & 0 deletions
1
packages/typescript/test/ts_project/generated_tsconfig/extends/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'; |
Oops, something went wrong.