Repository navigation
fix(gaxios): exclude compiled tests and .tsbuildinfo from published tarball - #9612
Merged
quirogas merged 1 commit intoOct 14, 2026
Merged
Conversation
…arball ## Description This change updates the `files` allowlist in `core/packages/gaxios/package.json` from `["build/"]` to `["build/cjs/src", "build/esm/src", "build/esm/package.json", "!build/**/*.map"]` so that compiled test artifacts, `.tsbuildinfo` incremental caches, and source maps are excluded from the published npm tarball (b/572989218). ## Impact Reduces the published `gaxios` tarball from 78 files (`738.4 kB` unpacked / `109.8 kB` compressed) to 28 files (`161.5 kB` unpacked / `26.1 kB` compressed) by eliminating `~488 kB` (66.1%) of compiled `test/`, `browser-test/`, `system-test/`, and `.tsbuildinfo` build-cache bloat across all downstream Google Cloud Node.js installs. ## Changes - `core/packages/gaxios/package.json`: Replace `"files": ["build/"]` with `["build/cjs/src", "build/esm/src", "build/esm/package.json", "!build/**/*.map"]`. - `core/packages/gaxios/test/test.getch.ts`: Add a unit test verifying that `package.json` `files` includes `build/cjs/src`, `build/esm/src`, and `build/esm/package.json` and does not include `build/` as a wildcard. ## Testing - Executed `npm test` and `JS_RUNTIME=bun npm test` in `core/packages/gaxios` (135 passing in both runtimes). - Verified `npm pack --dry-run` in `core/packages/gaxios` packs 28 files (`build/cjs/src/*`, `build/esm/src/*`, `build/esm/package.json`, `package.json`, `README.md`, `LICENSE`) with zero `test/`, `browser-test/`, `system-test/`, or `.tsbuildinfo` files. - Verified `GIT_DIFF_ARG=origin/main node ./bin/linter.mjs --strict` passes. ## Alternatives - Leaving `"files": ["build/"]` in `core/packages/gaxios/package.json` was rejected because `tsconfig.base.json` compiles `test/*.ts`, `browser-test/*.ts`, and `system-test/*.ts` during `prepare`, causing every `gaxios` consumer to download compiled test suites and `.tsbuildinfo` files.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the files field in package.json to restrict the published files to specific build directories and exclude map files, and adds a corresponding test to verify this allowlist. The review feedback suggests making the test less brittle by asserting the inclusion of specific paths rather than asserting exact array equality.
Comment on lines
+1990
to
+1996
| assert.deepStrictEqual(pkgFiles, [ | ||
| 'build/cjs/src', | ||
| 'build/esm/src', | ||
| 'build/esm/package.json', | ||
| '!build/**/*.map', | ||
| ]); | ||
| assert.strictEqual(pkgFiles?.includes('build/'), false); |
Contributor
There was a problem hiding this comment.
Asserting the exact array equality for package.json files makes the test brittle to future additions of other files or assets to the allowlist. It is more robust to assert the presence of the required build directories and the absence of the wildcard build/ directory individually.
assert.ok(pkgFiles?.includes('build/cjs/src'));
assert.ok(pkgFiles?.includes('build/esm/src'));
assert.ok(pkgFiles?.includes('build/esm/package.json'));
assert.ok(pkgFiles?.includes('!build/**/*.map'));
assert.strictEqual(pkgFiles?.includes('build/'), false);
danieljbruce
approved these changes
Oct 14, 2026
Merged
quirogas
added a commit
that referenced
this pull request
Oct 14, 2026
…tEqual (#9626) ## Description Replaces the `assert.deepStrictEqual(pkgFiles, [...])` assertion in `core/packages/gaxios/test/test.getch.ts` (added in #9612) with a minimal per-entry `pkgFiles?.includes(file)` check. ## Impact Avoids coupling the test to the exact array ordering or disallowing future additions to `package.json` `"files"`, while keeping the test minimal (+4/-2 lines), self-contained, and aligned with the existing assertion style in `test.getch.ts`. ## Changes - `core/packages/gaxios/test/test.getch.ts`: - Replace `assert.deepStrictEqual(pkgFiles, [...])` with a `for (const file of [...])` loop asserting `assert.strictEqual(pkgFiles?.includes(file), true)` for each required entry alongside `assert.strictEqual(pkgFiles?.includes('build/'), false)`. ## Testing - `npm test` in `core/packages/gaxios` (Node.js) - `JS_RUNTIME=bun npm test` in `core/packages/gaxios` (Bun) - `GIT_DIFF_ARG=origin/main node ./bin/linter.mjs --strict` ## Alternatives - Keeping `assert.deepStrictEqual(pkgFiles, [...])` was rejected because it couples the assertion to exact array ordering and length. - Shelling out to `npm pack --dry-run` with regex path matching was rejected as overengineered for a fast unit test.
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.
Description
This change updates the
filesallowlist incore/packages/gaxios/package.jsonfrom["build/"]to["build/cjs/src", "build/esm/src", "build/esm/package.json", "!build/**/*.map"]so that compiled test artifacts,.tsbuildinfoincremental caches, and source maps are excluded from the published npm tarball (b/572989218).Impact
Reduces the published
gaxiostarball from 78 files (738.4 kBunpacked /109.8 kBcompressed) to 28 files (161.5 kBunpacked /26.1 kBcompressed) by eliminating~488 kB(66.1%) of compiledtest/,browser-test/,system-test/, and.tsbuildinfobuild-cache bloat across all downstream Google Cloud Node.js installs.Changes
core/packages/gaxios/package.json: Replace"files": ["build/"]with["build/cjs/src", "build/esm/src", "build/esm/package.json", "!build/**/*.map"].core/packages/gaxios/test/test.getch.ts: Add a unit test verifying thatpackage.jsonfilesincludesbuild/cjs/src,build/esm/src, andbuild/esm/package.jsonand does not includebuild/as a wildcard.Testing
npm testandJS_RUNTIME=bun npm testincore/packages/gaxios(135 passing in both runtimes).npm pack --dry-runincore/packages/gaxiospacks 28 files (build/cjs/src/*,build/esm/src/*,build/esm/package.json,package.json,README.md,LICENSE) with zerotest/,browser-test/,system-test/, or.tsbuildinfofiles.GIT_DIFF_ARG=origin/main node ./bin/linter.mjs --strictpasses.Alternatives
"files": ["build/"]incore/packages/gaxios/package.jsonwas rejected becausetsconfig.base.jsoncompilestest/*.ts,browser-test/*.ts, andsystem-test/*.tsduringprepare, causing everygaxiosconsumer to download compiled test suites and.tsbuildinfofiles.