{"id":13198,"library":"foso","title":"Foso Bundler","description":"Foso is a convention-over-configuration JavaScript bundler, designed to simplify resource bundling with minimal setup. Originally conceived as an alternative to highly configurable task runners like Gulp or Grunt, Foso's core philosophy centers on zero-configuration operations. It automatically bundles resources using specific `fosify-*` plugins, watches for file changes to trigger re-bundling, includes a LiveReload server for automatic browser refreshes, and can optionally serve bundled assets via a static server. The system leverages naming conventions (e.g., `bundle.js`, `[something].bundle.js`) to determine how files are processed and outputted. The current and likely final stable version is 0.10.3, with development having ceased approximately seven years ago, indicating it is no longer actively maintained. Its primary differentiators were its simplicity and opinionated conventions to reduce boilerplate configuration.","status":"abandoned","version":"0.10.3","language":"javascript","source_language":"en","source_url":"https://github.com/fosojs/foso","tags":["javascript","foso","server","fosify","browserify","bundler"],"install":[{"cmd":"npm install foso","lang":"bash","label":"npm"},{"cmd":"yarn add foso","lang":"bash","label":"yarn"},{"cmd":"pnpm add foso","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for JavaScript bundling functionality.","package":"fosify-js","optional":true},{"reason":"Required for Less CSS preprocessor bundling functionality.","package":"fosify-less","optional":true},{"reason":"Required for Sass CSS preprocessor bundling functionality.","package":"fosify-sass","optional":true},{"reason":"Required for HTML bundling functionality.","package":"fosify-html","optional":true},{"reason":"Required for test-related bundling functionality.","package":"fosify-test","optional":true}],"imports":[{"note":"Foso is a CommonJS-only package. Direct ESM `import` statements are not supported.","wrong":"import foso from 'foso';","symbol":"foso","correct":"const foso = require('foso');"},{"note":"Plugins like 'fosify-less' are also CommonJS modules and must be imported using `require()`.","wrong":"import lessPlugin from 'fosify-less';","symbol":"fosify-less","correct":"const lessPlugin = require('fosify-less');"}],"quickstart":{"code":"const Foso = require('foso');\nconst lessPlugin = require('fosify-less');\nconst path = require('path');\nconst fs = require('fs');\n\n// Create dummy source files for the example\nconst srcDir = path.join(__dirname, 'src', 'styles');\nconst destDir = path.join(__dirname, 'dist');\nfs.mkdirSync(srcDir, { recursive: true });\nfs.mkdirSync(destDir, { recursive: true });\nfs.writeFileSync(path.join(srcDir, 'main.bundle.less'), 'body { color: red; }');\n\nconst foso = new Foso();\n\nfoso\n  .register(lessPlugin, {\n    src: path.join(__dirname, 'src'),\n    dest: destDir,\n    watch: false, // Set to true for live reloading, but requires a running process\n    minify: false\n  })\n  .then(() => {\n    console.log('Foso bundle command initiated. Checking for bundled files...');\n    // In a real scenario, you'd call foso.bundle() or foso.serve()\n    // For this quickstart, we're demonstrating setup.\n    // Simulating completion since actual bundling needs fosify-less to run and write files.\n    console.log(`Please check the '${destDir}' directory for bundled output if 'fosify-less' was properly configured and executed.`);\n    console.log('Foso setup complete. Actual bundling would happen now.');\n  })\n  .catch(err => {\n    console.error('Foso initialization failed:', err);\n  });\n\n// Clean up dummy files after a short delay (for demonstration purposes)\nsetTimeout(() => {\n  try {\n    fs.rmSync(path.join(__dirname, 'src'), { recursive: true, force: true });\n    fs.rmSync(destDir, { recursive: true, force: true });\n    console.log('Cleaned up dummy files.');\n  } catch (e) {\n    console.error('Error cleaning up:', e);\n  }\n}, 3000);\n","lang":"javascript","description":"This example demonstrates how to set up and initiate a Foso bundling process programmatically, registering the `fosify-less` plugin. It creates temporary source and destination directories to illustrate the convention-based file handling."},"warnings":[{"fix":"Migrate to a modern, actively maintained bundler like Webpack, Rollup, Vite, or Parcel. These tools offer better performance, feature sets, and security.","message":"The `foso` project and its associated `fosify-*` plugins have not been updated in approximately 7 years. This means it is no longer actively maintained, receives no security patches, and is likely incompatible with modern Node.js versions and ecosystem tools. Using it in new projects or maintaining it in existing ones is highly discouraged.","severity":"breaking","affected_versions":">=0.10.3"},{"fix":"If integrating into an ESM project, you must use `require()` within a CommonJS context or transpile your code, or use dynamic `import()` if Node.js runtime supports it and the module is compatible. It is generally safer to assume CommonJS-only usage.","message":"`foso` is a CommonJS-only package. Attempting to use `import` statements (ESM syntax) directly with `foso` or its plugins in a modern JavaScript module environment will result in errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If you must use `foso` CLI, perform `npm install -g foso` and `npm install -g fosify-js fosify-less fosify-html`. However, reconsidering the project's abandoned status and global dependency model is advisable.","message":"For CLI usage, Foso and its plugins (`fosify-js`, `fosify-less`, etc.) require global installation via `npm install -g`. This approach to dependency management is generally discouraged in modern Node.js development in favor of local project dependencies and `npx`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Run `npm install foso` in your project directory for local usage, or `npm install -g foso` for global CLI usage.","cause":"The `foso` package was not installed or is not accessible from the current working directory or Node.js module resolution path.","error":"Error: Cannot find module 'foso'"},{"fix":"Ensure your file is treated as a CommonJS module (e.g., using a `.js` extension without `type: \"module\"` in `package.json`), or use a compatibility layer if necessary. The recommended long-term solution is migrating to a modern bundler that supports ESM.","cause":"Attempting to use `require('foso')` within an ECMAScript Module (ESM) file (`.mjs` or when `type: \"module\"` in `package.json`). Foso is a CommonJS module.","error":"ReferenceError: require is not defined in ES module scope"},{"fix":"Install `foso` globally using `npm install -g foso`. Verify installation by running `foso --version` (if supported) or checking npm global binaries.","cause":"The `foso` CLI was not installed globally or its installation path is not in your system's PATH environment variable.","error":"foso: command not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"foso"}