{"id":16899,"library":"simple-file-bundler","title":"Simple File Bundler","description":"Simple File Bundler is a command-line utility designed to merge multiple files into a single bundle, primarily focused on concatenating CSS or JavaScript files. It operates via a configuration file (`simple-file-bundle.config.js`) located at the project root, which exports an array of bundling instructions. Each instruction specifies an output endpoint, a list of input files, an optional path prefix, and an optional separator. The package is currently at version 1.0.7, indicating a stable but likely feature-complete state with an infrequent release cadence. Its key differentiator is its minimalist approach, requiring minimal setup for basic file concatenation, contrasting with more complex bundlers that offer advanced features like module resolution, tree-shaking, or minification.","status":"active","version":"1.0.7","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","bundle","simple"],"install":[{"cmd":"npm install simple-file-bundler","lang":"bash","label":"npm"},{"cmd":"yarn add simple-file-bundler","lang":"bash","label":"yarn"},{"cmd":"pnpm add simple-file-bundler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The `simple-file-bundle.config.js` file must use CommonJS `module.exports` syntax to define the array of bundle configurations, not ES module `export default`.","wrong":"export default [\n    { /* bundle settings */ },\n    { /* bundle settings */ }\n];","symbol":"ConfigurationArray","correct":"module.exports = [\n    { /* bundle settings */ },\n    { /* bundle settings */ }\n];"},{"note":"Each object within the configuration array must include `endpoint` and `files` properties. `prefix` and `separator` are optional. Omitting required fields will lead to errors.","wrong":"{ files: ['src/file.js'] }","symbol":"BundleSettingObject","correct":"{\n    prefix: __dirname,\n    endpoint: 'dist/bundle.css',\n    files: ['src/file1.css', 'src/file2.css'],\n    separator: '\\n'\n}"},{"note":"When specifying the `prefix` for file paths, the Node.js CommonJS global `__dirname` is commonly used to ensure paths are relative to the config file's directory. `import.meta.url` is for ES modules and is not applicable here.","wrong":"prefix: import.meta.url","symbol":"__dirname","correct":"prefix: __dirname"}],"quickstart":{"code":"npm i simple-file-bundler\n\n// simple-file-bundle.config.js\nmodule.exports = [\n    {\n        prefix: __dirname,\n        endpoint: 'dist/style.bundle.css',\n        files: [\n            'src/style1.css',\n            'src/style2.css',\n            'src/style3.css'\n        ]\n    },\n    {\n        prefix: __dirname,\n        endpoint: 'dist/scripts.js',\n        files: [\n            'src/index.js',\n            'src/superScript.js'\n        ],\n        separator: '\\n'\n    }\n];\n\n// Create some dummy files for demonstration\n// src/style1.css\n// body { color: red; }\n// src/style2.css\n// h1 { font-size: 2em; }\n// src/index.js\n// console.log('Hello from index.js');\n// src/superScript.js\n// console.log('Hello from superScript.js');\n\nmkdir -p src dist\necho \"body { color: red; }\" > src/style1.css\necho \"h1 { font-size: 2em; }\" > src/style2.css\necho \"console.log('Hello from index.js');\" > src/index.js\necho \"console.log('Hello from superScript.js');\" > src/superScript.js\n\nnpx create-bundles\n\n// Check outputs:\n// cat dist/style.bundle.css\n// cat dist/scripts.js","lang":"javascript","description":"Demonstrates installation, configuration with `simple-file-bundle.config.js`, and execution of the bundler to concatenate CSS and JS files into specified endpoints."},"warnings":[{"fix":"Ensure `simple-file-bundle.config.js` is directly in the project root directory. You can verify the current working directory before running the command.","message":"The configuration file `simple-file-bundle.config.js` *must* be located at the root of your project where the `npx create-bundles` command is executed. Misplacing it will result in the bundler not finding any configurations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always use `module.exports = [...]` in your `simple-file-bundle.config.js` file, even if your main project is ESM. This file is loaded by Node.js as a CommonJS module by the CLI tool.","message":"The package uses CommonJS (`module.exports`) for its configuration file. If you are working in an ES module (`'type': 'module'`) project, you cannot use `export default` directly in the configuration file. You must use CommonJS syntax for `simple-file-bundle.config.js`.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Double-check all file paths in your configuration. Use `__dirname` for `prefix` to make paths relative to the config file, or ensure absolute paths are correct.","message":"Files listed in the `files` array and the `endpoint` path are resolved relative to the `prefix` (if provided) or the directory where the command is run. Incorrect paths will lead to `ENOENT` (file not found) errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Verify that all file paths specified in your `simple-file-bundle.config.js` are correct and the files actually exist relative to the `prefix` or the command execution directory.","cause":"One or more files specified in the `files` array or the `endpoint` path do not exist at the resolved location.","error":"Error: ENOENT: no such file or directory, open 'src/nonexistent.js'"},{"fix":"Ensure `simple-file-bundle.config.js` exists in the project root, exports a valid array, and each object in the array has at least `endpoint` and `files` properties defined.","cause":"The `simple-file-bundle.config.js` file is either missing, empty, or does not export an array, or the exported array contains an invalid entry (e.g., missing `files` property).","error":"TypeError: Cannot read properties of undefined (reading 'length')"}],"ecosystem":"npm","meta_description":null}