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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tlylt/vue-component-0

v0.0.1

Published

## Steps

Readme

Vue 3 + TypeScript + Vite Component Library Starter

Steps

Scaffold the project

cd my-project-folder
# Scaffold directly into the folder
npm create vite@latest . -- --template vue-ts
# Install dependencies
npm install

# Include node types which are needed whenever you need to import from node
npm i --save-dev @types/node

## Update `package.json`
- Change name to `@username/projectname` to publish into your user scope.
- Remove `"private": true,` to allow publishing
- Specify `vue` as a peer dependency.

```json
  "peerDependencies": {
    "vue": "^3.0.0"
  },
  • Add dist and optionally src to files to be published.
  "files": [
    "dist",
    "src"
  ],
  • Add author, license, repository, keywords for package information.
  "author": "your-user-name",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/your-user-name/your-repo-name.git"
  },
  "keywords": [
    "vue"
  ],
  • Add exports fields to indicate how the package can be imported. Also mentions how types can be loaded.
  "exports": {
    ".": {
      "types": "./dist/types/index.d.ts",
      "import": "./dist/your-component-name.es.js",
      "require": "./dist/your-component-name.umd.js"
    },
    "./style.css": "./dist/your-component-name.css"
  }

Update vite.config.ts

Add the build config. An important setting includes emptyOutDir, which means do not clean the dist folder when building JS files by Vite. This is because we let vue-tsc emit the type declarations and let Vite emit the JS files.

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path";

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  build: {
    lib: {
      entry: path.resolve(__dirname, "src/index.ts"),
      name: "YourComponentName",
      fileName: (format) => `your-component-name.${format}.js`,
    },
    rollupOptions: {
      external: ["vue"],
      output: {
        exports: "named",
        globals: {
          vue: "Vue",
        },
      },
    },
    emptyOutDir: false, // to retain the types folder generated by tsc
  },
})

Since Vite will not help to empty out the folder, we need to update package.json to help do that.

    "build": "rm -rf dist && vue-tsc -b && vite build",

Add index.ts

Include an entry point, to allow it to be both used globally or individually.

import type { App } from "vue";
import HelloWorld from "./components/HelloWorld.vue";

export { HelloWorld };

export default {
  install(app: App) {
    app.component("HelloWorld", HelloWorld);
  },
};

Update tsconfig.app.json

The tsconfig.app.json is the one that we intend to use for building our component. The tsconfig.node.json is for any other development TypeScript files.

Set "noEmit": false so that type declarations can be emitted. This is set to true by default in the base config that we extend from. Other important settings include "emitDeclarationOnly": true to only emit type files.

{
  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "compilerOptions": {
    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "noUncheckedSideEffectImports": true,

    /* Type Declaration */
    "noEmit": false, // This is important to generate type declaration files
    "emitDeclarationOnly": true, // This prevents the generation of JS files, which is left to vite
    "declaration": true,
    "declarationMap": true,
    "outDir": "dist/types",
    "rootDir": "src"
  },
  "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
  "exclude": ["node_modules", "dist"]
}

Remove unused files

Remove the default files that are not needed, e.g., App.vue, main.ts, style.css, src/assets/, index.html.

Publish

# Update version in package.json as needed
npm run build
npm publish --access public

Usage

Make sure to import the style.css if your component contains css styles.

import { YourComponentName } from '@user-name/your-component-name'
import '@user-name/your-component-name/style.css'