bazelbuild / rules_postcss

PostCSS rules for Bazel
Apache License 2.0
10 stars 13 forks source link

Refactor PostCSS plugin require() calls to the runner JS #46

Closed rzhw closed 3 years ago

rzhw commented 3 years ago

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.

rzhw commented 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

rzhw commented 3 years ago

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.

nex3 commented 3 years ago

Would it be possible to feed them as inputs through the postcss_run rule instead, as inputs that the runner can load at runtime?