Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can'not build with vue-select #390

Open
5 tasks done
mgbetegan opened this issue Dec 31, 2023 · 1 comment
Open
5 tasks done

Can'not build with vue-select #390

mgbetegan opened this issue Dec 31, 2023 · 1 comment

Comments

@mgbetegan
Copy link

Describe the bug

I'm currently facing a problem where I installed vue-select for my project and I'm unable to create the build when I run vite-ssg build it gives the following error bellow

Capture d’écran 2023-12-31 à 10 17 46

Reproduction

add vue-select in a vite project, when run the build with vite-ssg it thorws the error

System Info

/node_modules/vue-select/dist/vue-select.es.js:13
import { openBlock as a, createElementBlock as h, createElementVNode as u, resolveDirective as K, normalizeClass as A, renderSlot as r, normalizeProps as d, guardReactiveProps as c, Fragment as B, renderList as L, createTextVNode as v, toDisplayString as D, createBlock as b, resolveDynamicComponent as _, createCommentVNode as O, mergeProps as k, toHandlers as j, withDirectives as w, vShow as P, createVNode as $, Transition as R, withCtx as z, withModifiers as F } from "vue";
^^^^^^

SyntaxError: Cannot use import statement outside a module

Used Package Manager

yarn

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@JeffreyArts
Copy link

The issue is that vue-select is using methods that are not available in a nodeJS environment. In this case, the import method. A workaround I apply to these situations is to wrap the import statement in an if statement that checks for the window variable.

let vueSelect

if (typeof window !== "undefined") {
    (async () => {
        const vueSelect = await import("vue-select")
    })()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants