Can I write npm package in CoffeeScript?

后端 未结 5 796
夕颜
夕颜 2020-12-12 11:54

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?

5条回答
  •  自闭症患者
    2020-12-12 12:21

    You 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

提交回复
热议问题