Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
browserify plugin for coffee-script with support for mixed .js and .coffee files
The coffeeify npm package is a Browserify transform for CoffeeScript. It allows you to require CoffeeScript files in your Browserify bundle, enabling seamless integration of CoffeeScript into your JavaScript projects.
Transform CoffeeScript to JavaScript
This feature allows you to transform CoffeeScript files into JavaScript using Browserify. The code sample demonstrates how to bundle a CoffeeScript file (`main.coffee`) into a JavaScript file (`bundle.js`) using the coffeeify transform.
const browserify = require('browserify');
const fs = require('fs');
browserify({
entries: ['main.coffee'],
transform: ['coffeeify']
})
.bundle()
.pipe(fs.createWriteStream('bundle.js'));
Integration with Browserify
This feature shows how to integrate coffeeify with Browserify directly. The code sample demonstrates how to bundle a CoffeeScript file (`app.coffee`) into a JavaScript file (`app.bundle.js`) by specifying the `.coffee` extension and using the coffeeify transform.
const browserify = require('browserify');
const coffeeify = require('coffeeify');
const fs = require('fs');
browserify({
entries: ['app.coffee'],
extensions: ['.coffee']
})
.transform(coffeeify)
.bundle()
.pipe(fs.createWriteStream('app.bundle.js'));
The `coffeescript` package is the official CoffeeScript compiler. It can be used to compile CoffeeScript files into JavaScript. Unlike coffeeify, which is a Browserify transform, `coffeescript` is a standalone compiler that can be used in various build processes.
The `gulp-coffee` package is a Gulp plugin for compiling CoffeeScript files. It integrates with the Gulp build system, allowing you to include CoffeeScript compilation in your Gulp tasks. This is different from coffeeify, which is specifically designed for use with Browserify.
The `grunt-contrib-coffee` package is a Grunt plugin for compiling CoffeeScript files. It integrates with the Grunt build system, enabling you to add CoffeeScript compilation to your Grunt tasks. This package is similar to gulp-coffee but is designed for use with Grunt instead of Gulp.
CoffeeScript browserify transform. Mix and match .coffee
and .js
files in the same project.
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:
$ npm install coffeeify
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);
..
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
With npm do:
npm install coffeeify
MIT
FAQs
browserify plugin for coffeescript with support for mixed .js and .coffee files
The npm package coffeeify receives a total of 325,433 weekly downloads. As such, coffeeify popularity was classified as popular.
We found that coffeeify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.