Page MenuHomePhabricator

Make WVUI export compatible with ResourceLoader
Closed, ResolvedPublic

Description

T249658 posed the question of whether or not we should pre-compile the Vue.JS search app in the Vector skin. Although that initial conversation favoured precompiling, subsequent conversations have revealed that not compiling Vue.js is the more socially acceptable and perhaps technically simpler approach.

However, in order to use the WVUI library directly in ResourceLoader, without a build-step in Vector, changes need to be made to the WVUI webpack export:

  • In .wepack/config.js WVUI must export a bundle formatted as commonjs2, which appears to be the format most compatible with ResourceLoader’s CommonJS implementation.
  • The WVUI component exports (e.g. in Button.vue) must export a plain object, as opposed to one wrapped in Vue.extend() as they do currently. This was probably done for type-checking reasons, but not 100% sure, seems to work fine either way. Removing the Vue.js invocations from the components also removes the Vue.js runtime from the bundled output, allowing us to use the version of Vue.js bundled in MediaWiki. The externals flag in the Webpack config already does this job

These changes will allow us to use WVUI in ResourceLoader in the following way:

In skin.json

"wvui": {
    "PackageFiles": "resources/wvui/wvui.commonjs2.js", 
    "dependencies": [ "vue" ]
}

And then the actual usage of the library in Vector:

var wvui = require("wvui");
// -> {components: { Button: {} ...

We can still keep the default UMD formatted export as the default WVUI export, and make the CommonJS version an additional bundle.

Event Timeline

Change 642033 had a related patch set uploaded (by Jdrewniak; owner: Jdrewniak):
[wvui@master] Export a separate CommonJS bundle

https://gerrit.wikimedia.org/r/642033

Change 642033 merged by jenkins-bot:
[wvui@master] Export a separate CommonJS bundle

https://gerrit.wikimedia.org/r/642033

Change 644794 had a related patch set uploaded (by Phuedx; owner: Phuedx):
[wvui@master] [build] Disable minification for CommonJS bundle

https://gerrit.wikimedia.org/r/644794

Change 644794 merged by jenkins-bot:
[wvui@master] [build] Disable minification for CommonJS bundle

https://gerrit.wikimedia.org/r/644794