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 🙏

© 2026 – Pkg Stats / Ryan Hefner

lib-root

v1.0.2

Published

Testando

Readme

Guia de Criação de Lib TypeScript

Este guia explica como estruturar uma biblioteca em TypeScript, configurar aliases, compilar para uma pasta lib e publicar no npm.

1. Estrutura básica do projeto


lib-root/
├── src/
│   ├── utils/
│   │   └── hasValue.ts
│   └── index.ts
├── lib/  <-- saída do TypeScript (outDir)
├── package.json
├── tsconfig.json
└── README.md
  • src/ → código fonte da biblioteca
  • lib/ → arquivos compilados pelo TypeScript (outDir)
  • index.ts → ponto central de exportação da lib

2. tsconfig.json

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "CommonJS",
    "declaration": true,
    "declarationMap": true,
    "outDir": "lib",
    "rootDir": "src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "baseUrl": "src",
    "paths": {
      "@utils/*": ["utils/*"]
    }
  },
  "include": ["src"]
}

Explicação:

  • outDir: "lib" → define a pasta de saída da build
  • baseUrl: "src" → define o ponto de referência para aliases
  • paths: { "@utils/*": ["utils/*"] } → permite importar assim:
import { hasValue } from '@utils/hasValue';
  • declaration: true → gera arquivos .d.ts de tipagem
  • declarationMap: true → gera mapas para depuração de tipagem

3. index.ts (export centralizado)

// src/index.ts
export * from '@utils/hasValue';

Isso permite importar a lib inteira apenas com:

import { hasValue } from 'lib-root';

4. package.json

{
  "name": "lib-root",
  "version": "1.0.0",
  "description": "Biblioteca utilitária em TypeScript",
  "main": "lib/index.js",
  "types": "lib/index.d.ts",
  "scripts": {
    "build": "tsc",
    "dev": "ts-node src/index.ts"
  },
  "keywords": [],
  "author": "Seu Nome",
  "license": "ISC",
  "devDependencies": {
    "@types/node": "^24.3.0",
    "ts-node": "^10.9.2",
    "typescript": "^5.9.2"
  }
}

Importante:

  • main → arquivo principal compilado (lib/index.js)
  • types → arquivo de tipagem (lib/index.d.ts)
  • scripts.build → comando para gerar a build (npm run build)

5. Compilando a lib

npm run build
  • Compila todos os arquivos de src/ para lib/
  • Gera .js e .d.ts

6. Publicando no npm público

  1. Login no npm
npm login

Informe:

  • Username
  • Password
  • Email
  1. Publicar
npm publish --access public
  • --access public garante que a lib fique pública
  • Após publicar, qualquer projeto pode instalar via:
npm install lib-root

7. Usando a lib em outro projeto

import { hasValue } from 'lib-root';

console.log(hasValue("teste")); // true

8. Resumo

  • src/ → código fonte
  • lib/ → saída compilada (outDir)
  • tsconfig.json → configurações de build + aliases (@utils)
  • package.jsonmain e types corretos para npm
  • npm run build → compila a lib
  • npm login → autenticação
  • npm publish --access public → publica a lib