wc-bundler
raw JSON → 0.10.8 verified Sat Apr 25 auth: no javascript
A bundler for Web Components. Current stable version is 0.10.8, with ongoing active development and irregular release cadence. It provides TypeScript support out of the box and focuses on bundling single-file web components into a distributable format. Compared to larger bundlers like Webpack or Rollup, wc-bundler is lightweight and targeted specifically at Web Component authors.
Common errors
error Error: bundle is not a function ↓
cause Using require() instead of import.
fix
Use import { bundle } from 'wc-bundler' in an ESM context.
error Cannot find module 'wc-bundler' ↓
cause Package not installed.
fix
Run npm install wc-bundler.
Warnings
breaking As of version 0.8.0, the API changed from synchronous to asynchronous. ↓
fix Use await when calling bundle().
deprecated The 'format' option 'umd' is deprecated and will be removed in 1.0. ↓
fix Use 'esm' or 'cjs' instead.
gotcha TypeScript declarations are only generated when 'types: true' is explicitly set. ↓
fix Set { types: true } in options.
Install
npm install wc-bundler yarn add wc-bundler pnpm add wc-bundler Imports
- bundle wrong
const bundle = require('wc-bundler').bundlecorrectimport { bundle } from 'wc-bundler' - version
import { version } from 'wc-bundler'
Quickstart
import { bundle } from 'wc-bundler';
const result = await bundle({
input: 'src/my-component.ts',
output: 'dist/my-component.js',
format: 'esm',
types: true,
minify: true
}, { key: process.env.KEY ?? '' });
console.log('Bundled:', result.outputFiles);