2 const Vue = require( '../../lib/vue/vue.js' );
3 const errorLogger = require( './errorLogger.js' );
4 const i18n = require( './i18n.js' );
5 const teleportTarget = require( 'mediawiki.page.ready' ).teleportTarget;
8 * Additional functions and plugins added to the Vue object.
10 * For documentation on Vue's built-in functions, see
11 * {@link https://vuejs.org/api/ Vue's API reference}.
17 * Wrapper around {@link https://vuejs.org/api/application.html#createapp Vue.createApp} that
18 * adds the {@link module:vue#$i18n i18n plugin} and the error handler. These were added
19 * globally in Vue 2, but Vue 3 does not support global plugins.
21 * To ensure all Vue code has the i18n plugin and the error handler installed, use of
22 * `vue.createMwApp()` is recommended anywhere one would normally use `Vue.createApp()`.
25 * @param {...any} args
26 * @return {Object} Vue app instance
27 * @memberof module:vue
29 Vue.createMwApp = function ( ...args ) {
30 const app = Vue.createApp( ...args );
31 app.use( errorLogger );
33 app.provide( 'CdxTeleportTarget', teleportTarget );
34 // Includes all messages with `cdx-` prefix in languages/i18n/codex.
35 app.provide( 'CdxI18nFunction', mw.msg );
40 // HACK: the global build of Vue that we're using assumes that Vue is globally available
41 // in eval()ed code, because it expects var Vue = ...; to run in the global scope
42 // Satisfy that assumption