Skip to content

fix: support npm_typescript definitions from multiple modules#884

Merged
jbedard merged 2 commits intoaspect-build:mainfrom
jbedard:843-multiple
Jan 20, 2026
Merged

fix: support npm_typescript definitions from multiple modules#884
jbedard merged 2 commits intoaspect-build:mainfrom
jbedard:843-multiple

Conversation

@jbedard
Copy link
Copy Markdown
Member

@jbedard jbedard commented Jan 18, 2026

Fix #843

Changes are visible to end-users: no

Test plan

  • Covered by existing test cases
  • New test cases added

@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented Jan 18, 2026

Test (Bazel 6.x) (Test)

All tests were cache hits

179 tests (100.0%) were fully cached saving 9s.


Test (Bazel 7.x) (Test)

All tests were cache hits

179 tests (100.0%) were fully cached saving 13s.


Test (Bazel 8.x) (Test)

All tests were cache hits

179 tests (100.0%) were fully cached saving 12s.


Bazel-7

e2e/bzlmodules

All tests were cache hits

1 test (100.0%) was fully cached saving 32ms.


Bazel-8

e2e/bzlmodules

All tests were cache hits

1 test (100.0%) was fully cached saving 30ms.


Bazel-6

e2e/external_dep

All tests were cache hits

6 tests (100.0%) were fully cached saving 262ms.


Bazel-7

e2e/external_dep

All tests were cache hits

6 tests (100.0%) were fully cached saving 289ms.


Bazel-8

e2e/external_dep

All tests were cache hits

6 tests (100.0%) were fully cached saving 291ms.


Bazel-7

e2e/rules_js_v3

All tests were cache hits

1 test (100.0%) was fully cached saving 39ms.


Bazel-8

e2e/rules_js_v3

All tests were cache hits

1 test (100.0%) was fully cached saving 31ms.


Bazel-7

e2e/smoke

All tests were cache hits

2 tests (100.0%) were fully cached saving 107ms.


Bazel-8

e2e/smoke

All tests were cache hits

2 tests (100.0%) were fully cached saving 149ms.


Bazel-6

e2e/test

All tests were cache hits

179 tests (100.0%) were fully cached saving 9s.


Bazel-7

e2e/test

All tests were cache hits

179 tests (100.0%) were fully cached saving 13s.


Bazel-8

e2e/test

All tests were cache hits

179 tests (100.0%) were fully cached saving 12s.


Bazel-6

e2e/worker

All tests were cache hits

6 tests (100.0%) were fully cached saving 209ms.


Bazel-7

e2e/worker

All tests were cache hits

6 tests (100.0%) were fully cached saving 287ms.


Bazel-8

e2e/worker

All tests were cache hits

6 tests (100.0%) were fully cached saving 363ms.


Buildifier      Format

@jbedard jbedard force-pushed the 843-multiple branch 2 times, most recently from 26dad8d to e6b7968 Compare January 18, 2026 07:57
@jbedard jbedard marked this pull request as ready for review January 18, 2026 08:05
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3c2727d3b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ts/extensions.bzl
Comment on lines +10 to +16
selected = {}
for mod in module_ctx.modules:
is_root = hasattr(mod, "is_root") and mod.is_root
for attr in mod.tags.deps:
if attr.ts_version_from and hasattr(module_ctx, "watch"):
module_ctx.watch(attr.ts_version_from)
existing = selected.get(attr.name)
if existing and not is_root:
continue
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject conflicting npm_typescript versions

When multiple non-root modules register the same name but point at different ts_version/ts_version_from, the new de‑duplication silently keeps the first module in module_ctx.modules and drops the rest. In that scenario the dropped module is compiled with the wrong TypeScript compiler (whatever happened to be selected), which can change diagnostics or emitted JS. This only happens when dependency modules specify different TS versions and there is no root override. Previously this would error due to duplicate repo names; now it succeeds with a potentially incorrect toolchain. Consider validating that duplicate name entries are identical (or explicitly error) before picking one.

Useful? React with 👍 / 👎.

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.

@dzbarsky wdyt about this? I wonder if we should fail() if there are multiple non-root versions that differ? In which case it will fail() and the user must:

  • convince one of those non-root modules to use a unique name
  • explicitly declare a ts_version in the root to override those non-roots

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.

See followup commit for an example of that...

@jbedard jbedard merged commit b76a60a into aspect-build:main Jan 20, 2026
20 checks passed
@jbedard jbedard deleted the 843-multiple branch January 20, 2026 22:54
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.

[Bug]: Dependents of modules that use aspect_rules_ts cannot use aspect_rules_ts themselves

2 participants