lbundle is a small, zero-configuration bundler specifically designed for NPM libraries, leveraging Rollup.js for bundling and SWC (written in Rust) for fast transpilation. Its core philosophy is to minimize setup by heavily relying on best practices defined within the `package.json` file, using fields like `source`, `main`, `module`, `types`, `unpkg`, and `exports` to determine build inputs and outputs. The current stable version is 1.6.0, with frequent minor releases focusing on bug fixes and feature enhancements, as evidenced by its recent changelog. It differentiates itself by its 'convention over configuration' approach, automatic asset optimization, and robust TypeScript support, making it an ideal choice for library authors seeking a streamlined build process without extensive build toolchain configuration.
npm install lbundleVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `lbundle` using a `package.json` configuration, define an entry point in TypeScript, import various asset types, and prepare your project for bundling with the `lbundle` CLI.
Ensure all relevant `package.json` fields are correctly defined according to your desired library output. Consult the `lbundle` documentation for common `package.json` best practices for libraries.
Add `/// <reference types="lbundle/modules" />` to your `global.d.ts` or a similar type declaration file, or include `lbundle/modules` in the `types` array of your `tsconfig.json`.
Install the required peer dependency (e.g., `npm install -D sass` for SCSS files) if you are importing files of that type in your project.
Carefully define the `exports` field to map different entry points and formats to their respective paths (e.g., `./dist/index.mjs` for `import`, `./dist/index.js` for `require`). Validate with tools like `publint`.
Install `sass` as a development dependency: `npm install -D sass` or `yarn add -D sass`.
Ensure `source` field in `package.json` points to the correct entry file (e.g., `./src/index.ts`) and that TypeScript is correctly configured if using TS files.
Ensure `lbundle` is installed as a `devDependency` and run it via `npx lbundle` or add `lbundle` to your `package.json` scripts (e.g., `"build": "lbundle"`).