最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vite - How to forbid direct imports from other packages in a Typescript monorepo? - Stack Overflow

programmeradmin1浏览0评论

I'm using vite in my monorepo and I want to prohibit direct imports (without passing through the package name).

I have this structure:

root
|---packages
|     |-------front
|     |-------utils
|
|---package.json

I want to avoid that someone does this

//in front/main.ts
import { something } from "../utils/lib.ts

They need to do this instead

import { something } from "@repo/utils"

I am using vite. I tried the fs.allowed option, but it does not prevent me from doing this wrong import.

//it still allows for every import style
fs:{
  allowed: ["./src"],
}
发布评论

评论列表(0)

  1. 暂无评论