Julian Brooks
Julian Brooks

Reputation: 91

Turborepo Wildcard Exports with React

I'm new to Turborepo and am trying to export a component library from an internal package (@package-a). But when I go to import a component in @package-b I get the following error:

Cannot find module '@package-a/common/Button' or its corresponding type declarations.

As an example, the exports field of package.json in @package-a is like so:

"name":"@package-a",
"exports": {
    "./common": "./src/common/"
  }

The dependencies field of @package-b's package.json is like so:

"dependencies": {
    "@package-a": "*",
}

If I explicitly export the Button.tsx component from @package-a/common/ then it works, but I want to export multiple subdirectories (from @package-a) with many components and it would seem silly to have to list them ALL in the exports field.

The component library I want to export is made with React and Vite.

Am I missing a step? Am I not exporting the common directory properly?

Upvotes: 0

Views: 39

Answers (0)

Related Questions