Skip to content

Remove express dependency to reduce package size #1119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 20, 2025

This PR addresses the package size concern by removing the unnecessary express dependency from devDependencies.

Problem

The issue reported that the package size was large due to express being included. Upon investigation, I found that:

  • Express was only used in a single example file (examples/express.js)
  • Express was in devDependencies, not production dependencies
  • The examples directory wasn't included in the published npm package
  • However, express was contributing to development setup complexity and Docker image size

Solution

  1. Removed express from devDependencies - This eliminates 42 packages from the development dependency tree
  2. Moved express example to advanced-examples - Created comprehensive documentation in advanced-examples/express-webhook-example.md with:
    • Complete setup instructions for users who want to use Express
    • Alternative implementation without Express
    • Clear explanation that Express is optional
  3. Updated Dockerfile - Removed examples directory from Docker builds to reduce image size

Impact

  • Development dependencies reduced: From 576 to 534 packages (-42 packages)
  • Cleaner development setup: No unnecessary framework dependencies
  • Smaller Docker images: Examples no longer copied during builds
  • Better documentation: Express usage now properly documented with setup instructions

Backward Compatibility

All webhook functionality remains fully intact:

  • twilio.webhook() - Express middleware function still works
  • twilio.validateExpressRequest() - Express request validation preserved
  • twilio.validateRequest() - Generic validation unchanged
  • All existing APIs maintain the same signatures

The webhook implementation in src/webhooks/webhooks.ts provides Express-compatible middleware without requiring Express as a dependency, which is the correct architectural approach.

Testing

  • ✅ All 316 existing tests pass
  • ✅ TypeScript compilation successful
  • ✅ Build process verified
  • ✅ Webhook functionality confirmed working

Fixes #1118.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Author

Copilot AI commented Aug 20, 2025

@tiwarishubham635 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 2 commits August 20, 2025 18:11
Co-authored-by: tiwarishubham635 <59199353+tiwarishubham635@users.noreply.github.com>
Co-authored-by: tiwarishubham635 <59199353+tiwarishubham635@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Package size large due to express Remove express dependency to reduce package size Aug 20, 2025
Copilot finished work on behalf of tiwarishubham635 August 20, 2025 18:16
@Copilot Copilot AI requested a review from tiwarishubham635 August 20, 2025 18:16
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.

Package size large due to express
2 participants