-
Notifications
You must be signed in to change notification settings - Fork 430
Configure plugin order in config rather than rely on package.json order #1377
Comments
Agree. We should expose something like As for the locally-defined plugins, our goal here is to not introduce new APIs that duplicate current ones. Maybe there's a way of loading your local package while still using package.json |
Ok, manual ordering can make sense. Could you expand on locally defined plugins? If you mean you want your project to both contain a plugin and use that, I can't see any problems with that. {
"devDependencies": {
"my-super-plugin": "file:./my-super-plugin"
}
} |
Yeah, I'm currently using that npm mechanism, but if I'm editing the plugin I have to continually do an npm install to keep it up to date with the file system. I could also npm link it. However, defining a separate package, while trivial, seems a bit overkill when I could just use a locally defined (eg in brunch-config) class/object and inject it into the config. |
Well the use case we cover is editing your project and seeing the changes — not live-developing plugins. It does seem like a very niche one, and I'm not sure we want to complicate the internals and expose even more config for something that'll be barely used. cc @paulmillr? |
I think both the features presented in this issue would be very useful. Maybe something like this in the config?
|
❗ At the very least, the main documentation about plugins needs to state that plugins are executed in the order specified in (I found a mention of this here in the Brunch.io Guide, but it needs to be stated clearly in the main documentation on brunch.io.) This seems extremely unintuitive, and I don't think I've encountered any other situation where the order of dependencies in In addition, regarding the
As mentioned in this Stack Overflow answer: "You cannot and should not rely on the ordering of elements within a JSON object." For the benefit of people arriving here from a search engine:
I found this error was being generated by Esprima on this line in After investigating, I found the pipeline was using this array of compilers: After further investigation, I found the ordering of the compilers was originating in In my |
Hey @michaelhogg, thanks for such detailed post. After #1522 is merged, you can use plugins: {
order: [
'babel-brunch',
'javascript-brunch',
],
}, Also, I have added a note to Brunch docs on the website. We would love to hear more thoughts from you on how to improve Brunch in the future. Thank you. |
@shvaikalesh: Awesome, thank you so much! 😀 I'm really enjoying using Brunch, and I've made a few contributions to eslint-brunch. I'll definitely continue to share contributions/feedback where I think things can be improved. Many thanks to the whole Brunch team for building such a great tool! |
@michaelhogg After some thoughts and discussion, we've decided to eliminate the need of |
If anyone else has issues with package sorting (i.e. have some optimizers that depend on order and this blocks you from using |
Even if I strongly believe that depending on the order of Also, using The simplest solution here if you're adamantly against having an ordering variable may be to run plugins in the order they are defined in the |
@natecox we are going to add |
How are the plugin authors supposed to understand what their priority should be inside of my build process? I feel like it's a lot to ask of plugin developers, and invites another scenario where developers become blocked by a build step they don't have the power to control. |
@natecox we'll just use default order for most plugins; higher order for stuff like postcss-brunch. So postcss would be executed after sass compilation. What is your use case for the different plugin order? |
Taking the example of postcss and sass integration, there are basically two methods that you could use to join the two:
The second use case is valuable for people currently using Sass for their CSS solution, and PostCSS for optimizations such as auto-prefixing. However, both are valid use cases supported by PostCSS which Brunch itself should not be precluding. By mandating the order of operations you have chosen for the developer which technique they should be using, and this simply isn't a case where convention needs to win out over configuration. As a case example, the order you proposed above already negates my build preferences because there's no way that you could (or should need to) understand the specifics of it. This is only one example, and I can't imagine that there aren't currently more, or that more won't be created as the list of plugins increases. |
If it makes sense we can add the ability to switch order later. But, I don't understand — how can a postcss parser parse sass? |
@paulmillr see https://github.com/postcss/postcss-scss for relevent information |
Hello! I'm also experimenting the same issue. I'm using
I've tried to to move the "devDependencies": {
"elm-brunch": "^0.8.0",
"babel-brunch": "^6.0.6",
"brunch": "^2.10.9",
....
} Is there anything I can do to solve this? |
Currently (unless something I'm unaware of has changed), the only thing you can do is manually rearrange your Yes, this means that every time you install a new package with |
Hi @natecox, thanks for your response. Unfortunately that doesn't work. As you can see in the |
You may be able to throw The real solution here is, of course, for brunch to stop using |
@natecox thanks, I'll try that. It would be nice if it could use the current order set in the |
Hello @bigardone , Did you able to solve this. I am facing the same issue here. Thanks |
Same problem here. |
Same issue also, with Stylus and PostCSS. I understand the resistance to using |
@mikeprince13, I am not totally against PS: really appreciate all you guys commenting this issue and not creating other ones. |
@shvaikalesh Looking forward to that, just digging into brunch and though its advertised idea is to make plugins work OOB I'm now into the third day trying to get a simple static site setup work with some preprocessors without fancy modules or anything and it has been somewhat frustrating to be honest. Now I stumble over this thread and I suddenly understand why I got so many errors and wrong outputs...Keep up the efforts it's a nice little program! Hope this will appear in the documentation once published and just one side note: please make it very clear if ordering is from top to bottom or the other way round. I often find myself not reading clear instructions in some programs when this is critical and can vary. |
Has this been resolved? How do I set the execution order of my plugins, as of today? (Edit: meaning, outside of re-editing package.json after every npm install, which is rather painful) |
@polypus74 well, the website still indicates that |
Same. I have no particular attachment to brunch, it just happens to be the default phoenix framework builder. Having to think about whether my project is broken every time I |
@polypus74 I'm also invested into brunch because of Phoenix. I've spent enough time stuck on this particular issue that I've started dropping it and using Webpack instead at the start of every project. This thread has some decent resources for getting started swapping them out. |
I have just used Brunch for a few projects, but I started running into this more and more. Any news in which direction this might go? |
@brutus I haven't seen much development here since this issue opened. I know that Phoenix is in the process of switching from Brunch to Webpack 4 due to inactivity. That shouldn't be taken as proof that this project is "dead", just food for thought. |
I've been dealing with this issue recently too, trying to get // package.json
"scripts": {
"postinstall": "perl -0777pi -e 's/([^\\n]+\"babel-brunch\":.+?\\n)(.+\"coffee-script-brunch\":.+?\\n)/\\2\\1/s' package.json"
} It would obviously be much better to be able to configure this. |
Would love for this to get fixed. My current situation is the following: "terser-brunch": "^4.0.0",
"@nerevu/cachebust-brunch": "^0.4.2",
"gzip-brunch": "^1.3.0" These plugins must be in this specific order or else the build will fail. |
Is #489 related to this? Seems like Brunch supports Chained compilation. |
@reubano brunch supports chained compilation, yes |
@paulmillr so how can we use that feature to address this issue? |
you need to specify plugin order somewhere. Right now the only place is package.json. To be able to specify it in brunch-config, we need a pull request. |
@paulmillr can you provide a bit of guidance on that? E.g., is it as simple as resubmitting #1522, or does it require something more involved? Thanks! |
You will need to create a new brunch config entry called config.plugins.order. If it is specified, brunch should sort plugins in order written there. If not, fall back to current behavior |
|
It seems a bit fragile to have to rely on the order of declaration in package.json to determine the order that plugins are invoked in, given that npm --save reorders the dependencies alphabetically. I'm basing this on brunch-guide, and a cursory glance over the source code.
It would be nice if this could be overridden in config.
On another note, I'd quite like to be able to add locally-defined plugins without having them be a package in node_modules.
The text was updated successfully, but these errors were encountered: