The externals and globals options in Rollup only work for UMD and IIFE output formats and are only applied during build, so in HMR mode (kirbyup serve), Vue is not externalized and plugins still try to import their own copy. (which is causing issues)
To fix this, we can use rollup-plugin-external-globals, the same plugin Kirby is using, to externalize Vue consistently – in serve mode, too.
Kirby 3.9.5 makes Vue accessible globally via
window.Vue
, so the Kirby Panel and plugins built withkirbyup
can now share and access the same copy ofvue
. This is a requirement for Vue 2.7 functionality like dynamic CSS variables and<script setup>
(https://github.com/getkirby/kirby/issues/4735), for usage of Vue Dev Tools (https://github.com/getkirby/kirby/issues/4796) and also allows usage of dependencies thatimport { X } from 'vue'
within plugins built withkirbyup
(https://github.com/johannschopplich/kirbyup/issues/24).The
externals
andglobals
options in Rollup only work for UMD and IIFE output formats and are only applied during build, so in HMR mode (kirbyup serve
), Vue is not externalized and plugins still try to import their own copy. (which is causing issues) To fix this, we can userollup-plugin-external-globals
, the same plugin Kirby is using, to externalize Vue consistently – in serve mode, too.