[APPS] fix(apps): wrong connection IDs from mispaired module specifiers - #469
[APPS] fix(apps): wrong connection IDs from mispaired module specifiers#469sdkennedy2 wants to merge 1 commit into
Conversation
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…specifier
`collectStaticModuleDependencies` zipped the resolved dependency IDs the
bundler supplies against every static specifier found in the AST. Bundlers
report one entry per *unique* dependency, so a module importing the same
specifier twice yields more specifiers than resolved IDs and the pairing
slips by one from that point on — attributing imports to the wrong
dependency and dropping the last one entirely.
Verified against a real Rollup build. Six specifiers, five resolved IDs,
three mispaired:
./dup -> reexport.js (should be dup.js)
./reexport -> star.js (should be reexport.js)
./star -> zlast.js (should be star.js)
./zlast -> dropped
These pairings map an action-catalog call back to the module it came from
and feed importsByVariable / exportsByName / starExports, so a wrong
pairing can attribute a connectionId to the wrong file or miss it. Since
allowedConnectionIds is an allowlist, a miss is a functional break — and
the build still succeeds, so it fails silently. Present today on Vite 6/7.
Deduplicate specifiers by source string, preserving first-occurrence order.
Known gap, documented rather than fixed: Rollup dedups its resolved-ID list
by specifier string while Rolldown dedups by resolved module ID, both
verified against real builds. They agree unless one module imports the same
file through two different specifiers, which still mispairs under Rolldown.
Removing that dependence needs pairing by path correspondence instead of by
position, which is a larger change than this fix.
Also adds an end-to-end test driving connection ID collection through a real
vite.build() and asserting the exact collected IDs; it passes on master
unchanged, so it characterises existing behaviour.
Co-Authored-By: Claude <noreply@anthropic.com>
8db1359 to
cb0af18
Compare
|
@codex review Head is now |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Motivation
collectStaticModuleDependenciespairs the bundler's resolved dependency IDs against the AST's static specifiers by index. But bundlers report one entry per unique dependency, so a module that imports the same specifier twice yields more specifiers than IDs and the pairing slips by one from there on.Reproduced against a real Rollup build — 6 specifiers, 5 resolved IDs, 3 mispaired and 1 dropped:
./dup(2nd)reexport.js./reexportstar.jsreexport.js./starzlast.jsstar.js./zlastzlast.jsWhy it matters: these pairings map an action-catalog call back to its module and feed
importsByVariable/exportsByName/starExports. A wrong pairing can attribute aconnectionIdto the wrong file or miss it. SinceallowedConnectionIdsis an allowlist, a miss breaks the function at runtime — and the build still exits 0, so it fails silently.Live today on Vite 6/7 with plain Rollup. Unrelated to any bundler compatibility issue; it only shares a code path with #468.
Changes
Deduplicate the specifiers by source string, preserving first-occurrence order, so both sequences stay in step.
Known gap, documented rather than hidden. The two bundlers disagree on what "unique" means — verified against real builds, not assumed:
./dup.jsand./dupThey agree unless one module imports the same file through two different specifiers. In that case this fix is correct under Rollup and still mispairs under Rolldown. Closing that needs pairing by path correspondence instead of position — a larger change, so it's called out in the code comment and in the test that encodes the Rollup-specific expectation.
I also tried failing closed on a specifier/ID count mismatch. It broke 18 existing tests, because legitimate callers pass partial dependency lists — a build error there would be worse than the narrow remaining gap.
QA Instructions
No manual QA needed. Four unit cases cover the pairing (three fail without the fix), one asserts
importsByVariableresolves each binding to the right module, and a new end-to-end test drives connection-ID collection through a realvite.build()asserting the exact collected IDs — it passes onmasterunchanged, so it characterises existing behaviour before the fix moves it.Blast Radius
Only the Apps backend-function build path — how collected module records map imports to resolved modules, which feeds
allowedConnectionIds.This changes behaviour for existing Vite 6/7 users, which is the point: allowlists that were silently wrong become correct. Any app whose backend graph imports one specifier twice could previously have had a missing or misattributed connection ID. No dependency or public API changes.
Risk: moderate — it touches the allowlist path, so a mistake has runtime consequences. Mitigated by the tests above plus the end-to-end assertion of exact IDs.
Documentation
🤖 Generated with Claude Code