-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: CLI command to upgrade an existing Webpack config #250
Comments
P.S. I know some frameworks out there get around this sort of thing by hiding the configuration file entirely… requiring you to override it with changes only when needed. I think that's a terrible idea. I think the Webpack config file should be completely accessible and out in the open for every project. All we need to do then is simply provide a way to upgrade it when necessary. |
I was just thinking about this yesterday evening. In my mind I was toying with the idea of a super-lightweight Webpacker that would orchestrate Webpack. But that's opening one hell of a can of worms :D. And your second comment has literally just covered what I was about to type! |
I guess we can use the v4 -> v5 upgrade as a guinea pig and depending on the complexity of the changes (if any) required, we could figure out how to build this tool? |
Ignore me. I forgot about improvement we make to the config without a major version upgrade 🤦 . Last comment for now I promise! |
No those are really great points actually. I must admit I'm totally ignorant as to what would need to be tweaked in order to support Webpack v5. For the purposes of this conversation, how do we handle upgrades of the default state of |
Thor's You can always ship an npm package like Webpacker for Rails does and then let users extend it. https://github.com/rails/webpacker/tree/master/package |
Ideally, we shouldn't have to change anything but I couldn't get the manifest plugin to work in v5 so I swapped it out (as described in #204). If we can figure out how to make the manifest plugin work then in theory no major changes should be required. The more I think about this though I'm starting to think we need some kind of proper versioning system for the config file. An npm package as @ParamagicDev suggested could well be a good way to go. Since the config file is essentially just a JavaScript object; I wonder if there'd be a way for us to create the baseline config in an npm package; then allow the user to add/override values in a "local" project config. Then at build time we merge the two and write out the final config file that's used for the build to disk. Could potentially get the best of both worlds in the sense that we can version the baseline config properly while still not really hiding the config from the developer. Am I overthinking this too much? |
Just tried something and it seems to work; so here's an idea:
This way we don't hide the config from the user; we don't have to publish and maintain an NPM package and we can easily roll out upgrades to users. What do you think? |
@ayushn21 i really like this method. By modifying it a user essentially is "forking" the base config and it's up to them to maintain it properly going forward. This also allows us to ship configs without having to maintain a full fledged NPM package. I also like the idea of not having to sift through source code to find what the configuration is actually doing. |
I think we're on the right track here. So we basically would remove |
We wouldn't be able to track the version of the config file independently in the monorepo though. Don't know if its a good idea to tie the version of the webpack config to bridgetown version? So yeah we'd remove the webpack config to its own repo or folder in the monorepo and possibly put an automation in there along with it. The CLI would fetch and run the automation which would download config file. Advantage of having the automation is that we can handle versioning errors a bit better. For eg: v2 of the config file needs webpack v5; but the user is still on webpack v4. Using the automation; we can detect the version mismatch and ask the user if they'd like to upgrade. One of my concerns with this approach though is it's yet another thing for the user to keep up to date in addition to |
About the config updates, I do think they should tagged alongside Bridgetown releases, unless we completely strip out all the Webpack-related code and put it in its own gem (like Webpacker). Which maybe is the ultimate answer, but I'm wary of the extra overhead in maintaining… |
That would significantly simplify matters for sure so yeah probably best to go this way as a first step. So if we put the config in a folder in If the file lives in |
I had an idea… What if we make Webpack itself a "bundled configuration"? That way we can run it by default on BTW, I wouldn't expect it to be run automatically when updating the Bridgetown gem version itself. I think the Webpack config should be updated in a manual step. |
Yes! I think that would the simplest and most user-friendly way to go about it. But at the risk of going full circle right back to the start of the discussion; I reckon we should have a bespoke CLI command for this, even if the implementation is simply triggering an automation. In my mind This way when we add more bundlers we can give each of them their own command and suite of sub-commands like To sum up, we implement this functionality as an automation script but create a little wrapper command to invoke it. Or am I over-engineering this? |
I think that all makes sense. Just about everything in Rails, for example, is a "generator" and/or a Rake task, but generally it's all triggered by |
So what's the best process to get from here to there? Also #247 is waiting in the wings, which feels like a good candidate to test our approach to letting people upgrade their configs once Bridgetown v0.20 rolls out. |
I reckon the first step would be to add a We can then use this property when executing the template for the webpack config. So this is how I'd implement this:
I can spend some time on this but it'll only be about 4-5 weeks from now after my current contract ends. It might be best that way so #247 can be merged and released and we can use any learnings from how people use that while building this out. |
I think we're in good shape now to work on this whenever you're free. Your proposal above sounds good to me. |
Implemented in #270 |
As we continue to make the Webpack configuration in Bridgetown better out of the box, it highlights the need to allow existing sites' configurations to be upgraded. I shouldn't have to spin up a new site, then do a diff between the new site configuration and an older site of mine to figure out what's changed. That's the computer's job! 😉
I'm not sure exactly what to call the command, but I think if it basically copied an existing configuration to a backup copy, saved a new configuration, and then provided a visual diff between the two, that would be ideal. Maybe we even do a more rigorous job of maintaining a changelog just for the Webpack configuration, and link to that for reference.
The text was updated successfully, but these errors were encountered: