Skip to content

fix: exclude test files from npm package#1203

Merged
developerkunal merged 1 commit into
masterfrom
fix/exclude-tests-from-npm-package
Oct 13, 2025
Merged

fix: exclude test files from npm package#1203
developerkunal merged 1 commit into
masterfrom
fix/exclude-tests-from-npm-package

Conversation

@developerkunal
Copy link
Copy Markdown
Contributor

@developerkunal developerkunal commented Oct 10, 2025

Changes

This PR excludes test files from the npm package build, significantly reducing the package size distributed to end users.

What changed:

  • Added exclude patterns to tsconfig.cjs.json and tsconfig.esm.json to prevent test files from being compiled into the dist directory
  • Excluded patterns: **/*.test.ts, **/*.spec.ts, and **/tests/**

Why this is important:

  • Test files were being unnecessarily included in the npm package, inflating the package size
  • Users downloading the package had to download and store ~6 MB of test files they don't need
  • Both TypeScript config files are protected in .fernignore, so these changes won't be overwritten by the SDK generator

Impact:

  • Package size (compressed): Reduced from 1.6 MB to 947.6 kB (41% reduction)
  • Unpacked size: Reduced from 15.9 MB to 8.3 MB (48% reduction)
  • File count: Reduced from 8,977 files to 8,068 files (909 fewer files)

Files modified:

  • tsconfig.cjs.json - Added exclude patterns
  • tsconfig.esm.json - Added exclude patterns

Note: Both files are already listed in .fernignore (lines 30-31), so these changes are safe from being overwritten during SDK regeneration.

References

  • Internal investigation found that npm pack was including test files from src/management/tests/
  • 536 test-related files were being included in the distributed package

Testing

Manual testing performed:

  • ✅ Cleaned and rebuilt the project: rm -rf dist && npm run build
  • ✅ Verified test files are excluded: npm pack --dry-run 2>&1 | grep -c "tests/" returns 0
  • ✅ Confirmed package size reduction
  • ✅ Verified no test directories in dist: find dist -type d -name "tests" returns empty

What was tested:

  • Build process completes successfully with the exclude patterns
  • Test files are not present in the compiled dist directory
  • Package contents verified with npm pack --dry-run

What was not tested:

  • Existing unit/integration tests were not run as this change only affects the build output, not the code functionality
  • This change adds unit test coverage - N/A (build configuration change)
  • This change adds integration test coverage - N/A (build configuration change)

Checklist

- Added exclude patterns to tsconfig.cjs.json and tsconfig.esm.json
@developerkunal developerkunal requested a review from a team as a code owner October 10, 2025 13:32
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.20%. Comparing base (c827069) to head (c9bf375).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1203   +/-   ##
=======================================
  Coverage   79.20%   79.20%           
=======================================
  Files         580      580           
  Lines       18155    18155           
  Branches     8617     8617           
=======================================
  Hits        14379    14379           
  Misses       3776     3776           
Flag Coverage Δ
alltests 79.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@developerkunal developerkunal merged commit aa4c592 into master Oct 13, 2025
10 checks passed
@developerkunal developerkunal deleted the fix/exclude-tests-from-npm-package branch October 13, 2025 06:33
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.

3 participants