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.

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.
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.
npm install wc-bundler
yarn add wc-bundler
pnpm add wc-bundler

Shows how to bundle a TypeScript web component into an ESM module with type declarations.

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);