Skip to content

feat!: clearer bzlmod extension API for TypeScript toolchains - #972

Open
jbedard wants to merge 1 commit into
aspect-build:mainfrom
jbedard:941-extension-renaming
Open

feat!: clearer bzlmod extension API for TypeScript toolchains#972
jbedard wants to merge 1 commit into
aspect-build:mainfrom
jbedard:941-extension-renaming

Conversation

@jbedard

@jbedard jbedard commented Jul 18, 2026

Copy link
Copy Markdown
Member

Rename the module extension surface so a MODULE.bazel reads self-documenting:

    ts = use_extension("@aspect_rules_ts//ts:extensions.bzl", "typescript")
    ts.toolchain(version = "5.6.2")   # or version_from = "//:package.json"
    use_repo(ts, "npm_typescript")
  • Extension symbol ext -> typescript, matching rules_js's convention of naming the extension after its domain concept rather than a generic "ext".
  • Tag class deps -> toolchain: the tag selects the TypeScript compiler version backing the toolchain; it does not declare dependencies.
  • Attrs lose their redundant ts_ prefix inside the typescript.toolchain
    context: ts_version/ts_version_from/ts_integrity ->
    version/version_from/integrity.

The default repo name npm_typescript and the multi-toolchain name escape hatch are unchanged. The internal npm_dependencies repo rule (shared with the WORKSPACE path) is untouched.

Fix #941

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): yes
  • Suggested release notes appear below: yes

BREAKING CHANGES:

The bzlmod module extension API has changed. Update MODULE.bazel:

before

    rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext")
    rules_ts_ext.deps(ts_version = "5.6.2")
    use_repo(rules_ts_ext, "npm_typescript")

after

    ts = use_extension("@aspect_rules_ts//ts:extensions.bzl", "typescript")
    ts.toolchain(version = "5.6.2")
    use_repo(ts, "npm_typescript")

Renames:

  • use_extension(..., "ext") -> use_extension(..., "typescript")
  • .deps(...) -> .toolchain(...)
  • ts_version -> version
  • ts_version_from -> version_from
  • ts_integrity -> integrity

The local variable bound to use_extension (commonly rules_ts_ext) is arbitrary and may be named anything; the examples now use typescript. The npm_typescript repo name and the name attribute for registering additional TypeScript versions are unaffected.

Test plan

  • Covered by existing test cases

Comment thread ts/extensions.bzl
rules_ts_ext.deps(
ts_version_from = "//:package.json",
typescript = use_extension("@aspect_rules_ts//ts:extensions.bzl", "typescript")
typescript.toolchain(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean we have a typescript toolchain now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's not actually a toolchain, so we could potentially (for now) stick with the .deps() name? That also reduces the breaking change.

Regarding toolchains... see #951 - we can debate the correctness there, but maybe we should also wait till then to do this rename?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh i am fine with breaking changes, i was just curious. i'd be happy to see #951 land honestly. so that we can use configurability and platforms and toolchains to configure typescript in the graph.

@jbedard
jbedard force-pushed the 941-extension-renaming branch from b276897 to aadb6a2 Compare July 31, 2026 23:24
Rename the module extension surface so a MODULE.bazel reads self-documenting:

    typescript = use_extension("@aspect_rules_ts//ts:extensions.bzl", "typescript")
    typescript.toolchain(version = "5.6.2")   # or version_from = "//:package.json"
    use_repo(typescript, "npm_typescript")

- Extension symbol `ext` -> `typescript`, matching rules_js's convention of
  naming the extension after its domain concept rather than a generic "ext".
- Tag class `deps` -> `toolchain`: the tag selects the TypeScript compiler
  version backing the toolchain; it does not declare dependencies.
- Attrs lose their redundant `ts_` prefix inside the `typescript.toolchain`
  context: `ts_version`/`ts_version_from`/`ts_integrity` ->
  `version`/`version_from`/`integrity`.

The default repo name `npm_typescript` and the multi-toolchain `name` escape
hatch are unchanged. The internal `npm_dependencies` repo rule (shared with the
WORKSPACE path) is untouched.

Fixes aspect-build#941

BREAKING CHANGES:

The bzlmod module extension API has changed. Update MODULE.bazel:

    # before
    rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext")
    rules_ts_ext.deps(ts_version = "5.6.2")
    use_repo(rules_ts_ext, "npm_typescript")

    # after
    typescript = use_extension("@aspect_rules_ts//ts:extensions.bzl", "typescript")
    typescript.toolchain(version = "5.6.2")
    use_repo(typescript, "npm_typescript")

Renames:
- `use_extension(..., "ext")` -> `use_extension(..., "typescript")`
- `.deps(...)` -> `.toolchain(...)`
- `ts_version` -> `version`
- `ts_version_from` -> `version_from`
- `ts_integrity` -> `integrity`

The local variable bound to `use_extension` (commonly `rules_ts_ext`) is
arbitrary and may be named anything; the examples now use `typescript`. The
`npm_typescript` repo name and the `name` attribute for registering additional
TypeScript versions are unaffected.
@jbedard
jbedard force-pushed the 941-extension-renaming branch from aadb6a2 to 875cf1f Compare August 3, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use_extension second argument naming (ext) feels semantically unclear — is it required or just convention?

3 participants