Closed cyrilwanner closed 6 years ago
Wouldn't it be better if plugin can itself declare the phase in which it needs to be loaded without putting additional burden on plugin users? May be if some plugins need to loaded in user context specific way then we can extend and put extra phases, but i guess most won't
Good idea, I'll make this optionally available for plugin developers.
But I think I'll still also make this available in the next.config.js
file if a plugin doesn't add support for it so users can still decide (or overwrite) the behavior. It's a nice-to-have feature as Next.js officially added support for phases.
yeah, especially given that there are no other ways to separate dev plugins from prod plugins causing even dev plugins to included in main dependencies of package.json. At the run-time, composition should be intelligent enough to ignore missing dev plugins deps, which might be used through conditional import.
Hi @prateekrastogi, version 2 of next-compose-plugins
just got released 🎉 It includes many improvements like phase specific plugins and/or configuration, additional information/possibilities for plugin developers and optional plugins (e.g. when they are only in the devDependencies
).
I would suggest you can check out the updated readme.
For the optional (dev) dependencies, you can take a look at the optional plugins section. Would this resolve the problems you had described? Or do you still have a use-case which would not be solved now?
Thanks again for your inputs and feel free to create new issues when you have more ideas or a problem with the newly introduced functionalities :)
@cyrilwanner Tried using the updated plugin in my projects and its working perfectly. Just a little clarification regarding optional plugin that some optional plugins may be dev dependencies, but do not necessarily need to be run in PHASE_DEVELOPMENT_SERVER . They may run in some other phases. For example, next-bundle-analyzer needs to be run in PHASE_PRODUCTION_BUILD, but will generally be preferred to included as dev dependency. So, may be removing "and so you only want to apply it during PHASE_DEVELOPMENT_SERVER" line from readme will help avoid confusion.
@prateekrastogi thank you for testing the updated plugin! You are right, that makes total sense, I'll remove this line from the readme.
Next 5.1 introduced phases in the
next.config.js
file so specific plugins can only get applied in a specific phase. We should also add support for it.I'm not sure about the api yet, maybe something like this:
Please comment if you have inputs or another idea :)