Skip to content

Commit bb9e507

Browse files
perf(packages): ship npm packages without source maps and guard their size in CI (#5403)
* perf(packages): ship npm packages without source maps and guard their size in CI No package or consumer reads the published source maps, so they are no longer built. The CLI copies only the studio app it serves instead of the whole studio dist. verify:packed-manifests now holds every published package to a size budget that ratchets down, and CI rejects pull requests that add a large binary outside LFS. * fix(ci): large-binary check reads every filename and fails on git errors * ci: run only Build when a skill bundled into the CLI changes * fix(ci): size guards also catch type changes, odd file names, unreadable blobs and bad budgets * fix(ci): large-binary check reads blobs by id and skips submodules * fix(ci): exempt only exact registry copies under docs/public/catalog * test(ci): cover the staged catalog-copy exemption; drop the local-only override hint in CI * fix(ci): producer budget follows its slimmed package; size checks name their real cause
1 parent b6467d9 commit bb9e507

28 files changed

Lines changed: 452 additions & 72 deletions

‎.github/workflows/ci.yml‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
code: ${{ (github.event_name == 'workflow_dispatch' && inputs.catalog_publish) && 'true' || steps.filter.outputs.code }}
7070
docs_catalog: ${{ steps.filter.outputs.docs_catalog }}
7171
cli: ${{ steps.filter.outputs.cli }}
72+
cli_bundle: ${{ steps.filter.outputs.cli_bundle }}
7273
skills: ${{ steps.filter.outputs.skills }}
7374
catalog_index: ${{ steps.filter.outputs.catalog_index }}
7475
codex_plugin: ${{ steps.filter.outputs.codex_plugin }}
@@ -94,6 +95,11 @@ jobs:
9495
git rev-parse --verify -q HEAD^2 > /dev/null || { echo "::error::HEAD is not the pull request merge commit"; exit 1; }
9596
sha="$(git rev-parse --verify HEAD^1)"
9697
echo "sha=$sha" >> "$GITHUB_OUTPUT"
98+
- name: Reject large binaries outside LFS
99+
if: github.event_name == 'pull_request'
100+
env:
101+
BASE_SHA: ${{ steps.base.outputs.sha }}
102+
run: sh scripts/check-large-files.sh --range "$BASE_SHA" HEAD
97103
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4
98104
id: filter
99105
with:
@@ -131,6 +137,12 @@ jobs:
131137
- "package.json"
132138
- "bun.lock"
133139
- ".github/workflows/ci.yml"
140+
# Skills packages/cli/scripts/build-copy.mjs bundles into the CLI tarball (size budget).
141+
cli_bundle:
142+
- "skills/hyperframes/**"
143+
- "skills/hyperframes-cli/**"
144+
- "skills/gsap/**"
145+
- "skills/media-use/**"
134146
skills:
135147
- "scripts/generate-captured-font-copies.mjs"
136148
- "packages/cli/src/media-use/**"
@@ -243,14 +255,14 @@ jobs:
243255
name: Build
244256
needs: changes
245257
# A skipped required check passes, so a broken change detection must fail it instead.
246-
if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true') }}
258+
if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.code == 'true' || needs.changes.outputs.cli_bundle == 'true') }}
247259
runs-on: ubuntu-latest
248260
timeout-minutes: 10
249261
steps:
250262
- name: Require change detection
251263
if: needs.changes.result != 'success'
252264
run: |
253-
echo "::error::Change detection did not succeed, so this required check cannot pass."
265+
echo "::error::Detect changes did not succeed (it also rejects large binaries outside LFS); see its log. This required check cannot pass."
254266
exit 1
255267
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
256268
with:
@@ -437,7 +449,7 @@ jobs:
437449
- name: Require change detection
438450
if: needs.changes.result != 'success'
439451
run: |
440-
echo "::error::Change detection did not succeed, so this required check cannot pass."
452+
echo "::error::Detect changes did not succeed (it also rejects large binaries outside LFS); see its log. This required check cannot pass."
441453
exit 1
442454
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
443455
with:
@@ -543,7 +555,7 @@ jobs:
543555
- name: Require change detection
544556
if: needs.changes.result != 'success'
545557
run: |
546-
echo "::error::Change detection did not succeed, so this required check cannot pass."
558+
echo "::error::Detect changes did not succeed (it also rejects large binaries outside LFS); see its log. This required check cannot pass."
547559
exit 1
548560
- name: Require producer source tests
549561
if: needs.changes.outputs.code == 'true' && needs.producer-source-tests.result != 'success'
@@ -772,7 +784,7 @@ jobs:
772784
- name: Require change detection
773785
if: needs.changes.result != 'success'
774786
run: |
775-
echo "::error::Change detection did not succeed, so this required check cannot pass."
787+
echo "::error::Detect changes did not succeed (it also rejects large binaries outside LFS); see its log. This required check cannot pass."
776788
exit 1
777789
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
778790
with:

‎lefthook.yml‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@ pre-commit:
3333
# The prune keeps one audit base cache per checkout; the commit gets the audit's own status.
3434
run: env -u GIT_DIR -u GIT_INDEX_FILE -u GIT_WORK_TREE sh -c 'bunx fallow audit --base origin/main --fail-on-issues; status=$?; bun scripts/prune-fallow-audit-caches.mjs origin/main; exit $status'
3535
largefiles:
36-
# Reject large binaries committed straight into the git pack instead of
37-
# LFS. The script reads the staged set itself (via `git diff --cached`)
38-
# rather than taking lefthook's `{staged_files}` expansion, which would
39-
# split paths containing spaces. It skips files under the limit, anything
40-
# routed through LFS, and registry/ assets. Tune via HF_MAX_NONLFS_KB.
36+
# Rejects staged binaries over the limit that are not LFS pointers; see
37+
# the script header. CI runs the same script with --range.
4138
run: ./scripts/check-large-files.sh
4239
tracked-artifacts:
4340
# Keep ignored dependency trees and platform metadata out of commits.

‎packages/aws-lambda/build.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const sharedOpts = {
2929
target: "node22",
3030
format: "esm",
3131
minify: false,
32-
sourcemap: true,
3332
external: [
3433
"@aws-sdk/client-s3",
3534
"@aws-sdk/client-sfn",

‎packages/aws-lambda/tsconfig.build.json‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"noEmit": false,
66
"outDir": "./dist",
77
"rootDir": "./src",
8-
"declaration": true,
9-
"declarationMap": true,
10-
"sourceMap": true
8+
"declaration": true
119
}
1210
}

‎packages/cli/scripts/build-copy.mjs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ async function main() {
6666

6767
const studioDist = resolve(CLI_ROOT, "..", "studio", "dist");
6868
await waitForStudioDist(studioDist);
69-
copyDirContents(studioDist, join(DIST, "studio"));
69+
// Only the SPA studioServer.ts serves (index.html, /assets, /icons, /favicon.svg);
70+
// the rest of studio/dist is the npm library build.
71+
for (const entry of ["index.html", "assets", "icons", "favicon.svg"]) {
72+
copyDir(join(studioDist, entry), join(DIST, "studio", entry));
73+
}
7074

7175
for (const tmpl of ["blank", "from-file", "_shared"]) {
7276
copyDir(join(CLI_ROOT, "src", "templates", tmpl), join(DIST, "templates", tmpl));

‎packages/core/package.json‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"files": [
1111
"dist/**/*.js",
1212
"dist/**/*.d.ts",
13-
"dist/**/*.d.ts.map",
14-
"dist/**/*.js.map",
1513
"!dist/hyperframe.runtime.mjs",
1614
"docs",
1715
"schemas",

‎packages/core/tsconfig.json‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
"esModuleInterop": true,
99
"skipLibCheck": true,
1010
"declaration": true,
11-
"declarationMap": true,
12-
"sourceMap": true,
1311
"outDir": "./dist",
1412
"rootDir": "./src"
1513
},

‎packages/engine/tsconfig.json‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"outDir": "./dist",
1111
"rootDir": "./src",
1212
"declaration": true,
13-
"declarationMap": true,
14-
"sourceMap": true,
1513
"types": ["@webgpu/types"]
1614
},
1715
"include": ["src/**/*"],

‎packages/gcp-cloud-run/build.mjs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const sharedOpts = {
3030
target: "node22",
3131
format: "esm",
3232
minify: false,
33-
sourcemap: true,
3433
external: [
3534
"@google-cloud/storage",
3635
"@google-cloud/workflows",

‎packages/gcp-cloud-run/tsconfig.build.json‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"noEmit": false,
66
"outDir": "./dist",
77
"rootDir": "./src",
8-
"declaration": true,
9-
"declarationMap": true,
10-
"sourceMap": true
8+
"declaration": true
119
}
1210
}

0 commit comments

Comments
 (0)