Registry / web-framework / iced-coffee-middleware

iced-coffee-middleware

JSON →
library0.2.1jsnpmunverified

iced-coffee-middleware (also known as `coffee-middleware`) is a Connect/Express middleware designed for on-the-fly compilation of CoffeeScript files (`.coffee`) into JavaScript. Currently at version 0.2.1, it provides functionality to dynamically serve compiled JavaScript, offering options such as `force` for continuous recompilation, `bare` for compilation without the top-level safety wrapper, and `encodeSrc` for embedding base64 source maps. This package leverages patterns from `less-middleware` and is built for integration with older `connect` and `express` versions that utilized `createServer()` and `app.configure()`. Due to its reliance on these long-deprecated APIs and the declining prevalence of CoffeeScript in new web development, the package's active maintenance and applicability to modern Node.js ecosystems are highly questionable. Its development cadence is effectively halted, with no significant updates in many years, making it primarily a historical artifact rather than a viable solution for contemporary projects.

npm install iced-coffee-middleware
INSTALL
IMPORT
SIG · ICED-COFFEE-MIDDLE
I
iced-coffee-middleware
web-frameworkjavascriptv0.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

coffeeMiddleware
const coffeeMiddleware = require('coffee-middleware');
import coffeeMiddleware from 'coffee-middleware';
This package is CommonJS-only and relies on `require()`. It is not compatible with modern ESM `import` statements or contemporary build pipelines.

This quickstart demonstrates how to set up `coffee-middleware` with an older Express 3.x application to compile and serve CoffeeScript files on demand, including a basic example `.coffee` file and a server setup.

const express = require('express'); const coffeeMiddleware = require('coffee-middleware'); const path = require('path'); const fs = require('fs'); // Create a dummy public directory and a .coffee file for demonstration const publicDir = path.join(__dirname, 'public'); const coffeeFilePath = path.join(publicDir, 'hello.coffee'); if (!fs.existsSync(publicDir)) { fs.mkdirSync(publicDir); } fs.writeFileSync(coffeeFilePath, 'console.log "Hello from CoffeeScript!"'); // Note: express.createServer() and app.configure() are deprecated in modern Express. // This example uses patterns from Express 3.x to demonstrate functionality. const app = express(); // Mock the old `configure` method for compatibility with the example structure app.configure = function(fn) { fn(); }; app.configure(function () { app.use(coffeeMiddleware({ src: publicDir, bare: true, // Compile without the top-level safety wrapper compress: true, // Example option (may require 'uglify-js' in older versions) force: true // Ensure recompilation on each request for demo })); // Serve static files, ensuring compiled JS files can be accessed app.use(express.static(publicDir)); }); const PORT = 3000; app.listen(PORT, () => { console.log(`Server running on http://localhost:${PORT}`); console.log(`Try accessing http://localhost:${PORT}/hello.js`); console.log(`(This will compile and serve public/hello.coffee as JavaScript)`); }); // To run this example, you would typically need to install older versions: // npm install express@3.x coffee-middleware connect@2.x
Debug
Known issues
breakingThis package relies on `express.createServer()` and `app.configure()` which were deprecated in Express 4.x. It is not compatible with modern Express applications without significant bridging or downgrading Express versions.
fix
Consider using modern build tools (e.g., Webpack, Rollup, Vite) to precompile CoffeeScript (or switch to TypeScript/modern JS) or use an Express 3.x compatible environment for this middleware.
affects: >=4.0.0 (for Express)
deprecatedThe use of CoffeeScript for new web development projects has largely declined. Modern projects typically use TypeScript or contemporary JavaScript with transpilers like Babel.
fix
Evaluate if CoffeeScript is still the appropriate language for your project. Consider migrating to TypeScript or plain JavaScript with a modern build setup for better tooling and community support.
affects: All
gotchaThis package is CommonJS-only and cannot be directly `import`ed in an ESM module context. Attempting to do so will result in a runtime error.
fix
Ensure your project is configured for CommonJS modules if using this package, or use `require()` within an ESM module if supported by your runtime/transpiler setup (e.g., Node.js with `createRequire`).
affects: All
gotchaThe package is at version 0.2.1, indicating an early development stage and potential lack of stability or extensive testing for production environments. It has not seen updates for many years.
fix
Use with caution in production. Review the source code for potential vulnerabilities or unhandled edge cases. Consider if a more mature and maintained solution exists for your needs.
affects: All
Errors
Common errors & fixes
TypeError: app.createServer is not a function
Attempting to use `express.createServer()` with Express 4.x or later.
fix
This middleware is designed for Express 3.x. You either need to downgrade Express (e.g., `npm install express@3.x`) or refactor your application to not use this legacy middleware.
Error: Cannot find module 'coffee-middleware'
The package is not installed or the Node.js module resolution path is incorrect.
fix
Ensure the package is installed: `npm install coffee-middleware` (or `npm install iced-coffee-middleware` if that was the intended name, though the readme uses `coffee-middleware`). Check `node_modules` and your `package.json`.
SyntaxError: Cannot use import statement outside a module
Attempting to `import` `coffee-middleware` in a CommonJS context or using `require()` in an ESM context without proper configuration.
fix
This package is CommonJS. Use `const coffeeMiddleware = require('coffee-middleware');` and ensure your file is treated as CommonJS (e.g., no `"type": "module"` in `package.json` or rename to `.cjs`).
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
coffee-scriptrequiredCore compiler for .coffee files.
connectrequiredPeer dependency for middleware integration. Requires an older version.
expressrequiredPeer dependency for middleware integration. Requires an older version (pre-4.x).
Agent activity
6 hits · last 30 days
node
6
Resources
iced-coffee-middleware — npm install iced-coffee-middleware · libregistry