Registry / devops / bundlex

bundlex

JSON →
library3.0.4jsnpmunverified

Bundlex is a JavaScript bundler designed for high performance and scalability, offering in-memory bundling of JavaScript, TypeScript, and JSON files. Currently at stable version 3.0.4, it differentiates itself by its focus on speed and the ability to create highly customizable bundling workflows through its `createBundler` API. While a specific release cadence isn't published, the frequent updates to similar tools suggest an active development cycle. Beyond basic bundling, Bundlex includes a built-in listener for file change events, enabling efficient watch-mode development. Its architecture supports custom bundler implementations by allowing users to define their own info extractor and bundler functions, providing flexibility for niche requirements.

npm install bundlex
INSTALL
IMPORT
SIG · BUNDLEX
B
bundlex
devopsjavascriptv3.0.4
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.

jsBundler
import { jsBundler } from 'bundlex';
const jsBundler = require('bundlex').jsBundler;
The primary function for bundling files. Bundlex is ESM-first; CommonJS require() may not be supported directly.
createBundler
import { createBundler } from 'bundlex';
Used to create custom bundler instances with specific info extractor and bundler logic.
InfoExtractor, Bundler
import type { InfoExtractor, Bundler } from 'bundlex';
TypeScript types for defining custom bundler logic. Essential for strong typing when using `createBundler`.

Demonstrates basic bundling of TypeScript files and how to set up a file change listener using `jsBundler`.

import { jsBundler } from 'bundlex'; import path from 'path'; import fs from 'fs/promises'; // Define temporary files for the demo const entryFile = path.resolve('./temp-entry.ts'); const depFile = path.resolve('./temp-dependency.ts'); async function runBundlexQuickstart() { // Create dummy files for bundling await fs.writeFile(depFile, `export const message = "Hello from dependency!";`); await fs.writeFile(entryFile, ` import { message } from './temp-dependency'; console.log(message); console.log("This is the main entry point."); `); console.log('Starting Bundlex quickstart...'); try { // Set up a listener for file changes jsBundler.on('change', (changedPath: string) => { console.log(`[Bundlex Watch] Detected change in: ${changedPath}.`); console.log('Re-bundling logic would typically go here...'); }); // Bundle the entry file const bundledContent = await jsBundler(entryFile); console.log('\n--- Bundled Output (truncated) ---'); console.log(bundledContent.slice(0, 500) + '\n...'); // Display first 500 characters // Simulate a file change to trigger the listener await new Promise(resolve => setTimeout(resolve, 50)); // Small delay await fs.appendFile(depFile, `\n// Added content to trigger change on ${Date.now()}`); console.log('\nSimulated file change. Check for listener output above.'); } catch (error) { console.error('Bundlex quickstart failed:', error); } finally { // Clean up temporary files await fs.unlink(entryFile).catch(() => {}); await fs.unlink(depFile).catch(() => {}); console.log('\nCleaned up temporary files.'); } } runBundlexQuickstart();
bundlex --version
Debug
Known issues
gotchaBundlex primarily targets ESM output for modern JavaScript environments. While it processes CJS modules as inputs, the default output format is typically ESM. Direct CommonJS 'require()' calls in the bundled output for external modules might not function as expected without a transpilation step or specific configuration for Node.js environments.
fix
Configure your project to use ES modules (`"type": "module"` in package.json) or ensure your target environment supports ESM. For Node.js, consider a custom bundler function with `createBundler` if specific CJS output or advanced external module handling is required.
affects: >=3.0.0
gotchaRelative path resolution within the bundler can sometimes be tricky, especially when dealing with nested directories or alias configurations. Bundlex resolves paths relative to the importing file unless explicitly configured otherwise.
fix
Always use clear relative or absolute paths. For complex projects, consider implementing a custom 'infoExtractor' with `createBundler` to handle path aliases or advanced module resolution strategies tailored to your project structure.
affects: >=3.0.0
gotchaThe `jsBundler.on('change', ...)` listener monitors file system changes for files included in the bundle graph. However, it might not automatically trigger a *re-bundle* operation; it merely notifies your application. You are responsible for re-invoking the `jsBundler()` function (or your custom bundler) upon receiving a 'change' event to generate an updated output.
fix
When using the `change` listener, implement logic within your callback to explicitly re-run the `jsBundler()` function with the entry file path to generate an updated bundle.
affects: >=3.0.0
Errors
Common errors & fixes
Cannot find module 'some-module' or its corresponding type declarations.
The bundler failed to resolve an import path, likely due to incorrect relative paths, a missing `node_modules` dependency, or a misconfigured alias.
fix
Verify the import path is correct and the module exists. For `node_modules`, ensure it's installed. If using aliases, consider a custom `infoExtractor` with `createBundler` to handle alias resolution.
SyntaxError: Cannot use import statement outside a module
The bundled output is in ES Module format, but it's being executed in a CommonJS context (e.g., Node.js without `"type": "module"` in `package.json` or an older Node version).
fix
Ensure your Node.js project's `package.json` contains `"type": "module"` or ensure your runtime environment supports ESM. Bundlex's primary output is ESM, so direct CJS output options may not be available.
Upgrade
Version history
3.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
bundlex — npm install bundlex · libregistry