reactjs - How to publish a jsx file to npm? -
i want publish react component npm, found out it's difficult. file simple, es6 syntax. steps or solution publish npm can install , run locally installed react? have read article http://chadly.net/2015/04/publishing-react-to-npm/, seems outdated , failed following it.
use babel-cli transpile file es5 , publish file.
put source-files in 1 folder, e.g. src
, install babel , add build
entry npm scripts (package.json/scripts): "build": "babel --out-dir=lib src"
.
no every time call npm run build
. transpiled code in lib
folder. in index.js
refer lib
folder-folder.
of course can add build
script npm hooks such "prepublish": "npm run build"
or similar,
Comments
Post a Comment