coffee2closure

raw JSON →
0.1.12 verified Fri May 01 auth: no javascript deprecated

A utility that fixes CoffeeScript-compiled JavaScript output to be compatible with Google Closure Compiler. Version 0.1.12 is the latest stable release as of late 2013, with no active development since then. It addresses issues like missing 'var' declarations and proper function expression wrapping that break Closure Compiler's advanced optimizations. Unlike manual post-processing, it automates these fixes. The package is designed for build pipelines, notably used as a Grunt plugin. Given its age and lack of updates, it should be considered deprecated for modern projects.

error Error: Cannot find module 'coffee2closure'
cause Package not installed or import path incorrect.
fix
Run npm install coffee2closure --save-dev and ensure your import uses the correct path.
error TypeError: coffee2closure is not a function
cause Using default import incorrectly or requiring the wrong export.
fix
Use import coffee2closure from 'coffee2closure' or const coffee2closure = require('coffee2closure').
error CoffeeScript syntax error on line X
cause Input contains invalid CoffeeScript.
fix
Fix the CoffeeScript syntax before passing it to coffee2closure.
error Grunt task not found: coffee2closure
cause Grunt plugin not loaded correctly.
fix
Add grunt.loadNpmTasks('coffee2closure') in your Gruntfile.
deprecated Package is no longer maintained and has not been updated since 2013.
fix Consider using modern alternatives like decaffeinate or direct transpilation with Babel.
gotcha Input must be CoffeeScript source code, not compiled JavaScript.
fix Ensure you pass .coffee file contents, not .js.
gotcha The output may still require manual adjustments for strict Closure Compiler settings.
fix Review the output and apply additional fixes if needed.
npm install coffee2closure
yarn add coffee2closure
pnpm add coffee2closure

Shows how to import and use coffee2closure to transform CoffeeScript code for Closure Compiler compatibility.

import coffee2closure from 'coffee2closure'; import fs from 'fs'; const input = fs.readFileSync('input.coffee', 'utf8'); const output = coffee2closure(input); console.log(output);