[NPM + React] Prepare a Custom React Hook to be Published as an npm Package
2023-09-14 08:59:14 时间
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" }
相关文章
- 从 package.json 来聊聊如何管理一款优秀的 Npm 包
- [前端]解决React npm包管理器及npx安装网络慢的方式
- 玄学资料库(一)NPM、PYPI、DockerHub 备份
- React魔法堂:echarts-for-react源码略读
- 【随笔】npm- 更新所有依赖包
- 5种前端代码共享方案:npm包、git submodules、脚手架模板、复制、UMD或模块联邦
- pnpm 是凭什么对 npm 和 yarn 降维打击的
- npm error code ELIFECYCLE
- 微服务项目:尚融宝(12)(前端平台:NPM包管理器)
- react的jsx和React.createElement是什么关系?面试常问_2023-02-27
- react源码分析:深度理解React.Context
- 理解PHP MVC、NPM、YARN命令的相关说明
- 安装Linux:如何快速使用NPM进行全局安装(linuxnpm全局)
- 探索React框架中MySQL数据库的应用(react mssql)
- 淘宝网提供的国内NPM镜像简介和使用方法