Subscribe on changes!

vue.runtime.global.min.js is not in a format that works with webpack using externals

avatar
Feb 8th 2022

Version

3.2.30

Reproduction link

stackoverflow.com

Steps to reproduce

Webpack, listing vue as an external library (loaded separately in the browser), produces a bundle that checks the module for __esModule (which is true on the Vue global build, as well as VueRouter, but not Vuex), but when this value is true it then expects default to be defined on the module, which is undefined.

What is expected?

import Vue from 'vue'; should work. Vue.default in the browser should return Vue, or Vue.__esModule should not be defined.

What is actually happening?

Vue.__esModule is true but Vue.default is undefined, so import Vue from 'vue'; returns undefined in my client code.


I am trying to load as much as possible from CDN; so I don't want to import Vue directly into my bundle. The current build forces me to write const Vue = window.Vue;.

avatar
Feb 9th 2022

import Vue from 'vue'; should work.

No. Vue 3 has no default export. You have to do named imports when using ES module syntax. that's regardless of the build version you are using - that's kind of the point.