Closed es128 closed 11 years ago
@es128 maybe we can come up with more general solution for that? perhaps in brunch?
so, why does current behavior (errors) happen? we don’t mutate cfg in place
Honestly, I'm not sure if it's a problem here. You asked me to check for similar situations after the issue with uglify and this was the only similar one I found (+coffeelint).
In the uglify plugin, I'm pretty sure the error was being thrown from within uglify itself, so its internal code must have been trying to write to the config object that got passed in. I don't know if the same thing might come up in the linters, but I guess the point is that we need to be careful since we don't have that much control over what happens in the components.
As for a more general solution, here are some ideas (some could be combined):
freeze
. Plus, unless you make a separate clone for each plugin then they can impact each other.I suppose my overall suggestion would be for brunch to start looking for configKey
, and if present, clone the corresponding nested object to pass into the plugin.
Do plugins ever care about the overall brunch config object outside of their own settings? I guess just in case, the frozen config object could also be passed.
@es128 right, freeze
is done with purpose. You shouldn’t mutate config anywhere. If you do, then clone. I guess uglify did this internally so it was shitty. So we don’t need this change here I think.
All config is passed “just in case”. I think some plugins (bower-brunch) incorporate it.
Sounds good. We'll just keep it in mind in case a similar issue ever comes up again.
in case of freeze issues