admin管理员组文章数量:1426855
I am attempting to migrate several repositories to the monorepo architecture and I am currently working on a POC bootstrapped with Turborepo.
The issue I am seeing is that ts module aliasing isn't configured properly. I currently have a single ui package and I am trying to export a button ponent from the index.tsx
like so (notice, VS code not plaining, it thinks it can resolve the module):
However, when I attempt to build my application I see that the module is not in fact resolved:
Module not found: Can't resolve '@/ponents/Button'
I am at a loss here, does anyone know how to properly configure module aliases with turbo repo? Below is the tsconfig.json:
{
"extends": "tsconfig/react-library.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"],
"pilerOptions": {
"baseUrl": ".",
"paths": {
"@/ponents/*": ["./ponents/*"]
}
}
}
I am attempting to migrate several repositories to the monorepo architecture and I am currently working on a POC bootstrapped with Turborepo.
The issue I am seeing is that ts module aliasing isn't configured properly. I currently have a single ui package and I am trying to export a button ponent from the index.tsx
like so (notice, VS code not plaining, it thinks it can resolve the module):
However, when I attempt to build my application I see that the module is not in fact resolved:
Module not found: Can't resolve '@/ponents/Button'
I am at a loss here, does anyone know how to properly configure module aliases with turbo repo? Below is the tsconfig.json:
{
"extends": "tsconfig/react-library.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"],
"pilerOptions": {
"baseUrl": ".",
"paths": {
"@/ponents/*": ["./ponents/*"]
}
}
}
Share
Improve this question
edited Feb 2, 2023 at 8:10
Mayank Kumar Chaudhari
18.9k13 gold badges72 silver badges155 bronze badges
asked Feb 1, 2022 at 21:20
Logan MurphyLogan Murphy
4134 silver badges19 bronze badges
2
- 3 any updates on this? – untitled Commented Sep 23, 2022 at 21:37
- Look on this thread. You will have to do a little bit of trial and error to get this right. But this answer will get us in the right direction. – Mayank Kumar Chaudhari Commented Dec 2, 2022 at 4:02
1 Answer
Reset to default 2You need to setup the tsconfig.json
inside both packages/ui and root.
- Inside the packages/ui you have to set like the paths like this;
// root/packages/ui -> tsconfig.json
{
"extends": "tsconfig/react-library.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"],
"pilerOptions": {
"baseUrl": ".",
"paths": {
"@/ponents/*": ["ponents/*"] // Don't use "./ponents/*", instead like this: "ponents/*"
}
}
}
tsconfig.json
in root also.
// root -> tsconfig.json
{
"extends": "your_default_extends",
"pilerOptions": {
"plugins": [{your_plugins}],
"paths": {
"@*": ["./packages/ui/*"]
}
},
"include": ["your_include"],
"exclude": ["node_modules"]
}
If you have another project wanna using import @ alias as well, just add the route to the folder inside root tsconfig.json
too.
// root -> tsconfig.json
{
"extends": "your_default_extends",
"pilerOptions": {
"plugins": [{your_plugins}],
"paths": {
"@*": ["./packages/ui/*", "./apps/some_project/src/*"] // here
}
},
"include": ["your_include"],
"exclude": ["node_modules"]
}
本文标签: javascriptHow to configure module aliases in a monorepo bootstrapped with TurborepoStack Overflow
版权声明:本文标题:javascript - How to configure module aliases in a monorepo bootstrapped with Turborepo? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745482898a2660252.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论