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

@vrx-volar/dts

v0.3.0

Published

> 该包处于实验阶段,不建议直接使用在生产环境

Downloads

52

Readme

@vrx-volar/dts

该包处于实验阶段,不建议直接使用在生产环境

为解决 使用 vue-tsc 内部 API 生成 .d.ts 文件时,

由于vue-tsc内部 API 变更过于频繁,

无法基于 semver 规范宽松匹配 vue-tsc 版本的问题。

基于 vue-tsc >=2.0.19 封装

如果部分 volar 插件无法正确的加载,可能是 该 volar 插件未适配 vue/language-tools 2.x.x 的更新

安装

npm i @vrx-volar/dts
yarn add @vrx-volar/dts
pnpm add @vrx-volar/dts
bun add @vrx-volar/dts

createProject

根据 minimatch 规则匹配项目文件,并为其转换对应 .d.ts 文件

import { createProject, writeTypes } from '@vrx-volar/dts'

const { files } = await createProject({
  match: ['**/*.vue', '**/*.?({m,c}){ts,js}?(x)'],
  globbyOptions: { 
    absolute: true,
    onlyFiles: true,
  },
})

// 项目入口文件夹
const inputDir = join(process.cwd(),'src')
// 项目出口文件夹
const outDir = join(process.cwd(),'dist')
// 将 转换的结果写入文件系统
await writeTypes(inputDir,outDir,files)
// 自定义写入时的后缀名
// 在该例子下生成 *.d.ts *.d.mts
await writeTypes(inputDir,outDir,files,['.d.ts','.d.mts'])
// 自定义写入时的后缀名
// 在该例子下仅生成 *.d.mts
await writeTypes(inputDir,outDir,files,['.d.mts'])

rollupTypes

将文件夹下所有.d.ts,合并到指定入口.d.ts 文件中,并删除文件夹下其余所有 .d.ts 文件

import { createProject, write } from '@vrx-volar/dts'

const { files } = await createProject({
  match: ['**/*.vue', '**/*.?({m,c}){ts,js}?(x)'],
  globbyOptions: { 
    absolute: true,
    onlyFiles: true,
  },
})

// 项目入口文件夹
const inputDir = join(process.cwd(),'src')
// 项目出口文件夹
const outDir = join(process.cwd(),'dist')
// 将 转换的结果写入文件系统
await write(inputDir,outDir,files)
// 将所有.d.ts 集合到 index.d.ts 文件中
await rollupTypes('index.d.ts',outDir)
// 自定义写入时的后缀名
// 在该例子下生成 index.d.ts index.d.mts
await rollupTypes('index.d.ts',outDir,['.d.ts','.d.mts'])
// 自定义写入时的后缀名
// 在该例子下仅生成 index.d.mts
await rollupTypes('index.d.ts',outDir,['.d.mts'])

cleanTypes

删除指定目录下所有的 .d.ts 文件

import { cleanTypes } from '@vrx-volar/dts'

await cleanTypes(outDir)

其余 API 请参照 @vrx-volar/tsc