Advanced Installation

Advanced installation configurations for different environments and frameworks.

Module System Support

This package provides dual module support with both CommonJS and ES Modules built into the same package. No configuration changes are needed - the appropriate format is automatically selected based on your environment.

Package Exports Structure

The package includes the following build outputs:

dist/
├── index.js          # CommonJS main entry
├── index.mjs         # ES Modules main entry  
├── index.d.ts        # TypeScript definitions
├── streaming.js      # CommonJS streaming module
├── streaming.mjs     # ES Modules streaming module
├── streaming.d.ts    # Streaming TypeScript definitions
├── performance.js    # CommonJS performance module
├── performance.mjs   # ES Modules performance module
├── performance.d.ts  # Performance TypeScript definitions
├── errors.js         # CommonJS error handling
├── errors.mjs        # ES Modules error handling
└── errors.d.ts       # Error handling TypeScript definitions

Environment-Specific Setup

Node.js Projects

ESM Projects (package.json with "type": "module")

CommonJS Projects

Mixed Projects (CommonJS with ESM imports)

TypeScript Projects

tsconfig.json Configuration

Type Imports

The package provides complete TypeScript support for both module systems:

Frontend Frameworks

React/Next.js

Vue.js

Server Environments

Express.js

ES Modules:

CommonJS:

Serverless Functions

Vercel:

AWS Lambda:

Bundle Size Optimization

Automatic Module Selection

The package automatically selects the optimal format for your build system:

  • Webpack 5: Uses ES Modules (.mjs) for better tree-shaking

  • Rollup/Vite: Uses ES Modules (.mjs) for optimal bundling

  • Node.js: Uses CommonJS (.js) or ESM (.mjs) based on your package.json

  • TypeScript: Uses appropriate format with full type support

Tree Shaking (Webpack/Vite)

Lazy Loading

Bundle Analysis

The package provides different entry points for optimal bundling:

Last updated