{"id":15658,"library":"js-bundler","title":"JS Bundler","description":"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.","status":"abandoned","version":"1.2.4","language":"javascript","source_language":"en","source_url":"https://github.com/zhanzhenzhen/js-bundler","tags":["javascript","bundle","browserify","js","bundling","browser","coffeescript"],"install":[{"cmd":"npm install js-bundler","lang":"bash","label":"npm"},{"cmd":"yarn add js-bundler","lang":"bash","label":"yarn"},{"cmd":"pnpm add js-bundler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"require('js-bundler')","symbol":"bundle (CLI)","correct":"bundle <file> [options]"},{"note":"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.","wrong":"bundle example.coffee","symbol":"bundle -c (CoffeeScript)","correct":"bundle -c:coffee 'coffee -bcs' example.coffee"},{"note":"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.","wrong":"bundle example.js","symbol":"bundle -d (Dummy Modules)","correct":"bundle -d 'module-to-dummy' example.js"}],"quickstart":{"code":"#!/bin/bash\n\n# Ensure js-bundler is installed globally or linked\n# npm install -g js-bundler\n\n# Create a simple JavaScript file that requires another module\ncat <<EOF > main.js\nconst dep = require('./dependency.js');\nconsole.log('Main script running, dependency says: ' + dep.message);\nEOF\n\ncat <<EOF > dependency.js\nexports.message = 'Hello from dependency!';\nEOF\n\necho \"\\n--- Bundling main.js to stdout ---\"\nbundle main.js\n\necho \"\\n--- Bundling main.js to bundle.js ---\"\nbundle main.js > bundle.js\n\necho \"\\n--- Content of bundle.js ---\"\ncat bundle.js\n","lang":"bash","description":"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`."},"warnings":[{"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.","message":"js-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).","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The bundler does not generate source maps, making debugging bundled code significantly more challenging as original file locations are not preserved.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"Using 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.","severity":"security","affected_versions":">=1.0.0"},{"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.","message":"The `-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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"When 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).","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"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.","cause":"A file or directory that matches a pattern specified with the `-n` option was attempted to be included in the bundle.","error":"Error: A file matching a negation pattern was required: <path/to/file.js>"},{"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).","cause":"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.","error":"ReferenceError: require is not defined"}],"ecosystem":"npm"}