guybedford / chomp

'JS Make' - parallel task runner for the frontend ecosystem with a JS extension system.
https://chompbuild.com
Apache License 2.0
143 stars 7 forks source link

Wildcard targets #8

Closed guybedford closed 2 years ago

guybedford commented 2 years ago

Now that we have multiple target support, it should be possible to define wildcard targets the target an entire glob pattern. The pattern should have no conflicts or crossover with other targets. Then it can be fully iterated and built like any other target.

canadaduane commented 2 years ago

Do you have an example of how this would work, and how it is different from the # way of doing things? I'm not as familiar with Makefiles, so perhaps there is some domain knowledge missing for me here.

guybedford commented 2 years ago

@canadaduane the primary benefit of wildcard targets is where you have a tool that isn't invoked per file but is intead generating many files at once.

For example, tsc will compile a whole lib folder at once. It's target is thus lib/*.js, a wildcard target.

On the other hand, Babel can compile an individual file at once - babel in.js -o out.js. As such, Chomp can then take care of watching, invalidating and mtime checking instead of requiring the compiler to do that itself.

canadaduane commented 2 years ago

So tsc -w (watch mode) would be used in the wildcard target case? Or how does chomp know when to re-trigger it?

guybedford commented 2 years ago

Right so to support tsc, either use tsc -w as a long-running task, or have wildcard deps AND wildcard targets, then the full invocation will be retriggered automatically. Sharing the watcher internals are exactly the issue with why these approaches aren't ideal.

This is why I actually recommend swc for TypeScript as its the fastest and can be done per-file. I'm working on integrating the template for this now.

guybedford commented 2 years ago

And by wildcard dependencies I mean https://github.com/guybedford/chomp/issues/1.

guybedford commented 2 years ago

I'm going to close this for now, and instead reopen it if it becomes an issue in future.