npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sm-tool

v1.0.47

Published

sm-tool工具包

Downloads

34

Readme

rollup打包npm资源并发布到官方npm源步骤:

  1. 创建目录结构如:
sm-tool/src
sm-tool/src/core
sm-tool/src/types # 所有导出的类型声明放在该目录下的文件中
sm-tool/src/util
  1. 初始化npm目录,生成packages.json文件 npm init -y

  2. 初始化typescript配置,生成tsconfig.json文件 tsc --init

  3. 创建rollup.config.js文件

  4. 安装依赖包

npm i rollup -D
npm i rollup-plugin-dts -D
npm i rollup-plugin-typescript2 -D
npm i typescript -D
npm i rollup-plugin-uglify -D
  1. 编写rollup打包配置文件rollup.config.js

  2. 配置package.json中的打包命令build

# 默认采用当前目录下的rollup.config.js配置文件
"build": "rollup -c"
  1. 先随便写几行代码测试打包是否正常,如果打包出错,就按照提示信息修改,主要是tsconfig.json文件; 如果按照提示修改还是报错,多半是依赖包的版本问题,可以尝试先去掉支持cjs方式的导入。 以下配套的依赖版本暂时是ok的。
{
    "rollup": "~2.77.0",
    "rollup-plugin-dts": "~4.2.2",
    "rollup-plugin-typescript2": "~0.32.1",
    "typescript": "~4.7.4"
}
  1. 修改package.json文件中的main、module、browser

  2. 其它注意事项 (1)发布到npm官网之前,要确保使用的registry为npm官方源https://registry.npmjs.org (2)查看当前登录的npm账号信息:npm profile get

nrm ls
nrm use npm
# 默认公开发布
npm publish
npm publish --access public
npm publish --access restricted # 仅限域级npm包才能使用私有发布,但是官网的私有包收费
# 卸载发布的包
npm unpublish sm-tool -f