I am using lerna and yarn workspaces in my monorepo. The package structure looks like this:
root
`--- packages
|--- pkg1
| |--- src
| | `--- index.ts
| `--- dist
| `--- index.js
`--- pkg2
|--- src
| `--- index.ts
`--- dist
`--- index.js
src
folder gets compiled intodist
folder.- From each package, I would like to publish only the
dist
folder so that the imports work without the need of amain
entry in package.json pointing inside thedist
folder. This is easy to do with lerna:lerna publish --contents dist
.
This works fine for external projects needing to use this repo, however it doesn't work within the repo itself. For example, if pkg2
, depends on pkg1
, it looks for pkg1's index.js file at pkg1/index.js
while in reality the compiled version is sitting under pkg1/dist/index.js
. How can I make this work?
P.S. I have seen this work in repositories like material-ui, but I can't explain how it works there!
outDir
to'./'
intsconfig.json
. This way the transpiled files are all dumped in the root folder and I can reference them without/dist/...
. – Laroche