Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aspect-build/rules_ts
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.5.0
Choose a base ref
...
head repository: aspect-build/rules_ts
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.5.1
Choose a head ref
  • 7 commits
  • 20 files changed
  • 3 contributors

Commits on Mar 4, 2025

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9e0eb27 View commit details
  2. chore: upgrade rules_lint to v1.2.0

    jbedard committed Mar 4, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    21ddae1 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    735f50f View commit details
  4. chore: upgrade aspect-cli to 2025.08.26

    jbedard committed Mar 4, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    77be793 View commit details
  5. test: resolve_json_module with transpiler (#747)

    jbedard authored Mar 4, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1b7cfb6 View commit details

Commits on Mar 11, 2025

  1. fix: disallow remote cache with workers (#776)

    Disallow remote cache with non-sandboxed workers.
    MichaelMitchell-at authored Mar 11, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9bd59de View commit details

Commits on Mar 12, 2025

  1. fix: support ts_project(assets) that are generated directly into th…

    …e `outDir` (#779)
    walkerburgin authored Mar 12, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d82d330 View commit details
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -10,3 +10,4 @@ examples/linked_empty_node_modules/node_modules
examples/linked_tsconfig/node_modules
examples/linked_tsconfig_consumer/node_modules
examples/resolve_json_module_esm/node_modules
examples/resolve_json_module_transpiler/node_modules
2 changes: 1 addition & 1 deletion .bazeliskrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BAZELISK_BASE_URL=https://github.com/aspect-build/aspect-cli/releases/download
USE_BAZEL_VERSION=aspect/5.9.25
USE_BAZEL_VERSION=aspect/2025.08.26
13 changes: 10 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -78,14 +78,21 @@ jobs:
- os: windows
bazel-version:
major: 6
# Dont' test root workspace with Bazel 6 to reduce the size of the test matrix
# Don't test root workspace with Bazel 6 to reduce the size of the test matrix
- bazel-version:
major: 6
folder: .
# Don't run bzlmod tests with Bazel 6 to reduce the size of the test matrix
# Don't test non-bzlmod with Bazel 6 to reduce the size of the test matrix
- bazel-version:
major: 6
bzlmod: 1
bzlmod: 0
# Don't test root workspace with non-bzlmod
- bzlmod: 0
folder: .
# e2e/bzlmod broken with bazel6
- bazel-version:
major: 6
folder: e2e/bzlmod
# Disable some broken tests on Windows
- os: windows
folder: .
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ bazel_dep(name = "rules_proto", version = "6.0.0")

####### Dev dependencies ########

bazel_dep(name = "aspect_rules_lint", version = "0.9.1", dev_dependency = True)
bazel_dep(name = "aspect_rules_lint", version = "1.2.1", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
bazel_dep(name = "rules_go", version = "0.46.0", dev_dependency = True, repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_nodejs", version = "6.2.0", dev_dependency = True)
129 changes: 6 additions & 123 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,124 +1,7 @@
workspace(name = "aspect_rules_ts")
# This file is not used by Bazel 8 and should be removed.
#
# However its presence works around issues with some tools:
# https://github.com/bazel-contrib/bazel-gazelle/issues/2012
# https://github.com/bazelbuild/bazel-watcher/issues/646

load(":internal_deps.bzl", "rules_ts_internal_deps")

# Fetch deps needed only locally for development
rules_ts_internal_deps()

load("//ts:repositories.bzl", "rules_ts_bazel_dependencies", "rules_ts_dependencies")

# Fetch dependencies which users need as well
# Note, we have to be different and first load just the bazel dependencies, since we
# need to bootstrap rules_nodejs before we can load from @npm to get our typescript version.
rules_ts_bazel_dependencies()

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains")

rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION)

load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")

nodejs_register_toolchains(
name = "node18",
node_version = "18.12.0",
)

# For running our own unit tests
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

######################
# toolchains_protoc setup #
######################
# Fetches the toolchains_protoc dependencies.
# If you want to have a different version of some dependency,
# you should fetch it *before* calling this.
# Alternatively, you can skip calling this function, so long as you've
# already fetched all the dependencies.
load("@toolchains_protoc//protoc:repositories.bzl", "rules_protoc_dependencies")

rules_protoc_dependencies()

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")

rules_proto_dependencies()

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

load("@toolchains_protoc//protoc:toolchain.bzl", "protoc_toolchains")

protoc_toolchains(
name = "protoc_toolchains",
version = "v25.3",
)

register_toolchains("//tools/toolchains:all")

############################################
# Stardoc
load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories")

stardoc_repositories()

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@io_bazel_stardoc//:deps.bzl", "stardoc_external_deps")

stardoc_external_deps()

load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install")

stardoc_pinned_maven_install()

# Buildifier
load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")

buildifier_prebuilt_deps()

load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")

buildifier_prebuilt_register_toolchains()

###########################################
# A pnpm workspace so we can test 3p deps
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//examples:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)

load("@npm//:repositories.bzl", "npm_repositories")

npm_repositories()

# You can verify the typescript version used by Bazel:
# bazel run -- @npm_typescript//:tsc --version
rules_ts_dependencies(ts_version_from = "@npm//examples:typescript/resolved.json")

bazel_features_deps()

rules_proto_dependencies()

# rules_lint
load(
"@aspect_rules_lint//format:repositories.bzl",
"fetch_shfmt",
)

fetch_shfmt()
fail("Local WORKSPACE development unsupported")
8 changes: 0 additions & 8 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# TODO: rules_lint doesn't have a way to bring deps in under bzlmod
load(
"@aspect_rules_lint//format:repositories.bzl",
"fetch_shfmt",
)

fetch_shfmt()

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")

# Needed for stardoc to compile from Java sources
65 changes: 65 additions & 0 deletions docs/performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Performance

The primary method of improving build performance is essentially avoiding `tsc`, the TypeScript compiler, as much as possible.

There are 3 main goals of `ts_project`, where `tsc` is the traditional tool:
* transpile TypeScript to javascript files
* transpile TypeScript to declaration files
* type-check TypeScript

## Transpilers

The easiest and most common performance improvement is to use a transpiler other than `tsc` for the transpiling
of TypeScript to javascript files. See [transpiler.md](transpiler.md) for details.

## Isolated Typecheck

Isolating the type-check action from the transpiling actions can also improve performance.

The tsconfig `compilerOptions.isolatedDeclarations` option ensures TypeScript code can be transpiled
to declaration files without the need for dependencies to be present.

The `ts_project(isolated_typecheck)` option can take advantage of `isolatedDeclarations` by separating the
transpiling vs type-checking into separate bazel actions. The transpiling of TypeScript files with `isolatedDeclarations`
can be done without blocking waiting for dependencies, greatly increasing parallelization of declaration file creation.
Declaration files being created faster then allows the type-checking to start sooner.

### When to use `isolated_typecheck`

It is not always possible or convenient to use the TypeScript `isolatedDeclarations` option, especially when it requires
significant code changes. However it may be worth enabling `isolatedDeclarations` for a subset of projects that are bottlenecks
in the build graph.

Bottlenecks in the build graph are normally targets with a lot of dependencies (including transitive), while also being depended
on by a lot of targets (including transitive).

In this example scenario C is a bottleneck in the build graph:
```
┌─────┐ ┌─────┐
│ A ┼────┐ ┌───► D │
└─────┘ │ │ └─────┘
┌─────┐ ┌▼────┤ ┌─────┐ ┌─────┐
│ B ┼───► C ┼───► E ┼─► F │
└─────┘ └─────┘ └─────┘ └─────┘
```

Without `isolated_typecheck` transpiling declaration files follows the dependency graph. Project (A) and (B) require declaration
files outputted from (C). Project (C) requires declaration files outputted from (D), (E), and (F) etc.

With `isolated_typecheck` on module C more can be parallelized:
```
┌─────┐
│ A ┼────┐
└─────┘ │
┌─────┐ ┌▼────┐
│ B ┼───► C │
└─────┘ └─────┘
┌─────┐
│ D │
└─────┘
┌─────┐ ┌─────┐
│ E ┼───► F │
└─────┘ └─────┘
```

The additional parallelization will also lead to type-checking starting sooner.
18 changes: 18 additions & 0 deletions examples/assets/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -164,12 +164,19 @@ ts_project(
tsconfig = ":config",
)

genrule(
name = "generated_root_output_file",
outs = ["root-out/metadata/generated_metadata.json"],
cmd = "echo 1 > $@",
)

ts_project(
name = "ts-root-out",
srcs = [
"src/index.ts",
],
assets = [
"root-out/metadata/generated_metadata.json",
"src/styles.css",
"src/generated.json",
],
@@ -178,6 +185,17 @@ ts_project(
tsconfig = ":config",
)

assert_outputs(
name = "ts-root-out_outputs_test",
actual = ":ts-root-out",
expected = [
"examples/assets/root-out/generated.json",
"examples/assets/root-out/index.js",
"examples/assets/root-out/metadata/generated_metadata.json",
"examples/assets/root-out/styles.css",
],
)

build_test(
name = "test",
targets = [
1 change: 1 addition & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
"@babel/core": "~7.23.9",
"@babel/parser": "~7.23.9",
"@babel/preset-typescript": "^7.23.3",
"@babel/plugin-transform-modules-commonjs": "~7.26.3",
"@babel/types": "~7.23.9",
"@tsconfig/strictest": "2.0.5",
"@types/node": "^20",
Loading