[英]Exclude certain paths from being autoimported with Lerna, Typescript, and VS Code
I have a lerna@3.16 project with a chain of multiple packages.我有一个包含多个包链的 lerna@3.16 项目。
|-tsconfig.lib.json
|-packages
|--format
|----tsconfig.lib.json
|--helper
|----tsconfig.lib.json
Each package extends the tsconfig.lib.json from the top level.每个 package 从顶层扩展 tsconfig.lib.json。 helper
depends on format
. helper
取决于format
。 When I go to auto import from format, I get three levels of imports:当我 go 从格式自动导入时,我得到三个级别的导入:
packages/helper
@org-name/helper
(the right one) @org-name/helper
(正确的那个)packages/helper/dist
How do I exclude the two import paths with packages
without breaking all imports?如何在不破坏所有导入的情况下排除packages
的两个导入路径?
Years later, I think that https://www.typescriptlang.org/docs/handbook/project-references.html are the way to handle this with Typescript, at least.多年后,我认为https://www.typescriptlang.org/docs/handbook/project-references.html至少是用 Typescript 处理这个问题的方法。
Each tsconfig within packages
would have a packages
中的每个 tsconfig 都会有一个
// packages/helper/tsconfig.lib.json
"references": [
{ "path": "../format" }
]
The root package.json would include根 package.json 将包括
"paths": {
"@org-name/helper": "./packages/helper"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.