Write in CoffeeScript and package in Javascript

--- layout: post title: Write in CoffeeScript and package in Javascript tags: coffeescript, javascript, npm ---

Like using CoffeeScript and want to publish your NPM modules but write them in CoffeeScript? It is actually really easy to do.

{
  .
  .
  .
  "main": "build/index.js"
  "scripts": {
    "prepublish": "coffee --bare --compile --output build lib"
  },
  .
  .
  .
}

`prepublish` is run before a `npm package` command. The one above compiles the contents of `./lib` and puts it in `./build`. You will want your package.json main to point to the build directory for module entry.

I find it useful to place `lib` the `.npmignore` to keep things clean for the tarball that gets built for NPM.

More Reading
Newer// The 10%
comments powered by Disqus