How can I import a package inside another one #1333
-
I'd like to know how would you do to use a package inside another one. For example, using a function from |
Beta Was this translation helpful? Give feedback.
Answered by
belgattitude
Feb 16, 2022
Replies: 1 comment 2 replies
-
Here's a reply with an example here #1347. It basically adds the @your-org/core-lib dependency to the @your-org/ui-lib Interesting parts are:
"dependencies": {
"@your-org/core-lib": "workspace:^"
},
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "./src",
"paths": {
// First line allows you to resolve `import {} from "@your-org/core-lib/folder1/subfolder/file"`
"@your-org/core-lib/*": ["../../../packages/core-lib/src/*"],
// Second line resolves the barrel. `import {} from "@your-org/core-lib"`
"@your-org/core-lib": ["../../../packages/core-lib/src/index"]
}
}
} PS : Exposing the barrel (index.ts) or the modules exports is preferred if you intend to publish the package... Let me know if you want more in-depth and hope it will help you |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
ValentinH
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a reply with an example here #1347. It basically adds the @your-org/core-lib dependency to the @your-org/ui-lib
Interesting parts are: