vueform / multiselect

Vue 3 multiselect component with single select, multiselect and tagging options (+Tailwind CSS support).
https://vueform.com
MIT License
805 stars 149 forks source link

Cannot use import statement outside a module #44

Closed jnarowski closed 3 years ago

jnarowski commented 3 years ago

Version

Description

I'm using Nuxt with the composition API and trying to get this plugin to work. When I try to load it, I get the above error: Cannot use import statement outside a module

Demo

Please use our JSFiddle template to reproduce the bug. Issues without working reproduction might be ignored.

Here's a gist of the file. Not doing anything special.

jnarowski commented 3 years ago

This is nuxtJS specific. If you want to add a NuxtJS example, here's how I fixed it:

in nuxt.config.js { src: '~/plugins/vue-stack-grid', mode: 'client' }

in plugins/multiselect.js

import Vue from 'vue'
import Multiselect from '@vueform/multiselect/dist/multiselect.vue2.js'
Vue.component('VMultiselect', Multiselect)

In the component

  <client-only>
    <v-multiselect v-model="value" :options="options" />
  </client-only>
jnarowski commented 3 years ago

This didn't end up working in Nuxt. I was getting errors about infinite loops so I had to try and find another plugin. I love what you did though with composition, it's so clean. Any interest in ensuring this works with Nuxt and Vue2?

adamberecz commented 3 years ago

I've created a section with Nuxt.js usage: https://github.com/vueform/multiselect#using-with-nuxtjs

It works on a fresh install with this setup. If it's still not ok on your end please share your nuxt.config.js.

adamberecz commented 3 years ago

Feel free to reopen if you still have issue with this.

jnarowski commented 3 years ago

It's still not working and this seems like the cleanest select plugin out there by far!

Here's my config: https://gist.github.com/jnarowski/a740922bba3d9d1127ae239530773eaa

jnarowski commented 3 years ago

I recreated with a fresh nuxt install.

Here's the code for it: https://drive.google.com/file/d/12_r3SknguGWhaqvb2zwFTobo44wwcq5l/view?usp=sharing

Codesandbox was having issues getting the right Nuxt up and running. I'd love to use this if we can figure out what's going on. Maybe in the rollup settings?

jnarowski commented 3 years ago

Can we re-open this or should I create a new issue since it's still there?.

stale[bot] commented 3 years ago

Hi 👋 this issue has been automatically marked as stale 📌 because it has not had recent activity 😴. It will be closed if no further activity occurs.

stale[bot] commented 3 years ago

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period.

PixsaOJ commented 3 years ago

Can we get this fixed?

IsraelOrtuno commented 3 years ago

I think this should be opened again, bug is still there, no way to make it work with nuxt

IsraelOrtuno commented 3 years ago

I made it work by adding this to the nuxt config:

  build: {
    transpile: [
      '@vueform/multiselect/dist/multiselect.vue2.js',
    ],
  },
PixsaOJ commented 3 years ago

I used Nuxt multiselect

Grawl commented 3 years ago

The same for Quasar Framework. To fix this error, I have to add @vue-form/multiselect to build/transpileDependencies in quasar.conf.js:

module.exports = configure(function (ctx) {
    return {
        // …
        build: {
            // …
            transpileDependencies: [
                '@vueform/multiselect'
            ],
            // …
        },
    // …
}

(Quasar v2 in my case)

sthuber90 commented 2 years ago

With vue-cli the recommendation seems to be to adjust the transformIgnorePatterns in your jest.config.js file.

module.exports = {
    // ...
    transformIgnorePatterns: ["/node_modules/(?!@vueform/multiselect)"],
}

This way testing the multiselect with testing-library/vue works.