smartbundle

raw JSON →
0.14.1 verified Sat Apr 25 auth: no javascript

Zero-config bundler for npm packages, version 0.14.1. Lean and minimal configuration approach compared to tsdx or microbundle. Actively maintained with monthly releases. Ships TypeScript declarations. Requires vitest ^3.0.0, typescript ^5.0.0, and @babel/core ^7.26.0 as peer dependencies since v0.14.0. Handles ESM, CJS, and TypeScript out of the box.

error Error: Cannot find module 'smartbundle'
cause Missing peer dependencies or ESM/CJS mismatch
fix
Install peer deps: npm install -D vitest@^3.0.0 typescript@^5.0.0 @babel/core@^7.26.0 and use ESM imports
error TypeError: smartbundle is not a function
cause Using default import instead of named import
fix
Use named import: import { build } from 'smartbundle' instead of import smartbundle from 'smartbundle'
error Error: verbatimModuleSyntax is required
cause TypeScript config missing verbatimModuleSyntax in v0.12.4+
fix
Add 'verbatimModuleSyntax': true to tsconfig.json compilerOptions
error Error: exports or bin is required
cause package.json missing exports or bin field in v0.14.1+
fix
Add 'exports' or 'bin' field to package.json
breaking Minimum peer dependency vitest v3 required since v0.14.0
fix Install vitest ^3.0.0 in your project: npm install -D vitest@^3.0.0
breaking Force verbatimModuleSyntax in TypeScript config since v0.12.4
fix Enable 'verbatimModuleSyntax' in tsconfig.json
breaking ESM-only package, require() will fail since v0.13.0
fix Replace require('smartbundle') with import statements or use dynamic import
gotcha exports or bin field required in package.json since v0.14.1
fix Ensure your package.json has either 'exports' or 'bin' field defined
deprecated createConfig function may be deprecated in future in favor of defineConfig
fix Use defineConfig instead for future compatibility
npm install smartbundle
yarn add smartbundle
pnpm add smartbundle

Basic usage of smartbundle to build an npm package from a TypeScript entry point.

import { build, defineConfig } from 'smartbundle';
const config = defineConfig({
  entry: 'src/index.ts',
  formats: ['esm', 'cjs'],
  outDir: 'dist',
  tsconfig: 'tsconfig.json',
});
console.log('Building...');
build(config).then(() => console.log('Done!'));