Skip to content

How can I import a package inside another one #1333

Answered by belgattitude
ValentinH asked this question in Q&A
Discussion options

You must be logged in to vote

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:

  1. state your new dep, in dependencies (or peerDependencies)
  "dependencies": {
    "@your-org/core-lib": "workspace:^"
  },
  1. inform typescript how to resolve it in tsconfig.json
{
  "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-or…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ValentinH
Comment options

@belgattitude
Comment options

Answer selected by ValentinH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants