admin管理员组

文章数量:1434900

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"],
}

本文标签: viteHow to forbid direct imports from other packages in a Typescript monorepoStack Overflow