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

typescript-dynamic-path-plugin

v1.1.0

Published

## 介绍 A TypeScript Language Service Plugin 用于帮助typescript在多项目仓库中识别定位@/路径

Downloads

4

Readme

typescript-dynamic-path-plugin

介绍

A TypeScript Language Service Plugin
用于帮助typescript在多项目仓库中识别定位@/路径

示例

项目结构如下

project\
  ACT\
    2023\
      demo1\
      demo2\
  COMMON\
    setting\
  utils\

该项目结构下,

  • ACT\2023\demo1
  • ACT\2023\demo2
  • COMMON\setting
    都可以看做独立的前端项目, 他们共用外部的构建配置和工具函数库等内容

本插件解决的问题是
针对ACT\2023\demo1\pages\app.tsx中的 import { xx } from '@/api';
使 '@/api' 指向 ACT\2023\demo1\api\index.ts

针对ACT\2023\demo2\pages\app.tsx中的 import { yy } from '@/api';
使 '@/api' 指向 ACT\2023\demo2\api\index.ts

针对COMMON\setting\pages\app.tsx中的 import { zz } from '@/api';
使 '@/api' 指向 COMMON\setting\api\index.ts

配置

示例, 在tsconfig->compilerOptions.plugins中配置

{
  "name":"typescript-dynamic-path-plugin",
  "roots":[
    {
      "name":"ACT",
      "depth":2
    },
    {
      "name":"COMMON",
      "depth":1
    }
  ],
  "folders":["api","components","pages","store","img","js","style","scripts"]
}

roots 指定项目根目录, 该根目录下的文件夹都是各自独立的前端项目,须使用depth指定深度
folders 独立项目下的文件夹, 只有在这里定义了的文件夹才可以使用 @/api @/style 的形式引入

TODO:

  1. 发布npm √
  2. ~~修改import代码提示~~ -- failed 似乎要通过vscode插件才能实现
  3. 尝试使用vscode插件实现本插件功能, 并完成修改import提示的需求 √ (在vscode插件的package.json的contributes.typescriptServerPlugins中添加本插件, 但似乎不能传递配置参数)
  4. 若能完成3, 在vscode插件内能否让.vue文件也支持 @/ 路径

bugs

在.vue文件中无效, 猜测是vscode插件volar使用了独立的Typescript Language Service.
若是这样, 在本插件的能力范围内无法解决这个问题