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.

vue-demi is incompatible with import * as vue from 'vue' statements.

See original GitHub issue

Describe the bug

When using @vueuse/core or any vue-demi based package, and a package that has a import * as Vue from 'vue' statement, There is a blocking error in the console:

isRef is not a function

I tracked it down to the pre-compilation of dependencies tends to disliking the use of import * as ... in multiple places.

I am going to look into narrowing down the problem and finding a solution. I will start working on a PR.

Reproduction

https://github.com/elevatebart/demi-star

  • clone this repo
  • install using yarn
  • run yarn dev
  • open the chrome console
  • see the js error

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: macOS 11.2.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 9.27 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.0 - /var/folders/_h/jmt847vj0l50c9r8gdc_hz8m0000gn/T/fnm-shell-3404715/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.11 - /var/folders/_h/jmt847vj0l50c9r8gdc_hz8m0000gn/T/fnm-shell-3404715/bin/npm
  Browsers:
    Chrome: 89.0.4389.114
    Firefox: 87.0
    Safari: 14.0.3
  npmPackages:
    @vitejs/plugin-vue: ^1.2.1 => 1.2.1 
    vite: ^2.1.5 => 2.1.5 

Used package manager: yarn

Logs

  vite:deps Crawling dependencies using entries:
  vite:deps   /Users/bart/Documents/exp/demi-star/index.html +0ms
  vite:resolve 0ms   /src/main.ts -> /Users/bart/Documents/exp/demi-star/src/main.ts +0ms
  vite:resolve 3ms   vue -> /Users/bart/Documents/exp/demi-star/node_modules/vue/dist/vue.runtime.esm-bundler.js +4ms
  vite:resolve 0ms   ./App.vue -> /Users/bart/Documents/exp/demi-star/src/App.vue +0ms
  vite:resolve 1ms   @vueuse/core -> /Users/bart/Documents/exp/demi-star/node_modules/@vueuse/core/dist/index.esm.js +3ms
  vite:resolve 1ms   local-import-star -> /Users/bart/Documents/exp/demi-star/node_modules/local-import-star/import-star.js +1ms
  vite:resolve 1ms   ./components/HelloWorld.vue -> /Users/bart/Documents/exp/demi-star/src/components/HelloWorld.vue +1ms
  vite:deps Scan completed in 37ms: {
  vue: '/Users/bart/Documents/exp/demi-star/node_modules/vue/dist/vue.runtime.esm-bundler.js',
  '@vueuse/core': '/Users/bart/Documents/exp/demi-star/node_modules/@vueuse/core/dist/index.esm.js',
  'local-import-star': '/Users/bart/Documents/exp/demi-star/node_modules/local-import-star/import-star.js'
} +17ms
Pre-bundling dependencies:
  vue
  @vueuse/core
  local-import-star
(this will be run only when your dependencies or config have changed)
  vite:resolve 0ms   @vue/runtime-dom -> null +0ms
  vite:resolve 1ms   @vue/runtime-dom -> /Users/bart/Documents/exp/demi-star/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0ms
  vite:resolve 0ms   @vue/runtime-core -> null +5ms
  vite:resolve 0ms   @vue/runtime-core -> /Users/bart/Documents/exp/demi-star/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +4ms
  vite:resolve 0ms   vue-demi -> null +1ms
  vite:resolve 0ms   vue-demi -> /Users/bart/Documents/exp/demi-star/node_modules/vue-demi/lib/index.esm.js +1ms
  vite:resolve 0ms   @vue/shared -> null +1ms
  vite:resolve 0ms   @vue/shared -> /Users/bart/Documents/exp/demi-star/node_modules/@vue/shared/dist/shared.esm-bundler.js +1ms
  vite:resolve 0ms   @vueuse/shared -> null +1ms
  vite:resolve 0ms   @vueuse/shared -> /Users/bart/Documents/exp/demi-star/node_modules/@vueuse/shared/dist/index.esm.js +1ms
  vite:resolve 0ms   vue-demi -> /Users/bart/Documents/exp/demi-star/node_modules/vue-demi/lib/index.esm.js +0ms
  vite:resolve 0ms   @vue/reactivity -> null +13ms
  vite:resolve 1ms   @vue/reactivity -> /Users/bart/Documents/exp/demi-star/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js +14ms
  vite:deps deps bundled in 47ms +0ms

Context

I found this while trying to use @vue/test-utils within vitejs in a project using @vueuse/core. It is a complicated issue and feels like an esbuild limitation but I hope to find a solution.


Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
elevatebartcommented, May 17, 2021

I do like the sound of that! I will check right away. This is released as part of 2.3.3 for those who wonder.

Thank you team.

cc @JessicaSachs, for chakra_ui

1reaction
underfincommented, May 16, 2021

This is fixed at esbuild. I think it can be closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue-demi - npm
Start using vue-demi in your project by running `npm i vue-demi`. There are 856 other projects in the npm registry using vue-demi.
Read more >
import vue from 'vue' error | The AI Search Engine You Control
When using @vueuse/core or any vue-demi based package, and a package that has a import * as Vue from 'vue' statement, There is...
Read more >
Single SPA + Vite - Cannot use import statement outside a ...
Regarding the MF itself, I have the following Vite config: import vue from '@vitejs/plugin-vue'; import { nodeResolve } from '@rollup/plugin- ...
Read more >
Vue with TSX - the perfect duo!? - Arek Nawo
Your JSX should be compatible with SFCs, and you shouldn't even have to use the components field for them to work! import HelloWorld...
Read more >
Build a universal Vue component library with Vue Demi
In Vue Demi, the isvue2 and isvue3 APIs allow users to apply version-specific logic when creating Vue libraries. For example: import { isVue2, ......
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