fix: defer MediaManagerV2 Vue chunk until Vue CDN loads - #461
Merged
Conversation
Vue 3 SFC compilation imports from 'vue' at module eval time. admin.min.js is loaded on all admin pages before Asset::vue3(), so a static Vue import threw ReferenceError. Vue 2 never did because vue-loader 15 did not emit those top-level imports. Dynamically import the MMV2 SFCs only after window.Vue.createApp exists, and emit a stable admin.mediamanager-v2 async chunk + CSS. Co-authored-by: Pablo de la Peña <pablo@hellopablo.co.uk>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #460. Admin pages were throwing
ReferenceError: Can't find variable: Vuebecauseadmin.min.jsloads beforeAsset::vue3()’s CDN script.Vue 2 never hit this:
vue-loader15 did not emit top-levelfrom 'vue'imports. Vue 3 /vue-loader17 does, and withexternals: { vue: 'Vue' }that reads the global as soon as those modules evaluate.Fix
window.Vue.createApp, then dynamic-import the MMV2 SFCsadmin.mediamanager-v2.min.js+admin.mediamanager-v2.min.cssadmin.min.jsstays Vue-free at load time (still registers the plugin on every admin page)Test plan
Can't find variable: Vue