-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(esbuild): allow ts / tsx files in esbuilds srcs (#2594)
- Loading branch information
Showing
14 changed files
with
143 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
load("//:index.bzl", "generated_file_test", "nodejs_binary", "npm_package_bin") | ||
load("//packages/esbuild/test:tests.bzl", "esbuild") | ||
|
||
esbuild( | ||
name = "lib", | ||
srcs = [ | ||
"main.ts", | ||
"service/index.ts", | ||
"service/service.ts", | ||
], | ||
entry_point = "main.ts", | ||
minify = True, | ||
platform = "node", | ||
deps = [ | ||
"//packages/esbuild/test/typescript/ts_as_srcs/questions", | ||
], | ||
) | ||
|
||
nodejs_binary( | ||
name = "bin", | ||
data = [":lib"], | ||
entry_point = ":lib.js", | ||
) | ||
|
||
npm_package_bin( | ||
name = "runner", | ||
stdout = "output.txt", | ||
tool = ":bin", | ||
) | ||
|
||
generated_file_test( | ||
name = "ts_srcs_test", | ||
src = "output.golden.txt", | ||
generated = ":output.txt", | ||
) |
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,8 @@ | ||
import {QUESTION} from '@rnj/questions'; | ||
|
||
import {UnhelpfulService} from './service'; | ||
|
||
const service = new UnhelpfulService(); | ||
const answer = service.question(QUESTION); | ||
|
||
console.log(answer); |
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 @@ | ||
Don't know |
23 changes: 23 additions & 0 deletions
23
packages/esbuild/test/typescript/ts_as_srcs/questions/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,23 @@ | ||
load("//internal/js_library:js_library.bzl", "js_library") | ||
load("//packages/typescript:index.bzl", "ts_project") | ||
|
||
ts_project( | ||
name = "lib", | ||
srcs = [ | ||
"index.ts", | ||
"wood-chuck.ts", | ||
], | ||
tsconfig = { | ||
"compilerOptions": { | ||
"declaration": True, | ||
"types": [], | ||
}, | ||
}, | ||
) | ||
|
||
js_library( | ||
name = "questions", | ||
package_name = "@rnj/questions", | ||
visibility = ["//packages/esbuild/test/typescript/ts_as_srcs:__pkg__"], | ||
deps = [":lib"], | ||
) |
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 * from './wood-chuck'; |
1 change: 1 addition & 0 deletions
1
packages/esbuild/test/typescript/ts_as_srcs/questions/wood-chuck.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 QUESTION = `How much wood could a woodchuck chuck, if a woodchuck could chuck wood?`; |
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 * from './service'; |
15 changes: 15 additions & 0 deletions
15
packages/esbuild/test/typescript/ts_as_srcs/service/service.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,15 @@ | ||
abstract class Service { | ||
abstract question(q: string): string; | ||
} | ||
|
||
export class UnhelpfulService extends Service { | ||
public question(q: string): string { | ||
return `Don't know`; | ||
} | ||
} | ||
|
||
export class HelpfulService extends Service { | ||
public question(q: string): string { | ||
return `42`; | ||
} | ||
} |
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,29 @@ | ||
load("//:index.bzl", "generated_file_test", "nodejs_binary", "npm_package_bin") | ||
load("//packages/esbuild/test:tests.bzl", "esbuild") | ||
|
||
esbuild( | ||
name = "lib", | ||
srcs = [ | ||
"main.js", | ||
"name.js", | ||
], | ||
entry_point = "main.js", | ||
) | ||
|
||
nodejs_binary( | ||
name = "bin", | ||
data = [":lib"], | ||
entry_point = ":lib.js", | ||
) | ||
|
||
npm_package_bin( | ||
name = "runner", | ||
stdout = "output.txt", | ||
tool = ":bin", | ||
) | ||
|
||
generated_file_test( | ||
name = "vanilla_js_test", | ||
src = "output.golden.txt", | ||
generated = ":output.txt", | ||
) |
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 @@ | ||
const NAME = require('./name').NAME; | ||
console.log(NAME); |
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 @@ | ||
exports.NAME = 'rules_nodejs' |
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 @@ | ||
rules_nodejs |