Open PatrikLythell opened 9 years ago
Not sure what you mean by couldn't pass plugins in to the sigh proc.pool module
, maybe you mean you couldn't pass in modules/etc. from the surounding scope? This could be because the function within a proc-pool instance is not a closure. You can pass data into this function using the second argument to prepare
but of course this must be serialised, then deserialised by the subprocess. If you need access to node modules within the subprocess function then you can require the module at the top of the function:
Check https://github.com/ohjames/process-pool/tree/master and grep for "global is not available within the call to prepare".
Ah I see you mean postcss plugins, sorry for the confusion ;) Yeah you'd need to pass the string name of the plugin, rather than the actual plugin. Data passed between the processes has to be serialised/deserialised and it's not possible to serialise a whole js module.
So rather than:
postcss( [require('postcss-simple-vars')] ), // add plugins as array
You'd need to do:
postcss(['postcss-simple-vars']), // add plugins as array
Then the subprocess can do the requiring based on the plugin name.
Thanks for the solution! Yes, the problem was passing a full module as parameter in to the proc pool instance.
The pocss(['postcss-simple-vars])
is definitely an option. All though it requires the user to be very informed on how this plugin accepts extra plugins on top. And for them to be very careful about naming passed in variabled and their package.json (all though sigh already relies on this a bit).
Until sigh explodes with crazy popularity you have the advantage of its creator providing you personal support for free ;) To make up for the lack of a community to rely on... Even though sigh is technologically superior to these projects, there's still no guarantee it'll get mass adoption though ;)
Tried it out but couldn't pass plugins in to the sigh proc.pool module.
Not worth it if not working with plugins as having one sigh-plugin for each postcss plugin is just ridiculous.