[NPM + React] Prepare a Custom React Hook to be Published as an npm Package
2023-09-14 09:00:48 时间
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" }
相关文章
- node npm python 环境配置、安装
- React saga_react获取子组件ref
- React v18.x 在 react-router v6 使用 lazy 动态加载组件实现
- node.js常用npm命令
- npm入门使用介绍
- npm缺少css-loader,/style-compiler,stylus-loader问题,npm没有权限无法全局更新问题
- “NPM”的全称(github.com/npm/npm-expansions)
- 从npm发展历程看pnpm的高效
- 5种前端代码共享方案:npm包、git submodules、脚手架模板、复制、UMD或模块联邦
- 在本地和CI/CD中支持npm免登录发布
- npm自动改版本号+博客静态源代码自动上传
- 在React中使用 react-router-dom 编程式路由导航【含V5.x、V6.x】
- vue : 无法加载文件 C:UsersAdministratorAppDataRoamingnpmvue.ps1,因为在此系统上禁止运行脚本
- react 基础之组件篇二——Style in React
- 从 10 万 npm 用户信息被窃看开源软件供应链安全
- Mac npm install permission denied
- Linux 安装node.js和npm教程详解程序员
- 利用npm管理mssql数据库(npm mssql)
- 使用NPM和Oracle给您带来的IT解决方案(npm oracle)