How to publish a module written in ES6 to NPM?

前端 未结 11 639
自闭症患者
自闭症患者 2020-11-29 15:22

I was about to publish a module to NPM, when I thought about rewriting it in ES6, to both future-proof it, and learn ES6. I\'ve used Babel to transpile to ES5, and run tests

11条回答
  •  死守一世寂寞
    2020-11-29 15:58

    The main key in package.json decides the entry point to the package once it's published. So you can put your Babel's output wherever you want and just have to mention the right path in main key.

    "main": "./lib/index.js",
    

    Here's a well written article on how to publish an npm package

    https://codeburst.io/publish-your-own-npm-package-ff918698d450

    Here's a sample repo you can use for reference

    https://github.com/flexdinesh/npm-module-boilerplate

提交回复
热议问题