question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vite: vue is undefined in runtime

See original GitHub issue

Environment


  • Operating System: Linux
  • Node Version: v16.15.1
  • Nuxt Version: 2.16.0-27720022.54e852f
  • Nitro Version: 0.5.4
  • Package Manager: npm@8.13.2
  • Builder: vite
  • User Config: bridge, build, buildModules, vuetify, serverHandlers, devServerHandlers
  • Runtime Modules: -
  • Build Modules: (), @nuxtjs/vuetify@1.12.3, @nuxt/bridge@0.10.1

Reproduction

https://github.com/AndreyYolkin/nuxt-vuetify-issue (better explained) https://github.com/AndreyYolkin/nuxtjs-vuetify (with @nuxtjs/vuetify)

Describe the bug

For some reasons files that use Vue import in undefined at runtime. I’ve got this problem trying to make vuetify 2 work with latest bridge versions. image

Additional context

No response

Logs

entry.mjs:100 TypeError: Cannot read properties of undefined (reading 'observable')
    at Vue.<anonymous> (index.ts:239:23)
    at Vue.on (vue.runtime.esm.js?v=6c5bc416:3655:16)
    at invokeWithErrorHandling (vue.runtime.esm.js?v=6c5bc416:3015:30)
    at Vue.$emit (vue.runtime.esm.js?v=6c5bc416:3714:17)
    at callHook$1 (vue.runtime.esm.js?v=6c5bc416:4033:12)
    at Vue._init (vue.runtime.esm.js?v=6c5bc416:5678:9)
    at new Vue (vue.runtime.esm.js?v=6c5bc416:5747:10)
    at mountApp (entry.mjs:737:16)

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
IlyaSemenovcommented, Nov 7, 2022

+1 on this. I traced this to default export being deliberately removed in esbuild’s __reExport.

Related issue: https://github.com/evanw/esbuild/issues/1737

I ended up with a bunch of pnpm patches:

  1. exporting { Vue } from vue itself
  2. importing { Vue } from 'vue' in the affected libraries
diff --git a/dist/vue.runtime.esm.js b/dist/vue.runtime.esm.js
index 1786d28198333ad006b15289e77790083e88594f..2d1e626ee4932bac121aaececf9edaa08acb729a 100644
--- a/dist/vue.runtime.esm.js
+++ b/dist/vue.runtime.esm.js
@@ -8782,4 +8782,5 @@ if (inBrowser) {
     }, 0);
 }
 
+export { Vue }
 export { EffectScope, computed, customRef, Vue as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref$1 as ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useListeners, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };
diff --git a/dist/vue.runtime.mjs b/dist/vue.runtime.mjs
index 83d889271bd477fe1506c030fd6b351cdf1fe99b..3b6ed86a7e52e8004934f927b3867aa2d313aee1 100644
--- a/dist/vue.runtime.mjs
+++ b/dist/vue.runtime.mjs
@@ -1,5 +1,6 @@
 import Vue from './vue.runtime.common.js'
 export default Vue
+export { Vue }
 
 // this should be kept in sync with src/v3/index.ts
 export const {

and then like:

diff --git a/dist/portal-vue.esm.js b/dist/portal-vue.esm.js
index 05e6c55723bc8f303569f8deb9dd2b186a9856a8..f69c765ea376cffc50f5e64fd0c04a28edda88d3 100644
--- a/dist/portal-vue.esm.js
+++ b/dist/portal-vue.esm.js
@@ -10,7 +10,7 @@
   * 
  */
 
-import Vue from 'vue';
+import { Vue } from 'vue';
 
 function _typeof(obj) {
   if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue 3 + Vite image URL becomes undefined after build
I encountered a bug where I dynamically generated a URL from props for image import in my Vue 3 component and it becomes...
Read more >
Configuring Vite
The value could be undefined for tools that don't have separate commands for the browser and SSR build, so use explicit comparison against...
Read more >
TypeScript with Composition API - Vue.js
This is called "runtime declaration", because the argument passed to defineProps() will ... inferred type: Ref<number | undefined> const n = ref<number>() ...
Read more >
vite uncaught referenceerror: require is not defined - You.com
There should never be require in source code when using Vite. It's ESM only. edit your app.js to import .vue files.
Read more >
[Vue 3 & Vite 2] Uncaught (in promise) TypeError: Cannot read ...
After a day of searching, I came close to understand that while 'loading' is true, the function won't return anything so it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found