Page MenuHomePhabricator

Treat @vue/composition-api as a peer dependency
Closed, ResolvedPublic

Description

I'm noticing two things related to our use of the Composition API plugin that may not be 100% correct now that we've started using it in some WVUI components.

  1. The package is listed as a devDependency in package.json
  2. Individual component files like Checkbox.vue have their own calls to Vue.use( VueCompositionAPI ).

I think the correct place to be installing plugins into the Vue prototype is on the consumer side (i.e. the relevant Vue instance in the feature or application that is using these components) – not in the component library itself. This is how we are handling other Vue plugins in MediaWiki currently (i18n plugin, for example).

Moving the Composition API plugin into peerDependencies would help to make this obvious to end-users of WVUI. Would we want to automatically install this plugin in the vue module supplied by ResourceLoader?

On a related note, we probably should not include any code from the Composition API plugin in the bundled library output; this means we'd want to "externalize" this dependency in Webpack (or Rollup if we eventually migrate to that). Rollup has a plugin to automatically externalize any peerDependencies, and Webpack may have something similar.

Event Timeline

Change 738470 had a related patch set uploaded (by Catrope; author: Catrope):

[wvui@master] build: Externalize the Vue composition API plugin

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

Change 739341 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/core@master] vue: Rename vue-composition-api module to @vue/composition-api

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

Change 739341 merged by jenkins-bot:

[mediawiki/core@master] vue: Rename vue-composition-api module to @vue/composition-api

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

Change 738470 merged by jenkins-bot:

[wvui@master] build: Externalize the Vue composition API plugin

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

Change 740293 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/core@master] Update WVUI to v0.3.3

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

Change 740293 merged by jenkins-bot:

[mediawiki/core@master] Update WVUI to v0.3.3

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

Catrope claimed this task.