Features
- CDN Imports - Import npm packages directly from CDN URLs
- Tree-shaking - Full tree-shaking support for CDN modules
- Multiple CDNs - Support for Skypack with fallback chains
- Version Pinning - Pin specific package versions
- Custom Resolvers - Use any CDN with custom URL resolvers
Installation
Quick Start
Configuration
Version Pinning
Pin specific versions for reproducible builds:Custom CDN Resolvers
Use any CDN by providing custom resolver functions:Custom Fetch Implementation
For environments without global fetch or for adding custom headers:How It Works
- Resolution: When Rollup encounters an import, the plugin checks if it’s a CDN-resolvable module
- Fetching: The module is fetched from the configured CDN(s)
- Transformation: Relative imports within the fetched module are resolved to absolute CDN URLs
- Bundling: Rollup processes the module like any local file, enabling tree-shaking
Import Resolution
Popular CDN Examples
API Reference
importCdn(options?)
Creates the Rollup plugin.
Options
Examples
Vite Configuration
Multi-CDN Fallback
Types
Compatibility
- Rollup: 3.x, 4.x
- Node.js: 18+ (requires
fetchor customfetchImpl)