Closed rzhw closed 3 years ago
😱 that's horrifying. But that's a great idea and I can't believe I haven't tried that earlier. JS never ceases to amaze
I'll give it a try, will be great if that reduction of targets can make meaningful impact at large scale
Thinking about this some more, I think eval() is a really good idea to avoid creating separate runner source files, which right now we do create targets for and so this absolutely can cut down on.
We'll still have to create separate runner nodejs_binary targets, because the node requires need to be known and fed to the nodejs_binary.
Would it be possible to feed them as inputs through the postcss_run
rule instead, as inputs that the runner can load at runtime?
Instead of generating the require() calls as a string in Starlark.
This minor refactor slightly reduces the templated JS, and clarifies how we get the plugins from Starlark into the runner.
A followup to this PR can be to log a useful warning message if the Node.js require failed.