1. coffeeify
browserify plugin for coffeescript with support for mixed .js and .coffee files
coffeeify
Package: coffeeify
Created by: jnordberg
Last modified: Fri, 11 Nov 2022 06:33:59 GMT
Version: 3.0.1
License: MIT
Downloads: 1,560,431
Repository: https://github.com/jnordberg/coffeeify

Install

npm install coffeeify
yarn add coffeeify

coffeeify Build Status

CoffeeScript browserify transform. Mix and match .coffee and .js files in the same project.

NOTE: As of version 3.0.0 coffeeify requires CoffeeScript to be installed manually as a peerDependency, also note that the CoffeeScript package has changed name from coffee-script to coffeescript.

Example

Given some files written in a mix of js and coffee:

foo.coffee:

 console.log require './bar.js'

bar.js:

 module.exports = require('./baz.coffee')(5)

baz.coffee:

 module.exports = (n) -> n ** n

Install coffeeify into your app, and CoffeeScript if you don't have it already:

$ npm install --save-dev coffeeify coffeescript

When you compile your app, just pass -t coffeeify to browserify:

 $ browserify -t coffeeify foo.coffee > bundle.js
$ node bundle.js
3125

You can omit the .coffee extension from your requires if you add the extension to browserify's module extensions:

 module.exports = require('./baz')(5)
$ browserify -t coffeeify --extension=".coffee" foo.coffee > bundle.js
$ node bundle.js
3125

You can also pass options to the CoffeeScript compiler:

$ browserify -t [ coffeeify --bare false --header true ] --extension=".coffee" foo.coffee
..
// Generated by CoffeeScript 1.10.0
(function() {
  console.log(require('./bar.js'));

}).call(this);
..

Options

Name Default Description
sourceMap null Generate source maps, deteremined from browserify's --debug option if not set.
bare true Omit the (function(){ .. }).call(this); wrapper.
header false Include the // Generated by CoffeeScript <version> header in every file processed.

When using browserify programatically options can be passed as an object, example:

 browserify = require 'browserify'
coffeeify = require 'coffeeify'

bundle = browserify
  extensions: ['.coffee']

bundle.transform coffeeify,
  bare: false
  header: true

bundle.add 'foo.coffee'

bundle.bundle (error, result) ->
  throw error if error?
  process.stdout.write result

Install

With npm do:

 npm install --save-dev coffeeify

CoffeeScript is not installed automatically, so that you can choose what version of CoffeeScript you'd like:

 npm install --save-dev coffeescript  # Or coffeescript@1 to use CoffeeScript 1.x

License

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code