Skip to content

fix: ship with zero runtime dependencies, and check it - #10

Merged
MeAkib merged 1 commit into
mainfrom
fix/zero-dependencies
Sep 22, 2026
Merged

MeAkib merged 1 commit into
mainfrom
fix/zero-dependencies

Conversation

@MeAkib

@MeAkib MeAkib commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Bundlephobia reported "1 dependency" for 0.0.2, beside a README that says none. The dependency was tslib, and the built code never imported it: the published FESM imports exactly one module, @angular/core, which is a peer.

It got there because ng-packagr injects tslib into the built package.json unconditionally whenever a library does not declare it — there is no option to turn that off, so removing it from the source package.json is not enough.

  • Remove the declaration from the library's package.json.
  • Set importHelpers: false in the library tsconfig, so any helper TypeScript ever needs is inlined rather than imported from tslib. Output is unchanged today (8.6 KB, byte-identical size) because an ES2022 target needs none.
  • strip-tslib.mjs removes the entry ng-packagr writes, as part of build:lib, so npm run release publishes the corrected file.
  • verify-deps.mjs fails if package.json declares any dependency, or if the built code imports any module that is not a declared peer. The second check is what makes stripping safe: a build that genuinely needed tslib would fail CI rather than break a consumer.
  • CI runs it on every pull request.

Confirmed the check catches the bug before trusting it: against the 0.0.2 build it fails with "package.json declares dependencies: tslib"; after the fix it passes. 185 tests pass, and verify:compat installs the tarball and builds a real app cleanly on Angular 17 and 22.

What does this change?

How to see it

Checks

  • npm test passes
  • npm run format run on the files I touched
  • Added a test, if this fixes a bug — one that fails before the change and passes after
  • npm run verify:compat, if I changed anything public (builds a real app on Angular 17–22)

Bundlephobia reported "1 dependency" for 0.0.2, beside a README that says
none. The dependency was tslib, and the built code never imported it: the
published FESM imports exactly one module, @angular/core, which is a peer.

It got there because ng-packagr injects tslib into the built package.json
unconditionally whenever a library does not declare it — there is no option to
turn that off, so removing it from the source package.json is not enough.

- Remove the declaration from the library's package.json.
- Set importHelpers: false in the library tsconfig, so any helper TypeScript
  ever needs is inlined rather than imported from tslib. Output is unchanged
  today (8.6 KB, byte-identical size) because an ES2022 target needs none.
- strip-tslib.mjs removes the entry ng-packagr writes, as part of build:lib, so
  `npm run release` publishes the corrected file.
- verify-deps.mjs fails if package.json declares any dependency, or if the
  built code imports any module that is not a declared peer. The second check
  is what makes stripping safe: a build that genuinely needed tslib would fail
  CI rather than break a consumer.
- CI runs it on every pull request.

Confirmed the check catches the bug before trusting it: against the 0.0.2
build it fails with "package.json declares dependencies: tslib"; after the
fix it passes. 185 tests pass, and verify:compat installs the tarball and
builds a real app cleanly on Angular 17 and 22.
@vercel

vercel Bot commented Sep 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
masonry-angular Ready Ready Preview Sep 22, 2026 9:07am UTC
masonry-angular-examples Ready Ready Preview Sep 22, 2026 9:07am UTC

@MeAkib
MeAkib merged commit b65652f into main Sep 22, 2026
9 checks passed

This branch was successfully deployed

2 active deployments
Preview – masonry-angular 018b52fa Deployed Sep 22, 2026 by vercel[bot]
Preview – masonry-angular-examples 018b52fa Deployed Sep 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant