I'm curious if we're open to using webpack in the Popups extension. While reviewing https://gerrit.wikimedia.org/r/#/c/333320/2 I felt that it's a shame we use mw.popup in so many places and now have so many JS files listed in a ResourceLoader module. Using webpack would make development much easier and nicer.
It also seems like it may help with our use of Mustache templates - we could compile these rather than pull in the Mustache library and the templates (note currently Wikipedia doesn't load Mustache on pageload which would happen once Popups goes live).
Benefits:
- Reduce need for mw.popup global
- require files rather than rely on RL
- expected optimisations to size of code
- Fix T147306
Cons
- adds a compilation phase:
Suggested switchover strategy
- Create folder build_resources with folder ext.popups
- Generate ext.popups/reducers using bundler generated from build_resources that assumes mw.popups global and assigns to mw.popups.reducers (ext.popups script RL definition should now be one file for reducers.js)
- Generate changeListeners using bundler generated from build_resources that assumes mw.popups global and assigns to mw.popups.changeListeners (ext.popups script RL definition should now be one file for changeListeners.js)
- Generate preview and top level JS so that it is bundled from build_resources (ext.popups RL script definition should now be one file)
- Add developer documentation
- Add CI check so that built assets have to be up to date
- Get rid of IIFEs
- Migrate QUnit unit browser tests to run in qunit node with common JS and remove the exposed keys on the global object
- Use webpack 2 instead of the outdated v1
De-scoped
See T160059: Popups technical improvements related to frontend assets
-
Precompile templates -
Use uglifyJS on bundling -
Improve bundled-assets-in-repo workflow