Registry / web-framework / js-bundler

js-bundler

JSON →
library1.2.4jsnpmunverified

js-bundler is a command-line tool designed for bundling JavaScript and CoffeeScript files, along with their 'required' dependencies, into a single output file. Currently at version 1.2.4, it was last published over 7 years ago, indicating an abandoned status. It differentiates itself from more feature-rich bundlers like Browserify by explicitly *not* providing Node.js built-in module shims or source mapping, aiming for a lightweight profile. This makes it suitable primarily for client-side browser or 'neutral' packages that do not rely on Node.js-specific modules. Its release cadence is effectively non-existent, given its age. Modern alternatives like Vite, Rollup, esbuild, and Parcel offer significantly faster build times, better developer experience, and more comprehensive feature sets, including native ES module support and advanced optimizations like tree-shaking, which js-bundler lacks.

npm install js-bundler
INSTALL
IMPORT
SIG · JS-BUNDLER
J
js-bundler
web-frameworkjavascriptv1.2.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.

bundle (CLI)
bundle <file> [options]
require('js-bundler')
js-bundler is a command-line interface (CLI) tool and is not intended for programmatic import within JavaScript code. Its functionality is accessed via the `bundle` command in the terminal.
bundle -c (CoffeeScript)
bundle -c:coffee 'coffee -bcs' example.coffee
bundle example.coffee
To bundle CoffeeScript files, the `-c` option is required to specify the CoffeeScript compiler command. This option is noted to be for Node 0.12 or higher, reflecting the tool's age.
bundle -d (Dummy Modules)
bundle -d 'module-to-dummy' example.js
bundle example.js
The `-d` option is used to create a 'dummy' module for specified `require` strings, preventing external package modules (e.g., `coffee-script/register`) from being bundled and instead providing an empty module. This is useful for browser-only bundles.

Demonstrates basic bundling of a main JavaScript file and its required dependency into a single output, first to stdout and then to a file named `bundle.js`.

#!/bin/bash # Ensure js-bundler is installed globally or linked # npm install -g js-bundler # Create a simple JavaScript file that requires another module cat <<EOF > main.js const dep = require('./dependency.js'); console.log('Main script running, dependency says: ' + dep.message); EOF cat <<EOF > dependency.js exports.message = 'Hello from dependency!'; EOF echo "\n--- Bundling main.js to stdout ---" bundle main.js echo "\n--- Bundling main.js to bundle.js ---" bundle main.js > bundle.js echo "\n--- Content of bundle.js ---" cat bundle.js
js-bundler --version
Debug
Known issues
gotchajs-bundler explicitly does not provide shims for Node.js built-in modules (e.g., `fs`, `path`). Bundling code that relies on these modules will result in runtime errors in environments where these shims are not present (e.g., browsers).
fix
Ensure all modules to be bundled are 'browser' or 'neutral' packages that do not depend on Node.js built-in modules. For Node.js-specific code, use conditional loading or a different bundler.
affects: >=1.0.0
gotchaThe bundler does not generate source maps, making debugging bundled code significantly more challenging as original file locations are not preserved.
fix
For production, consider minifying the output to obfuscate paths if `-i` was used. For debugging, rely on the `// ***** file-674497323404793172` comments for file demarcation or use the `-i` option cautiously.
affects: >=1.0.0
securityUsing the `-i` option (informative data) embeds raw file paths into the bundled output. This can disclose sensitive information about your project's directory structure, especially in downloadable versions.
fix
Only use the `-i` option for testing or debugging. For deployable versions, ensure the output is minified with comment removal to prevent path disclosure.
affects: >=1.0.0
gotchaThe `-n` (negate pattern) option prevents files or directories matching a given pattern from being bundled. If a required file matches a negation pattern, the bundler will exit with code 64.
fix
Review the negation patterns (`-n`) to ensure they don't inadvertently exclude necessary files. Correct your code to avoid `require` statements for files intended to be excluded, or adjust the patterns.
affects: >=1.0.0
gotchaWhen using the `module.` prefix trick (e.g., `var abc = module.require('./abc');`) for server-side code, `module.require` will throw an error if the surrounding `if` condition fails to prevent its execution in an unsupported environment (e.g., browser).
fix
Ensure that conditional logic (`if (environment === "server")`) robustly prevents `module.require` from being called in environments where it's not supported or where the module is not available.
affects: >=1.0.0
Errors
Common errors & fixes
Error: A file matching a negation pattern was required: <path/to/file.js>
A file or directory that matches a pattern specified with the `-n` option was attempted to be included in the bundle.
fix
Adjust your negation patterns (`-n`) or refactor your code to avoid requiring files that should be excluded. The process will exit with code 64 upon this error.
ReferenceError: require is not defined
Attempting to bundle Node.js-specific modules (e.g., using `require('fs')`) for a browser environment where Node.js built-in shims are not provided.
fix
Ensure your project only requires 'browser-safe' modules, or manually shim/mock Node.js built-ins if absolutely necessary (though this tool is designed *without* such shims).
Upgrade
Version history
1.2.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources