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

ts-webpack-demo-for-andy

v3.0.0

Published

这是个 用 webpack 打包 ts 的 库,你可以在上面 测试,打包你的 ts 库

Downloads

5

Readme

这是个 用 webpack 打包 ts 的 库,你可以在上面 测试,打包你的 ts 库

实现

  • [x] ts 项目,tsconfig.json 就可以实现打包 tsc 一条命令即可
  • [x] 建议用 webpack 打包,更强大,配合 tsconfig.json 生成 typings 文件
  • [x] 两个文件的输出路径要一致

疑问

  • 用 ts 编写一个库,也生成了.d.ts 文件,然后发布到 npm,然后 在第三方项目中引入这个库,报错, 解决方法:在 node_modules 中建 @types/xxxx(库名)/index.d.ts 就不报错了, 但是问题来了,自己写的库,如何把库的.d.ts 文件提交到 @types/xxx 呢

    解决疑问: 只需要在 tsconfig.json 中 添加 include: ["typeings"], 然后在 项目根目录下新建 typings目录即可,如果里面还报错,那么在 typings 里 新建和你 引入的库 同名的 xxxx.d.ts 文件即可

    参考: https://www.jianshu.com/p/35742227738e https://juejin.im/post/5e43d7a3e51d45270d530300

收获

参考 https://juejin.im/post/5d1f01fce51d454d5653585c

发布库到 npm 如何忽略 不必要的文件

  • 黑名单 新建一个 .npmignore 文件,在其中添加不要的文件(夹)
  • 白名单 (推荐) 在 package.json 中设置一个要发布的文件(夹)白名单 "files": ["lib/**/*"] ,你要添加发布的库的文件

参考:https://godbasin.github.io/2019/01/05/ts-npm-package/

https://nodelover.gitbook.io/typescript/tsconfig.json

https://segmentfault.com/a/1190000021421461 【xxxx】