ojkelly / yarn.build

Build 🛠 and Bundle 📦 your local workspaces. Like Bazel, Buck, Pants and Please but for Yarn Berry. Build any language, mix javascript, typescript, golang and more in one polyglot repo. Ship your bundles to AWS Lambda, Docker, or any nodejs runtime.
https://yarn.BUILD
MIT License
325 stars 28 forks source link

Export fields seem to be not working #234

Closed timonmasberg closed 2 years ago

timonmasberg commented 2 years ago

Describe the bug When referencing a workspace that uses the package.json exports property, and I run yarn build (tsc), the imports cannot be resolved: Cannot find module 'modulewithexportfields' or its corresponding type declarations. When running tsc in the project, everything works as expected

To Reproduce Steps to reproduce the behavior:

  1. Create a yarn workspaces project
  2. Create 2 packages where 1 exports via the package json exports property and the other imports that export and has it as dependency
  3. run yarn build in the root

Expected behavior Everything should work the same way as you run the build command in the packages folder.

timonmasberg commented 2 years ago

Actually, it seems to be the build order, is there a way to explicitly set it?

zinserjan commented 2 years ago

Actually, it seems to be the build order, is there a way to explicitly set it?

Build order gets determined by dependencies or devDependencies in package.json. If you have any issues with the build order based on these dependencies, I think it will help to provide a repo for testing.

ojkelly commented 2 years ago

Yep that sounds like an issue with the build order.

There's an example in this repo you can reference. To define the build order declare your workspace dependencies as if they're an npm module, but instead of a version you can use "workspace:*".

https://github.com/ojkelly/yarn.build/blob/main/packages/examples/phrases/lorem-ipsum/package.json#L12