Bundilio: Simple JavaScript File Concatenator
Bundilio is a highly rudimentary JavaScript utility package designed for basic file concatenation, combining multiple JavaScript source files into a single output file. Last published over seven years ago, version 0.4.5 is the most recent release, indicating the package is abandoned. It operates purely as a concatenator and lacks the sophisticated features expected of modern module bundlers, such as dependency resolution, module graphing, tree-shaking, code splitting, asset handling (CSS, images), or transpilation for different JavaScript versions (e.g., ES6+ to ES5). This makes it unsuitable for contemporary web development projects, which typically require robust bundling capabilities provided by tools like Webpack, Rollup, Parcel, or esbuild. Its minimal scope and lack of maintenance mean it does not adhere to current best practices for performance, security, or developer experience.
Common errors
-
TypeError: bundilio is not a function
cause Attempting to call `require('bundilio')()` directly, or mistakenly using destructuring assignment `const { bundle } = require('bundilio')`.fixThe `bundilio` package's `module.exports` *is* the `bundle` function itself. Correct usage is `const bundle = require('bundilio');` -
Error: ENOENT: no such file or directory, open '<path/to/file>'
cause One of the input files specified in the `files` array does not exist at the provided path, or the output directory for the bundled file does not exist.fixVerify all input file paths are correct and the files exist. Ensure the target directory for the output bundle exists before running Bundilio, or create it programmatically using `fs.mkdirSync(outputDir, { recursive: true });`.
Warnings
- breaking The `bundilio` package is abandoned and has not been updated in over 7 years. It is highly insecure and incompatible with modern JavaScript development practices and environments, posing significant risks for production use.
- gotcha Bundilio is a simple file concatenator, not a module bundler. It does not perform dependency resolution, tree-shaking, transpilation (e.g., ES6+ to ES5), code splitting, minification, or handle non-JavaScript assets (CSS, images).
- gotcha This package only supports CommonJS (CJS) modules. It will not correctly process or understand ES Modules (ESM) `import`/`export` syntax, leading to syntax errors or incorrectly formed bundles.
Install
-
npm install bundilio -
yarn add bundilio -
pnpm add bundilio
Imports
- bundle
import { bundle } from 'bundilio'; // or const { bundle } = require('bundilio');const bundle = require('bundilio');
Quickstart
const fs = require('fs');
const path = require('path');
const bundle = require('bundilio');
const inputDir = path.join(__dirname, 'src');
const outputDir = path.join(__dirname, 'dist');
// Create dummy source files
fs.mkdirSync(inputDir, { recursive: true });
fs.writeFileSync(path.join(inputDir, 'moduleA.js'), 'console.log("Module A loaded");\nmodule.exports = { name: "A" };');
fs.writeFileSync(path.join(inputDir, 'moduleB.js'), 'console.log("Module B loaded");\nmodule.exports = { value: 123 };');
// Ensure output directory exists
fs.mkdirSync(outputDir, { recursive: true });
const inputFiles = [
path.join(inputDir, 'moduleA.js'),
path.join(inputDir, 'moduleB.js')
];
const outputFile = path.join(outputDir, 'app.bundle.js');
bundle(inputFiles, outputFile, (err) => {
if (err) {
console.error('Bundling failed:', err);
return;
}
console.log(`Successfully bundled ${inputFiles.length} files to ${outputFile}`);
const bundledContent = fs.readFileSync(outputFile, 'utf8');
console.log('\n--- Bundled Content ---');
console.log(bundledContent);
console.log('--------------------');
});