[PR #11] [MERGED] Optimize CLI bundle size with esbuild #9

Closed
opened 2026-03-04 01:38:07 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/tuanngocptn/nport/pull/11
Author: @tuanngocptn
Created: 1/27/2026
Status: Merged
Merged: 1/27/2026
Merged by: @tuanngocptn

Base: mainHead: feat/optimize_size


📝 Commits (4)

  • 487044c Update build process and dependencies for NPort CLI
  • ad7b63f Enhance build script for watch mode in NPort CLI
  • 6ccc86d Update GitHub Actions test-smoke workflow for NPort
  • 58bfa00 Release v2.1.2 - Optimize build process and enhance testing

📊 Changes

7 files changed (+799 additions, -128 deletions)

View changed files

📝 .github/workflows/test-smoke.yml (+33 -10)
📝 CHANGELOG.md (+57 -0)
📝 package-lock.json (+573 -106)
📝 package.json (+7 -6)
scripts/build.js (+123 -0)
📝 src/index.ts (+1 -2)
📝 tsconfig.json (+5 -4)

📄 Description

Summary

  • Replace tsc with esbuild for bundling, enabling minification, tree-shaking, and single-file output
  • Reduce npm package footprint by trimming included files (only postinstall.js script, removed CHANGELOG.md)
  • Disable TypeScript declaration and source map generation for smaller output
  • Improve development experience with faster watch mode (minification disabled during dev)

Changes

Build System

  • Add new scripts/build.js using esbuild to bundle the CLI
  • Bundle main entry point (src/index.tsdist/index.js) and bin-manager separately
  • External dependencies (axios, chalk, ora) kept external to avoid CJS/ESM issues
  • Shebang now added via esbuild banner instead of source file

Package Optimization

  • Update files in package.json to only include necessary files
  • Disable declaration and sourceMap in tsconfig.json
  • Add noEmit: true to tsconfig (esbuild handles output)

CI/CD

  • Enhance smoke test workflow to simulate npm pack/install flow
  • Test installation from generated tarball for accurate packaging validation

Test Plan

  • Run npm run build and verify output size reduction
  • Run npm run dev and verify watch mode works
  • Run npm test to ensure no regressions
  • Run npm pack and inspect tarball contents
  • Install from tarball and test CLI functionality

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/tuanngocptn/nport/pull/11 **Author:** [@tuanngocptn](https://github.com/tuanngocptn) **Created:** 1/27/2026 **Status:** ✅ Merged **Merged:** 1/27/2026 **Merged by:** [@tuanngocptn](https://github.com/tuanngocptn) **Base:** `main` ← **Head:** `feat/optimize_size` --- ### 📝 Commits (4) - [`487044c`](https://github.com/tuanngocptn/nport/commit/487044c3f79ea8898cb8030f4ebb1778596842d2) Update build process and dependencies for NPort CLI - [`ad7b63f`](https://github.com/tuanngocptn/nport/commit/ad7b63f8c6e5098f7ec373d6f5e0303e04df1268) Enhance build script for watch mode in NPort CLI - [`6ccc86d`](https://github.com/tuanngocptn/nport/commit/6ccc86d4214e299e86f5df9a1f125e1510e840d4) Update GitHub Actions test-smoke workflow for NPort - [`58bfa00`](https://github.com/tuanngocptn/nport/commit/58bfa00a053637b4d3acb6cdb7ac276900242418) Release v2.1.2 - Optimize build process and enhance testing ### 📊 Changes **7 files changed** (+799 additions, -128 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/test-smoke.yml` (+33 -10) 📝 `CHANGELOG.md` (+57 -0) 📝 `package-lock.json` (+573 -106) 📝 `package.json` (+7 -6) ➕ `scripts/build.js` (+123 -0) 📝 `src/index.ts` (+1 -2) 📝 `tsconfig.json` (+5 -4) </details> ### 📄 Description ## Summary - Replace `tsc` with `esbuild` for bundling, enabling minification, tree-shaking, and single-file output - Reduce npm package footprint by trimming included files (only `postinstall.js` script, removed `CHANGELOG.md`) - Disable TypeScript declaration and source map generation for smaller output - Improve development experience with faster watch mode (minification disabled during dev) ## Changes ### Build System - Add new `scripts/build.js` using esbuild to bundle the CLI - Bundle main entry point (`src/index.ts` → `dist/index.js`) and bin-manager separately - External dependencies (`axios`, `chalk`, `ora`) kept external to avoid CJS/ESM issues - Shebang now added via esbuild banner instead of source file ### Package Optimization - Update `files` in `package.json` to only include necessary files - Disable `declaration` and `sourceMap` in `tsconfig.json` - Add `noEmit: true` to tsconfig (esbuild handles output) ### CI/CD - Enhance smoke test workflow to simulate npm pack/install flow - Test installation from generated tarball for accurate packaging validation ## Test Plan - [ ] Run `npm run build` and verify output size reduction - [ ] Run `npm run dev` and verify watch mode works - [ ] Run `npm test` to ensure no regressions - [ ] Run `npm pack` and inspect tarball contents - [ ] Install from tarball and test CLI functionality --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem closed this issue 2026-03-04 01:38:07 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nport#9
No description provided.