0

I have an NX monorepo set up with two Stencil packages(I followed StencilJS docs): Package-A and Package-B. However, there is no React libraries alongside them, as I only need them two.

Problem: When I do import '@nx-workspace/Package-A' inside Package-B and run build - I never get Package-A included in the Package-B dist folder. However, it works fine when I serve my project. The tsconfig.base.json is set up by nx with paths like so:

"@nx-workspace/Package-A": ["dist/packages/Package-A"],
      "@nx-workspace/Package-A/loader": [
        "dist/packages/Package-A/loader"
      ],
"@nx-workspace/Package-B": ["dist/packages/Package-B"],
"@@nx-workspace/Package-B/loader": [
        "dist/packages/Package-B/loader"
      ],

Question: How do I change the path to make sure when Package-B is built, it includes Package-A build files in Package-B dist folder? OR Is it supposed be in such way: You still npm i Package-A into Package-B and tsconfig.base just allows you to use local version of Package-A rather then npm one?

What I tried: I have followed NX and StencilJS docs to setup a blank stencil monorepo to play with it and try understand how it links things and builds dist. However, still no luck to include one component in the other component dist.

istepsv
  • 21
  • 4
  • I don't know anything about NX but with Stencil you usually import the whole package (not individual components) and let Stencil's compiler do the tree-shaking, see https://stackoverflow.com/a/66137851/1242317 – Thomas Nov 08 '22 at 15:52
  • @Thomas Sorry, I wrote it wrong. It is two separate packages. Edited the question accordingly. I thought that because it is a monorepo - I would not have to npm i another package inside a package but rather specify a path to it? – istepsv Nov 08 '22 at 16:03

0 Answers0