Skip to content

Commit

Permalink
Add benchmarks for esbuild transpiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbarsky committed Aug 29, 2022
1 parent 2947b9e commit 59926f8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions rules_ts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ts_project_swc
ts_project_swc_rbe
ts_project_worker_swc
ts_project_sandboxed_worker_swc
ts_project_esbuild
ts_project_rules_nodejs
ts_project_rules_nodejs_swc
ts_library
Expand Down
19 changes: 19 additions & 0 deletions rules_ts/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ swc_register_toolchains(
swc_version = "v1.2.244",
)

http_archive(
name = "aspect_rules_esbuild",
# HEAD of https://github.com/dzbarsky/rules_esbuild/tree/esbuild_transpiler
sha256 = "24f49ec473c9a96e8efef0f211642579ebc790e4e21cd6a5818ae4bfc610deb0",
strip_prefix = "rules_esbuild-e23be685e07a78ef14dd744ac844193dec09bd2c",
url = "https://github.com/aspect-build/rules_esbuild/archive/e23be685e07a78ef14dd744ac844193dec09bd2c.tar.gz",
)

load("@aspect_rules_esbuild//esbuild:dependencies.bzl", "rules_esbuild_dependencies")

rules_esbuild_dependencies()

load("@aspect_rules_esbuild//esbuild:repositories.bzl", "LATEST_VERSION", "esbuild_register_toolchains")

esbuild_register_toolchains(
name = "esbuild",
esbuild_version = LATEST_VERSION,
)

########################################################
# Below only needed for legacy rules_nodejs comparison #

Expand Down
15 changes: 15 additions & 0 deletions rules_ts/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Generator {
'ts_project_swc_rbe',
'ts_project_worker_swc',
'ts_project_sandboxed_worker_swc',
'ts_project_esbuild',
'ts_project_rules_nodejs',
'ts_project_rules_nodejs_swc',
'ts_library',
Expand Down Expand Up @@ -160,6 +161,12 @@ ${this._ts_attributes()}
'load("@aspect_rules_swc//swc:defs.bzl", "swc_transpiler")',
].join("\n")

case 'ts_project_esbuild':
return [
'load("@aspect_rules_ts//ts:defs.bzl", "ts_project")',
'load("@aspect_rules_js//js:defs.bzl", "js_library")',
'load("@aspect_rules_esbuild//esbuild:defs.bzl", "esbuild_transpiler")',
].join("\n")
case 'ts_project_rules_nodejs':
return [
'load("@npm//@bazel/typescript:index.bzl", "ts_project")',
Expand Down Expand Up @@ -215,6 +222,7 @@ ${this._ts_attributes()}
case 'ts_project_swc_rbe':
case 'ts_project_worker_swc':
case 'ts_project_sandboxed_worker_swc':
case 'ts_project_esbuild':
return `
# Generated BUILD file, see /generate.js
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
Expand Down Expand Up @@ -291,6 +299,13 @@ ${rootDeps.map(d => ` \"${d}\",`).join("\n")}
attrs.push(' supports_workers = True,')
break;

case 'ts_project_esbuild':
attrs.push(` tsconfig = "//${this.outputDir}:tsconfig",`)
attrs.push(' declaration = True,')
attrs.push(' transpiler = esbuild_transpiler,')
attrs.push(' supports_workers = False,')
break;

case 'ts_project_rules_nodejs':
attrs.push(` tsconfig = "//${this.outputDir}:tsconfig.json",`)
attrs.push(' declaration = True,')
Expand Down
1 change: 1 addition & 0 deletions rules_ts/run_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ styles=(
'ts_project_swc_rbe'
'ts_project_worker_swc'
'ts_project_sandboxed_worker_swc'
'ts_project_esbuild'
'ts_project_rules_nodejs'
'ts_project_rules_nodejs_swc'
'ts_library'
Expand Down

0 comments on commit 59926f8

Please sign in to comment.