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

library-rollup

v1.0.0

Published

TypeScript library npm package boilerplate

Downloads

4

Readme

Library Rollup 说明

参考文档

  1. rollup/rollup-starter-lib TS 版本
  2. rollup/rollup-starter-lib JS 版本
  3. Creating Awesome TypeScript NPM Packages

先决条件

  1. NPM 要求包名唯一,可以用命令行查询
npm search library-rollup
  1. 创建远程仓库,并克隆下来
git clone https://github.com/adntin/library-demo.git

Scaffolding the Library, 搭建库

  1. package.json安装依赖包
yarn add -D eslint \
            prettier \
            typescript \
            tslib \
            rollup \
            @rollup/plugin-commonjs \
            @rollup/plugin-node-resolve \
            @rollup/plugin-typescript
  1. package.json配置运行脚本
{
  "scripts": {
    // dev: Run Rollup in watch mode (-w) to detect changes to files during development
    "dev": "rollup -c -w",
    // build: Run Rollup to build our production release distributable
    "build": "rollup -c"
  }
}
  1. package.json配置输出文件
// main: CommonJS (CJS) output file
// module: ES Module (ESM) output file
// browser: Universal Module Definition (UMD) output file
// files: Our files will be built to a “dist” folder
{
  "main": "dist/library-demo.cjs.js",
  "module": "dist/library-demo.esm.js",
  "browser": "dist/library-demo.umd.js",
  "files": ["dist"]
}
  1. TypeScript Configuration, tsconfig.json配置
{
  "compilerOptions": {
    "target": "ES6",
    "module": "ESNext",
    "moduleResolution": "Node",
    "strict": true,
    "esModuleInterop": true
  }
}
  1. Rollup Configuration, rollup.config.js配置

Setting up the Development Environment, 搭建开发环境

  1. 创建应用工程(TypeScript 版本)
yarn create react-app my-app --template typescript
  1. library-rollup项目配置
# 关联包
yarn link
# Start Rollup in watch mode
yarn dev
  1. package.json配置
# 关联包
yarn link library-rollup
# 添加自研库依赖
yarn add file:../library-rollup
{
  "type": "module",
  "dependencies": {
    "library-rollup": "file:../library-rollup"
  }
}
  1. tsconfig.json配置
{
  "baseUrl": ".",
  "paths": {
    "library-rollup": ["node_modules/library-rollup/src"],
    "library-rollup/*": ["node_modules/library-rollup/src/*"]
  }
}

Documentation 文档

  1. 添加依赖包
yarn add -D typedoc
  1. 添加脚本
"scripts": {
  "docs": "typedoc src --out docs",
}
  1. 生成文档
yarn docs

Publishing 发布

# 1. 登录 NPM 帐号
npm login
# 2. 发布 NPM 包
# 参数说明 [--access <public|restricted>]
npm publish --access public