I have used CoffeeScript for a while. Now I need to write a npm package, can I write it in CoffeeScript, or I should compile CoffeeScript into JavaScript?
NPM is the default package manager for node. It is used to install, share, and manage javascript packages in a project.
npm install [<@scope>/]<name>@<version> : Install the specified version of the package.
I'm going to suggest that you write your package in coffeescript, but only publish it in javascript. I do it like this:
src lib src is committed to my git repo, lib is in my .gitignore lib is published to npm, src is in my .npmignore coffee-script package is in my devDependencies You can take a look at a simple package of mine, refix, for inspiration:
npm install refixYou can write NPM modules in coffeescript, but in order for them to be usable by JS users they must be compiled to JS before you publish on NPM.
package.json makes this easy with their prepublish script hook which runs the specified script before you publish. Heres an example of a prepublish NPM hook in zombie.js
https://github.com/assaf/zombie/blob/master/package.json#L16
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With