Yarn workspaces and baseUrl in a shared package

Viewed 92

I've set up a monorepo with yarn workspaces. Thus far it's structure is similar to:

/packages
  /app1 <-- CRA
  /common
    Component1.js
    Component2.js
    jsconfig.json

  

I would like to create an absolute reference in Component1 to Component2. In other words, instead of import thing from ./Component2, I would like to write import thing from Component2. Thus, I have in my jsconfig.json in common

{
  "compilerOptions": {
    "baseUrl": ".",
  }
}

However, when I run yarn --cwd packages/app1 start, I get a compile error telling me Component2 can't be found.

So, how can I get baseUrl recognized by webpack in the referenced package?

0 Answers
Related