Repository navigation
packaging: slim the npm tarball and make pack-smoke measure the published tarball - #385
Merged
Merged
Conversation
…shed tarball (#191, #316) - files: stop shipping *.test-d.ts, *.testkit.ts, __snapshots__/, __cassettes__/ and apps/agent-forge/dist-server/*.map - tsup: emit SDK source maps without sourcesContent (sources still resolve to the shipped src/) - pack-smoke: also run build:studio so the packed tarball is the one prepublishOnly publishes; forbid test-like paths and the Forge server map; require the files lousho build and lousho studio need; set thresholds from the measured tarball with ~20% headroom Tarball: 873 entries / 13.5 MiB unpacked / 3.65 MiB packed (was 902 / 20.8 MiB / 5.6 MiB).
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.
Closes #191
Closes #316
Implements #191 option A (the ticket's recommended option): the issue had no owner answer recorded when work started, so this PR implements A as specified; B and C remain possible follow-ups if the owner prefers.
What changed
package.jsonfiles: added!src/**/*.test-d.ts,!src/**/*.testkit.ts,!src/**/__snapshots__and!apps/agent-forge/dist-server/*.map(after the positiveapps/agent-forge/dist-serverentry). Also added!src/**/__cassettes__— the owner's note on pack-smoke: the tarball size cap is reached (main at 14.63 of 14.68 MB) #316 says cassette/fixture exclusion is part of the same decision (__fixtures__was already excluded).src/stays.tsup.config.ts:esbuildOptionssetsoptions.sourcesContent = false, so the SDK's maps no longer embed the source a second time. Verifieddist/index.js.maphas nosourcesContentand all 31sourcesentries still resolve fromdist/to../src/...files that ship in the package.scripts/pack-smoke.ts:main()also runsnpm run build:studio(unless--skip-build), so it packs the tarballprepublishOnlyactually publishes — previously it skipped the Agent Forge build and measured a tarball ~5 MB smaller than the real one.ALLOWED_TEST_LIKE; added/\.test-d\.ts$/,/\.testkit\.ts$/,/__snapshots__\//,/__cassettes__\//and/^apps\/agent-forge\/dist-server\/.*\.map$/toFORBIDDEN_PATHS.REQUIRED_PATHS: the tarball must containsrc/index.ts,src/deploy/runtime.worker.ts,src/deploy/shims/node.worker.ts(the Worker/node-server bundles read them viasrc/deploy/bundle.ts) andapps/agent-forge/dist-server/index.cjs,apps/agent-forge/dist/index.html(lousho studio).MAX_ENTRIES900 → 1050 (measured 873),MAX_UNPACKED_BYTESstays 16 MiB (measured 13.5 MiB),MAX_PACKED_BYTESstays 4.5 MiB (measured 3.65 MiB).CHANGELOG.md: entry under## [Unreleased]→ Changed. No docs state the package size, so no docs changes;npm run docs:llms:checkpasses.Measured tarball (
npm pack --dry-run --json, afternpm run build+npm run build:studio)(
dist/**/*.mapalone: 8,040,032 B → 2,699,298 B.) For reference, the1.0.0-alpha.8baseline cited in #191 was 720 files / 16.5 MB / 4.4 MB — this also lands under it. Thepack-smokeunpacked cap of 16 MiB now has ~2.5 MiB of headroom instead of the 45 KB that triggered #316.None of the 15 test-only files (nor the newer
*.test-d.ts/*.testkit.tsfiles added since alpha.8) ship;src/testing/*and the cassettes' runtime readersrc/testing/recordReplay.tsstill do.Checks
npm run pack-smoke: passes —873 entries, 13.5 MB unpacked, 3.6 MB packed, publish dry-run ok, ESM+CJS loads,lousho --help/doctor,tscbundler+node16,create-lousho-agent --help.!src/**/*.test-d.tsfromfilesmakes pack-smoke fail with 17tarball contains forbidden file src/**.test-d.tserrors (then reverted).npm run test:coverage: 295 test files passed, 1 skipped.npx tsc --noEmit: clean.npm run lint: clean.npm run test:types: 17 files / 79 tests, no type errors.npm run fallow: fails withdead-code (10 issues), dupes (5 clone groups), health (6 above threshold)— identical failure on main's CI (e.g. run 37184342607), pre-existing and unrelated to this diff (nosrc/changes).Functional proof (issue item 4)
Installed the packed tarball in a fresh project (
npm install <tarball> tsup wrangler ai zod @ai-sdk/openai @ai-sdk/anthropic @modelcontextprotocol/sdk) with a yaml spec (provider: { type: mock },tools: [current-date]):lousho studioalso works from the installed package (R1a is merged):