Fix: derive the bundled outfile from the entry in integrations/build.js - #784
Open
AmaadMartin wants to merge 3 commits into
Open
Fix: derive the bundled outfile from the entry in integrations/build.js#784AmaadMartin wants to merge 3 commits into
AmaadMartin wants to merge 3 commits into
Conversation
The bundled branch hardcoded the output filename to index.js, so the web target compiled src/index_web.ts into dist/web/index.js. The path integrations/package.json advertises as "browser", dist/web/index_web.js, was never emitted by npm run build:bundle. Derive the filename from the entry instead. The esm and cjs targets are unchanged because their entry is already index.ts.
7 tasks
added 2 commits
August 7, 2026 11:20
esbuild derives each output filename from its entry when outdir is set, so the bundled branch does not need to name the file itself. Giving both modes the same outdir collapses the branch to two lines and removes the hand-rolled extension swap. Output is byte-identical to the outfile-based fix in both modes, and the unbundled output is byte-identical to main. The bundled test case now also asserts the browser target holds exactly one .js file. The entry list is the only remaining difference between the two modes, so without it a build:bundle that stopped bundling would pass.
Both fields are unconditional once the bundle branch is gone, so assigning them after construction buys nothing and separates the two banner conditionals. Post-construction mutation is now reserved for banner, which is the only genuinely conditional field. The emitted dist/ is byte-identical in both modes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
N/A
Problem:
integrations/build.jshardcoded the bundled output filename toindex.js, ignoring the entry it was given. The web target therefore compiledsrc/index_web.tsintodist/web/index.js, anddist/web/index_web.jswas never emitted. That is the pathintegrations/package.jsonadvertises as"browser", so afternpm run build:bundlethe field dangles. The unbundled build is unaffected because it globs./src/**/*.tsintooutdirand ignoresentry.Solution: Drop
outfileand give both modes the sameoutdir. esbuild then derives each output filename from its entry, which is the naming the bundled branch was doing by hand and getting wrong. Both fields are unconditional once the branch is gone, so they move into thebuildOptionsliteral:Post-construction mutation is left to
banner, the only field that is still conditional.esmandcjsare unchanged because their entry is alreadyindex.ts, somainandmodulekeep resolving. I diffed the whole ofdist/before and after: both the bundled and the unbundled output are byte-identical to anoutfile-based fix, and the unbundled output is byte-identical tomain.Measured on this branch:
core/build.jshas the identical defect and is deliberately out of scope.core/build.js:65-71hardcodes the sameoutfile,core/build.js:109passesentry: 'index_web.ts', andcore/package.jsondeclares the same"browser": "./dist/web/index_web.js"— sonpm run build:bundle --workspace corebreaks that field too.I am not fixing it here because google#614 is open and already fixes it, with the same outfile hunk plus a rewrite of the rest of that function: new browser targets,
packages: 'browser' ? 'bundle' : 'external', analiasblock of browser shims,format === 'esm' && platform === 'node'banner gating, and a web target forced tobundle: true. Editingcore/build.json this branch would collide with a live review for no gain. When #614 lands,core/build.jscan take this sameoutdircollapse as a follow-up; that is a strictly smaller change than the one #614 is already carrying.Collision check, per the contribution workflow: five open PRs also edit
integrations/build.js(#430, #552, #553, #555, #670). All five change the license banner and thecreateRequirepreamble. None touches theoutfileassignment, so this branches frommainrather than stacking.Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.
New file
tests/integration/build_setup/integrations_build_test.tsruns both build scripts and asserts that the files named bybrowser,mainandmoduleall exist and are non-empty. It reads those paths fromintegrations/package.jsoninstead of hardcoding them, so it checks the actual manifest contract.The bundled case also asserts that the browser target holds exactly one
.jsfile. Sharing oneoutdirbetween the two modes means the entry list is now the only difference between them, so without that assertion the two cases assert the same thing and abuild:bundlethat quietly stopped bundling would still pass. Mutation 2 below is that regression.It had to go under
tests/integration/rather thanintegrations/test/:npm run test:coverage, the command CI runs, does not run theunit:integrationsvitest project.Each case deletes
integrations/distbefore it builds. Without that both cases pass on the unfixed code, because CI's earliernpm run buildstep leaves a validdist/web/index_web.json disk. The bundled case runs first, so the tree is left holding the plain build's output. Nothing else in the repo readsintegrations/dist— every vitest project aliases@google/adk-integrationstointegrations/src.Mutation checks. Four mutations were run against the final code and every one failed.
integrations/build.jsexactly as onmain:The unbundled case still passes, which is the right split: the test pins the bundled path specifically, not merely that a build ran.
build:bundleglobs every source instead of bundling the entry:${targetDir}fromoutdir, which proves both cases carry signal:index.ts, which is the defect restated at the entry rather than the outfile:Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.
Local validation on the pushed commit:
npx tsc --noEmitreports pre-existing errors elsewhere undercore/test, unrelated to this change and not run by CI.CI is green on all three legs of the validation matrix, plus
check-licenseand the cross-language job. The new test ran and passed on each leg. It takes 2.8s onwindows-latest, the leg at risk, because it shells out tonpm run ... --workspace integrations.Earlier attempts on this same commit were red on three pre-existing timeout flakes this change does not touch:
tests/integration/app_loader/app_loader_test.ts,core/test/code_executors/unsafe_local_code_executor_test.tsandtests/integration/build_setup/build_setup_test.ts.They are not mine. Across the last 20 failed validation runs on this fork,
app_loader_test.tstimes out on 13 branches, includingmainitself and theci-control-main-baselinebranch. The other two time out on four more branches that do not carry this change. Two further observations rule out an indirect effect:unsafe_local_code_executor_test.tstimed out at 18:47:25 and the new build test ran at 18:51:45. The failure preceded my test by four minutes, so the builds it shells out to were not starving it.integrations/dist, but nothing in the suite reads it. Every vitest project aliases@google/adk-integrationstointegrations/src, and thebuild_setupfixtures depend only oncoreanddev, neither of which depends onintegrations.I am not fixing these flakes here, because they are unrelated breakage.
Checklist
[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.