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 e14eee9 commit 24a1970
Show file tree
Hide file tree
Showing 4 changed files with 40 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 @@ -7,6 +7,7 @@ ts_project_sandboxed_worker
ts_project_swc
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
23 changes: 23 additions & 0 deletions rules_ts/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ swc_register_toolchains(
swc_version = "v1.2.204",
)

local_repository(
name = "aspect_rules_esbuild",
path = "../../rules_esbuild",
)

#http_archive(
# name = "aspect_rules_esbuild",
# sha256 = "1e365451341ffb2490193292dfd9953f2ca009586c2381cb4dc08d01e48866b7",
# strip_prefix = "rules_esbuild-0.12.0",
# url = "https://github.com/aspect-build/rules_esbuild/archive/refs/tags/v0.12.0.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 @@ -39,6 +39,7 @@ class Generator {
'ts_project_swc',
'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 @@ -155,6 +156,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 @@ -207,6 +214,7 @@ ${this._ts_attributes()}
case 'ts_project_swc':
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 @@ -280,6 +288,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 @@ -11,6 +11,7 @@ styles=(
'ts_project_swc'
'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 24a1970

Please sign in to comment.