-
Notifications
You must be signed in to change notification settings - Fork 195
Webpack 5 support #103
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
Webpack 5 support #103
Conversation
…t-webpack-dev-server setup
- use react-refresh plugin and loader - user react-refresh only on client config, not dev wrapper builds - update dynamic cdn plugin to exclude react externalization for development - update devServer config to use "hot" mode and remove google-apps-script-webpack-dev-server "before" settings
also update webpack to latest version 4
Thanks @kmalakoff, appreciate this. I've avoided updating to webpack 5 because of the dynamic-cdn-webpack-plugin issue and happy to see you've published a fork. That repo hasn't had activity in years so a bit doubtful it will get merged but curious to see. I've made some changes to the way hot module reloading works, and it should be more straightforward/modern, just haven't merged in yet. Can you try applying the changes in your PR to my branch at fix/update-webpack-dev-server (see PR #98) and seeing if hot refresh works with the new setup and webpack 5? |
I believe I also had issues with html-webpack-inline-source-plugin when trying to upgrade webpack. Is that why you switched to the other inline plugin? It didn't look like it had as much support... |
Good question! Choosing html-inline-script-webpack-plugin was mainly a "process of elimination" to find a plugin compatible with webpack 5. If there's a more common one out there with webpack 5 support, we can swap it in. html-webpack-inline-source-plugin doesn't support webpack 5 and hasn't been updated for 3 years:
Unfortunately, InlineChunkHtmlPlugin hasn't been updated for 2 years and so also doesn't support webpack 5. |
You can use https://github.com/KyLeoHC/inline-source-webpack-plugin with webpackv5. |
@kdar thank you for the tip. Based on npm downloads, it looks like html-inline-script-webpack-plugin is more popular than inline-source-webpack-plugin. Also, I tried out inline-source-webpack-plugin and it is expecting a non-standard signature to mark the replacement rather than a standard src attribute:
I wasn't able to get it to work quickly either ;-P |
@enuchi I just realized that you requested me to try updating fix/update-webpack-dev-server (PR #98) I tried it and I ran into the same issue with hot-update endpoints missing. See commit Also, something weird happened that I tried to chase down, but couldn't figure it out. In the generated code.js file, there was incorrectly generated code:
This had two invalid things: |
Hey @kmalakoff, think the server-side error is coming from changes to gas-webpack-plugin. I know @fossamagna made changes to that repo to support removing the "global" declarations but it doesn't seem to be working here. If I make the changes in this commit then the server-side works. As for the hot refresh, it isn't even working outside of the Google spreadsheet. If you try running |
@enuchi I've spent quite a few hours mainly looking on the server side as the {chunk}.hot-update.js route seems to be missing (404) rather than looking at the generated html files. Is there something that you are seeing that makes the broken hot reloading seem to be client side? |
Okay @kmalakoff got this to work locally. Looks like there is some issue with See 8fd64ce. Can you try this change locally and see if hot refresh works for you? |
Or like this: 5b18bed |
…bpack-inline-source-plugin
Hey @enuchi. I wasn't able to get your fixes working so I went back to the drawing board and ported html-webpack-inline-source-plugin to webpack 5 @effortlessmotion/html-webpack-inline-source-plugin. Here's a working version based on your fix/update-webpack-dev-server branch kmalakoff@dd7c1d4 I think it is should be super simple to merge in....just the webpack config and updated / new modules |
@enuchi I merged my changes into this branch based on your fix/update-webpack-dev-server branch. Hot reloading with webpack 5 works and I updated all the modules to the latest Let me know if you prefer a different approach to any of this |
Hey @kmalakoff, thanks again for this work on upgrading to webpack 5. Have not forgotten about this. Would like to go in this order:
Currently working on the first one. Hang tight, and will comment here hopefully soon when I have updates! Thanks again. |
Thank you for explaining your plan. It sounds solid. |
Here’s how I added cross-platform testing using a free travisci account to one of the webpack plug-ins: https://github.com/kmalakoff/html-webpack-inline-source-plugin/blob/master/.travis.yml |
Hi @kmalakoff, sorry it's taken a while to get back to this one. I finally got around to doing step 1 and 2. React-refresh and integration tests are now there. Any chance you are able to pull in the new changes? Also totally understand if you've moved on from this. I am also happy to take a look and try to pull in all the change but may need to pull your work onto a new branch/PR so I can edit. |
Hi @kmalakoff, I've pulled in your changes here into a new PR, #131, with some additional minor changes. I know you did a lot of work on this last year and not sure if you're still following along, but anyway, thanks for adding webpack 5 support for dynamic-cdn-webpack-plugin and html-webpack-inline-source-plugin. I've added integration tests to the repo with Github Actions that test the local development setup, and running them against a few versions of node and both mac/windows, so now have more confidence that the switch to webpack 5 works. Will merge the other PR in a bit and close this one. |
Looks like there were some issues with gas-webpack-plugin, and @fossamagna was able to publish a new version that fixed them (issue here). |
Closing -- #131 has been merged. |
I've been using your boilerplate and tried upgrading the dependencies to the latest version. Thank you for your amazing work!
I got it to work with webpack 5...almost. Hot module reloading isn't working, but after trying all the fixes and workarounds I could find and it still not working, I'm wondering if you want to try to get it to work? It's so close!
To upgrade to webpack 5, I needed to rewrite dynamic-cdn-webpack-plugin and published it under a new module @effortlessmotion/dynamic-cdn-webpack-plugin until the author accepts the pull request.