这篇文章上次修改于 495 天前,可能其部分内容已经发生变化,如有疑问可询问作者。
- 在 npm 官网上注册账户,本步略。
修改 tsconfig.json
a. 打开如下注释:
"declaration": true
这一步是为了在执行打包命令
yarn run build
时生成*.d.ts
文件。b. 打开如下注释:
"outDir": "./lib"
这一步是为了将生成的打包文件放到一个单独的目录
lib
中。在 packages.json 中添加类似如下内容
{ "name": "bincoder", "version": "0.2.1", "description": "A binary encoder / decoder implementation in Typescript.", "main": "lib/src/index.js", "repository": "git@github.com:felicityin/bincoder.git", "author": "felicityin <yinjingping2022@gmail.com>", "homepage": "https://github.com/felicityin/bincoder#readme", "license": "MIT", "keywords": ["bincode", "rust", "serde"], "engines": { "node": ">=14" }, "scripts": { "build": "tsc", "test": "jest", "format": "prettier -wu src/* __test__/*", "prepare": "husky install", "clean": "rm -rf lib", "release": "npm publish --access public.", "prepublishOnly": "yarn run test", "version": "git add -A src", "postversion": "git push && git push --tags" }, "publishConfig": { "access": "public" }, "bugs": { "url": "https://github.com/felicityin/bincoder/issues" }, "pre-commit": [ "format" ], "directories": { "lib": "lib", "test": "__tests__" }, "files": [ "lib" ], ... }
发布
npm publish
如果想删除已经发布的包,可以执行如下命令:
npm unpublish [<pkg>][@<version>] --force
例如:
npm unpublish dzmtest@1.0.1 --force
没有评论