shershen08 / vue-masonry

💠 Vue.js directive for masonry blocks layouting ✅
MIT License
677 stars 81 forks source link

updating nextThink issue for vue 3 and vite #117

Closed tayfunerbilen closed 2 years ago

tayfunerbilen commented 3 years ago

When I tried using this plugin with vue 3 and vite, I got error because of nextThink.

If we change like this import Vue from 'vue' instead of this import { nextThink } from 'vue' and we update this nextThink() to this Vue.nextThink() it works fine without any error.

dimitarkolev commented 3 years ago

This is not the case nextTick is not global Vue method anymore. Its well written in the official Documentation. I believe that you are not using Vue 3 at all in your setup.

tayfunerbilen commented 3 years ago

This is not the case nextTick is not global Vue method anymore. Its well written in the official Documentation. I believe that you are not using Vue 3 at all in your setup.

I understand, but I'm using vue 3.2.2 with vite. And when I try to run I'm getting this error

(this will be run only when your dependencies or config have changed)
 > node_modules/vue-masonry/src/masonry-vue3.plugin.js:5:9: error: No matching export in "node_modules/vue-masonry/node_modules/vue/dist/vue.runtime.esm.js" for import "nextTick"
    5 │ import { nextTick } from 'vue';
      ╵          ~~~~~~~~

error when starting dev server:
Error: Build failed with 1 error:
node_modules/vue-masonry/src/masonry-vue3.plugin.js:5:9: error: No matching export in "node_modules/vue-masonry/node_modules/vue/dist/vue.runtime.esm.js" for import "nextTick"
    at failureErrorWithLog (/Users/macbook/Desktop/vue-project/node_modules/esbuild/lib/main.js:1449:15)
    at /Users/macbook/Desktop/vue-project/node_modules/esbuild/lib/main.js:1131:28
    at runOnEndCallbacks (/Users/macbook/Desktop/vue-project/node_modules/esbuild/lib/main.js:921:63)
    at buildResponseToResult (/Users/macbook/Desktop/vue-project/node_modules/esbuild/lib/main.js:1129:7)
    at /Users/macbook/Desktop/vue-project/node_modules/esbuild/lib/main.js:1236:14
    at /Users/macbook/Desktop/vue-project/node_modules/esbuild/lib/main.js:609:9
    at handleIncomingPacket (/Users/macbook/Desktop/vue-project/node_modules/esbuild/lib/main.js:706:9)
    at Socket.readFromStdout (/Users/macbook/Desktop/vue-project/node_modules/esbuild/lib/main.js:576:7)
    at Socket.emit (events.js:315:20)
    at Socket.EventEmitter.emit (domain.js:486:12)
error Command failed with exit code 1.

do you have any suggestion for this error? If I change these code to that I committed, it works.

shershen08 commented 2 years ago

i've created a composite file with vue-demi to be usable with both v2/v3 here #118 thanks for your input, closing this