Registry / devops / lbundle

lbundle

JSON →
library1.6.0jsnpmunverified

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 lbundle
INSTALL
IMPORT
SIG · LBUNDLE
L
lbundle
devopsjavascriptv1.6.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

lbundle CLI
npx lbundle
import lbundle from 'lbundle'; // This is a CLI tool, not a directly importable function for general use.
The primary interaction with lbundle is via its command-line interface. Install as a dev dependency and run via `npx` or add to your `package.json` scripts.
Asset Modules Types
/// <reference types="lbundle/modules" />
import { Asset } from 'lbundle/modules';
To enable TypeScript support for asset imports (e.g., `.png`, `.svg` as URLs or React components), add this triple-slash directive to your main TypeScript declaration file (e.g., `src/global.d.ts` or `tsconfig.json` `files` array).
build
import { build } from 'lbundle'; await build({ /* config */ });
const build = require('lbundle').build;
While primarily a CLI tool, `lbundle` exposes a programmatic API for more advanced use cases, allowing direct invocation of its build process within Node.js environments. Use ESM imports for this.

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.

{ "name": "my-library", "version": "1.0.0", "source": "./src/index.ts", "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "unpkg": "./dist/index.umd.js", "sideEffects": false, "exports": { ".": { "default": "./dist/index.js", "node": "./dist/index.js", "require": "./dist/index.js", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" }, "./index.css": "./dist/index.css", "./package.json": "./package.json" }, "scripts": { "build": "lbundle", "dev": "lbundle --watch" }, "devDependencies": { "lbundle": "^1.6.0" } } // src/index.ts import logo from './assets/logo.png'; import { ReactComponent as Icon } from './assets/icon.svg'; export const sayHello = (name: string) => { console.log(`Hello, ${name}!`); // Example usage of imported assets document.body.innerHTML += `<img src="${logo}" alt="Logo" />`; const iconContainer = document.createElement('div'); // In a React context, you'd render <Icon /> directly. // For this example, we'll simulate its presence. iconContainer.innerHTML = 'SVG Icon placeholder'; document.body.appendChild(iconContainer); return `Hello, ${name} with logo and icon!`; }; // global.d.ts (for TypeScript asset support) /// <reference types="lbundle/modules" /> // Run the build // npm install && npm run build
lbundle --version
Debug
Known issues
gotchalbundle heavily relies on `package.json` fields (`source`, `main`, `module`, `types`, `unpkg`, `exports`). Misconfiguring these fields, or omitting them entirely, will prevent `lbundle` from generating the expected output formats or entry points.
fix
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.
affects: >=1.0.0
gotchaAsset imports (images, SVGs, etc.) require a TypeScript reference directive (`/// <reference types="lbundle/modules" />`) in your project's type declaration files to ensure type safety and correct resolution during development.
fix
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`.
affects: >=1.6.0
gotchaStyling preprocessor support (Less, Sass, Stylus) depends on corresponding peer dependencies. If you import such files without installing the relevant package, `lbundle` will fail to process them.
fix
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.
affects: >=1.0.0
gotchaThe `exports` field in `package.json` is crucial for defining how your bundled library is consumed by different environments (ESM, CJS, Node, browser). Incorrectly configuring this field can lead to module resolution issues for consumers.
fix
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`.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'sass' imported from 'some-file.scss'
Sass/SCSS file imported, but `sass` peer dependency is not installed.
fix
Install `sass` as a development dependency: `npm install -D sass` or `yarn add -D sass`.
Error: Unknown file extension "./src/index.ts" for "./src/index.ts"
Typically indicates a misconfiguration in `package.json`'s `source` field or missing `tsconfig.json` setup for `lbundle`.
fix
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.
lbundle: command not found
The `lbundle` CLI tool is not in your system's PATH or `npx` cannot locate it.
fix
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"`).
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies
lessoptionalPeer dependency for Less style processing. Required if Less files are imported.
sassoptionalPeer dependency for Sass style processing. Required if Sass/SCSS files are imported.
stylusoptionalPeer dependency for Stylus style processing. Required if Stylus files are imported.
Agent activity
2 hits · last 30 days
node
2
Resources