mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-20 03:01:01 +00:00
49df4b9572
Generate changeListeners via webpack We now use a build folder to build the JavaScript for our ResourceLoader modules. This is the first change in a line of changes. A source map is provided for debug support. Bug: T156333 Change-Id: I771843d1ddb4b50adedc3fa53b30c2f1d8a76acb
64 lines
2.1 KiB
Markdown
64 lines
2.1 KiB
Markdown
# 4. Use webpack
|
|
|
|
Date: 02/02/2017
|
|
|
|
## Status
|
|
|
|
Accepted
|
|
|
|
## Context
|
|
|
|
Discussed by entire team, but predominately Sam Smith, Joaquin Hernandez and
|
|
Jon Robson.
|
|
|
|
As our JavaScript becomes more complex we are making it increasingly difficult
|
|
to maintain dependencies via extension.json. Dependencies and file order have
|
|
to be managed and every new file creation requires an edit to extension.json.
|
|
This slows down development. In Vagrant for instance NTFS file systems
|
|
experience slowdown when loading many files.
|
|
|
|
There are many tools that bundle JavaScript out there that can do this for us.
|
|
|
|
** Pros **
|
|
* mw.popups no longer needs to be exposed as a global object
|
|
* Dependency management is no longer a manual process but automated by webpack
|
|
* Would allow us to explore template pre-compiling
|
|
* More reliable debug via source map support
|
|
* For non-MediaWiki developers it should be easier to understand our
|
|
development workflow.
|
|
|
|
**Cons**
|
|
* There is now a build step. New developers to the extension may try to
|
|
directly edit the distribution files.
|
|
* Likely to be more merge conflicts, but this could be addressed by additional
|
|
tooling (e.g. post-merge build step)
|
|
|
|
## Decision
|
|
|
|
There are various bundlers to choose from, but Webpack was chosen on the basis
|
|
that
|
|
1) It was easy to switch to another
|
|
2) It is popular and well maintained.
|
|
3) Many members of the team are familiar with it.
|
|
|
|
https://medium.com/@tomchentw/why-webpack-is-awesome-9691044b6b8e#.mi0mmz75y
|
|
provides a good write up.
|
|
|
|
## Consequences
|
|
|
|
While we migrate directory structure is likely to go through a series of
|
|
changes. Specifically template loading is likely to change in future.
|
|
|
|
New JavaScript files should import and export other files via commonjs and
|
|
not rely on global variables.
|
|
|
|
extension.json still needs to be updated to point to modules in MediaWiki
|
|
core.
|
|
|
|
Care should be taken when including node module libraries to ensure they
|
|
are not loaded by other extensions.
|
|
|
|
Developers working on the repository are now required to run `npm run build`
|
|
in a pre-commit hook to ensure that the right JavaScript is sent to users.
|
|
|