Currently, postcss_binary expands into three targets:
//example:target.postcss_runner.runner_src: Generates the source file for the PostCSS runner, using Bazel template expansion to embed the plugin config
//example:target.postcss_runner: Defines the nodejs_binary for the PostCSS runner, with all required deps for the PostCSS config attached
We don't actually need to embed the plugin config into the PostCSS runner source file. Instead, we can have a single source file, which is fed the plugin config, that then eval()s the plugin arguments defined by the user inside their BUILD files.
(We'll still need to define a nodejs_binary for each postcss_binary instance, because the PostCSS plugins are dynamic. However, a followup optimisation could be allowing users to define a set of plugins used across multiple postcss_binary invocations, which would further cut down the number of nodejs_binary targets. A further optimisation would be to then make this nodejs_binary a worker i.e. #45)
In a large project, this could make a sizeable reduction in the number of targets and source files generated.
Currently,
postcss_binary
expands into three targets://example:target.postcss_runner.runner_src
: Generates the source file for the PostCSS runner, using Bazel template expansion to embed the plugin config//example:target.postcss_runner
: Defines thenodejs_binary
for the PostCSS runner, with all required deps for the PostCSS config attached//example:target
: Invokes//example:target.postcss_runner
We don't actually need to embed the plugin config into the PostCSS runner source file. Instead, we can have a single source file, which is fed the plugin config, that then
eval()
s the plugin arguments defined by the user inside their BUILD files.(We'll still need to define a
nodejs_binary
for eachpostcss_binary
instance, because the PostCSS plugins are dynamic. However, a followup optimisation could be allowing users to define a set of plugins used across multiplepostcss_binary
invocations, which would further cut down the number ofnodejs_binary
targets. A further optimisation would be to then make thisnodejs_binary
a worker i.e. #45)In a large project, this could make a sizeable reduction in the number of targets and source files generated.