sample-monorepo icon indicating copy to clipboard operation
sample-monorepo copied to clipboard

Is it required to run a full monorepo build before test?

Open cmdcolin opened this issue 3 years ago • 2 comments
trafficstars

Hi there, I am browsing around looking for monorepo templates and this one looked great

However, I am curious: is it required to run a full monorepo build to perform a test? On a large codebase, this could be a pain point, but I am not sure if there is a workaround because I ran into trying to make our own monorepo....

In non-monorepo setups, it seemed like it was fine to test without building first, but because there are inter-dependencies in the monorepo, it expects those to be built.

Just curious if you had thoughts on this

cmdcolin avatar Apr 03 '22 15:04 cmdcolin

In this current setup, the answer tends to be yes.

These days, I find that using the actual .js files that are going to be consumed by others (via npm package) is preferable to trying to remap own tooling directly to sources (previous iterations of this monorepo did just that).

Now, that doesn't mean you can't just execute npx tsc --build src when inside the app package, which will only build app and components (meaning the package itself, and packages it depends on). This allows executing app's test separately, while knowing the dependencies got built.

This gets trickier when other processes (like bundling) use the output of typescript, so doing this only takes care of the typescript end. An example to that is the server that assumes app will be already bundled, ready to be served.

We discussed the concept of automated partial testing within my team, but more work has to be done to make such flow a reality.

AviVahl avatar Apr 04 '22 21:04 AviVahl

I would like to add here one more thing You usually only pay the "full build" once in dev when there is no existing dist, other times you only build what you have changed.

barak007 avatar Apr 07 '22 23:04 barak007