{"id":15614,"library":"felt","title":"Felt: On-demand ES6/CSS Bundler","description":"Felt is an on-demand bundler designed for modern JavaScript (ES6 and beyond, typically transpiled via Buble/Rollup) and CSS (CSS Next), serving primarily as a development middleware or a static asset exporter. Currently at version 0.3.2, it requires Node.js 6 or above to run. The package offers three main modes of operation: a standalone CLI web server for quick local development, an Express.js middleware for integration into existing Node.js applications, and a static file exporter for pre-compiling assets for deployment. Its core functionality is highly extensible through 'recipes' and a plugin architecture, exemplified by modules like `felt-rollup`, which allows developers to define custom handler logic for different file types. This on-demand compilation approach is a key differentiator, focusing on speed during development rather than exhaustive pre-bundling.","status":"active","version":"0.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/cognitom/felt","tags":["javascript","express","middleware"],"install":[{"cmd":"npm install felt","lang":"bash","label":"npm"},{"cmd":"yarn add felt","lang":"bash","label":"yarn"},{"cmd":"pnpm add felt","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for using Felt as an Express.js middleware.","package":"express","optional":false},{"reason":"A common 'recipe' module providing basic bundling handlers, necessary for minimal functionality both in CLI and middleware modes.","package":"felt-recipe-minimal","optional":false}],"imports":[{"note":"Felt is a CommonJS module, primarily used with `require()`. There is no native ESM support.","wrong":"import felt from 'felt'","symbol":"felt","correct":"const felt = require('felt')"},{"note":"Recipes like `felt-recipe-minimal` are separate CommonJS modules that `felt` consumes. Do not use ES module `import` syntax.","wrong":"import recipe from 'felt-recipe-minimal'","symbol":"recipe","correct":"const recipe = require('felt-recipe-minimal')"},{"note":"Configuration files are expected to be CommonJS modules exporting an object, typically required relative to the application's entry point.","wrong":"import config from './felt.config.js'","symbol":"feltConfig","correct":"const config = require('./felt.config.js')"}],"quickstart":{"code":"const express = require('express');\nconst felt = require('felt');\nconst path = require('path');\nconst config = require('./felt.config.js'); // Assuming felt.config.js exists and exports a Felt config object\n\nconst app = express();\n\n// Integrate Felt as an on-demand bundling middleware\napp.use(felt(config));\n\n// Serve static files from the 'public' directory\napp.use(express.static(path.join(__dirname, 'public')));\n\nconst PORT = process.env.PORT ?? 3000;\napp.listen(PORT, () => {\n  console.log(`Felt server running at http://localhost:${PORT}`);\n  console.log('Serving static files from ./public and bundling JavaScript/CSS on-demand.');\n});\n\n// To set up:\n// 1. npm install express felt felt-rollup rollup-plugin-buble rollup-plugin-node-resolve rollup-plugin-commonjs\n// 2. Create 'felt.config.js' (as shown in the README example)\n// 3. Create 'public/index.html' and 'public/main.js' (e.g., 'console.log(\"Hello from Felt!\")')\n// 4. Run with 'node server.js'","lang":"javascript","description":"Integrates Felt as an on-demand ES6/CSS bundler middleware with an Express.js server."},"warnings":[{"fix":"Ensure your project or file where Felt is used operates in a CommonJS context (e.g., by using `.cjs` extension or `\"type\": \"commonjs\"` in package.json) and use `require()` syntax. If ESM is required, consider a CJS-to-ESM wrapper or alternative tooling.","message":"Felt is a CommonJS-only package. Attempting to use `import` statements directly in an ES module environment will result in runtime errors. It predates widespread native ESM support in Node.js.","severity":"breaking","affected_versions":">=0.3.0"},{"fix":"Always install a recipe (e.g., `npm install felt-recipe-minimal`) or define custom handlers in your `felt.config.js` file, ensuring all necessary bundler plugins (e.g., `felt-rollup`, `rollup-plugin-buble`) are also installed.","message":"Felt itself does not bundle files out of the box; it requires 'recipes' (like `felt-recipe-minimal`) or custom `handlers` specified in its configuration to define how different file types (e.g., `.js`, `.css`) are processed.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"Ensure your Node.js environment is at least version 6.x. For newer Node.js versions, test thoroughly and be prepared for potential dependency conflicts or deprecation warnings related to older build tools.","message":"Felt explicitly requires Node.js 6.x or above. While it may run on newer versions, its older dependencies (e.g., Rollup 0.x, Buble) might lead to compatibility issues or missing features compared to modern bundling setups.","severity":"gotcha","affected_versions":"<6.0.0"},{"fix":"For production deployments, consider using Felt's `--export` option to pre-compile and serve static assets, or implement aggressive caching strategies on your server to mitigate compilation overhead.","message":"Felt's 'on-demand' bundling means assets are compiled dynamically upon request. This is great for development hot-reloading but can introduce latency for initial requests or heavy load in production environments compared to pre-compiled static assets.","severity":"gotcha","affected_versions":">=0.3.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Install the required recipe: `npm install felt-recipe-minimal` or `npm install -g felt felt-recipe-minimal` if using the CLI globally.","cause":"The `felt-recipe-minimal` package (or another specified recipe) was not installed, or its path is incorrect.","error":"Error: Cannot find module 'felt-recipe-minimal'"},{"fix":"Change the port Felt uses with the `--port` CLI option (e.g., `felt --port 3333`) or by setting the `port` option in your `felt.config.js`.","cause":"The default port 3000 (or a specified port) is already being used by another process on your system.","error":"Error: listen EADDRINUSE: address already in use :::3000"},{"fix":"Ensure your Node.js environment and file types are correctly configured for CommonJS (`.js` files without `\"type\": \"module\"` in package.json, or `.cjs` files) when using Felt, as it is a CommonJS library.","cause":"Attempting to use CommonJS `require()` in an ES module context or vice-versa, indicating a module system mismatch.","error":"ReferenceError: require is not defined (at file:///path/to/server.js:...) or SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm"}