码迷,mamicode.com
首页 > 其他好文 > 详细

[NPM + React] Prepare a Custom React Hook to be Published as an npm Package

时间:2019-11-04 17:31:37      阅读:63      评论:0      收藏:0      [点我收藏+]

标签:patch   class   enc   eve   read   require   correct   nbsp   json   

Before we publish our package, we want to make sure everything is set up correctly. We’ll cover versioning, preparing our package, adding a proper README, and updating our package.json.

 

Using npm version:

The reason to use npm version to prumping the version, is because it create a version commit and tag.

npm version patch

 

Setup a pre- and post- scripts:

"prepare": "yarn run build",
"postpublilsh": "git push --tags"

 

peerDependenices:

You might also need to update peerDependencies in order to info the user which verison of react is minimue required.

"peerDependencies": {
   "react": ">=16.8.6"
}

 

publishConfig:

Depend on your package name:

// A
"name": "some-react-hooks"

//B
"name": "@zhentiw/some-react-hooks" //@<user-name>/package-name

If you are using B version, it default to a private npm package, if you want to make it public:

"publishConfig": {
    "access": "public"
}

 

[NPM + React] Prepare a Custom React Hook to be Published as an npm Package

标签:patch   class   enc   eve   read   require   correct   nbsp   json   

原文地址:https://www.cnblogs.com/Answer1215/p/11792967.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!