feat(construct): opt-in slim (unbundled) build to cut ~225MB install cost [DRAFT/RFC]#3514
Draft
osama-rizk wants to merge 1 commit into
Draft
feat(construct): opt-in slim (unbundled) build to cut ~225MB install cost [DRAFT/RFC]#3514osama-rizk wants to merge 1 commit into
osama-rizk wants to merge 1 commit into
Conversation
…RFC] Adds scripts/pack-slim-construct.ts: produces a slim, UNbundled .tgz for the data-construct / graphql-api-construct packages by removing bundledDependencies from a throwaway copy before npm pack. Every bundled dep is also a regular dependency, so a pure-npm consumer resolves identical versions from the registry with a much smaller/faster install (the bundled closure is ~225MB / ~480 files per construct and cannot be opted out of via overrides — see aws-amplify#3464). Purely additive and opt-in: the default bundledDependencies build/publish and verify-construct-dependencies are unchanged, so existing customers and jsii targets are unaffected. HOW to publish the slim artifact (separate -slim name vs. opt-in dist-tag) is left as a maintainer decision — see scripts/README-slim-construct-build.md. Draft/RFC to start the discussion; not for merge as-is.
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.
Problem
@aws-amplify/data-constructand@aws-amplify/graphql-api-constructship their non-jsii dependency closure viabundledDependencies(derived from each package'snonJsiiDependencies.json, enforced byscripts/verify-construct-dependencies.ts). That closure is large — each construct unpacks to roughly 225 MB / ~480 nested files.For pure-npm / TypeScript consumers (e.g.
aws-amplify/amplify-backend), this dominatesnpm installtime, and is ~2x worse on Windows CI where antivirus scans every extracted file on close. Because the deps are physically inside the published tarball, consumers cannot opt out viaoverrides/resolutions— see #3464.Key observation: every bundled dependency is also declared as a normal
dependenciesentry (I verified: 144 bundled, 0 that aren't also regular deps). So for a pure-npm consumer an unbundled tarball resolves the exact same packages+versions from the registry (npm hoists/dedupes normally) — a smaller, faster install with identical resolved code, and one consumers can patch viaoverrides.What this PR adds
A single additive, opt-in script —
scripts/pack-slim-construct.ts(root:yarn pack-slim-construct <constructPackageDir>):bundledDependenciesfrom the copy'spackage.json(leavingdependenciesintact) and annotates it (amplifySlimBuild: true).npm packs the copy to emit a slim.tgz.The default
bundledDependenciesbuild — what every existing customer and every jsii/multi-language target consumes — is untouched.Explicitly out of scope (maintainer decisions)
@aws-amplify/*-slimpackage name, or an opt-inslimdist-tag."targets": {}(JS/TS only).Compatibility
verify-construct-dependenciesare unchanged.dependencies), differing only in delivery (registry-resolved vs. tarball-embedded).Related
overrides/resolutions.Testing done
Verified the transform against
packages/amplify-data-construct/package.json: 144bundledDependenciesremoved, 0 of them lost (all present in the 145 regulardependencies), resultingpackage.jsonhas nobundledDependencies. Script typechecks undertsc --module nodenext.Filed from a consumer perspective (amplify-backend e2e install-time investigation). Happy to iterate on the publish mechanism you'd prefer.