MaxLeiter / sortablejs-vue3

A thin wrapper around Sortable.js for Vue 3
https://sortablejs-vue3.maxleiter.com
MIT License
380 stars 21 forks source link

typeError: t is not a constructor #85

Open volodymyr-pictime opened 1 year ago

volodymyr-pictime commented 1 year ago

Hi.

I used @vue/cli-service version 4.5.9 and couldn't build project because this lib uses optional-chaining syntax. Babel loader with "@babel/plugin-proposal-optional-chaining" helped me, but I don't need extra loaders so decided to update @vue/cli-service and @vue/cli-plugin-typescript to "^5.0.8" and now I have such runtime error

image

any thoughts?

zofoklecja commented 1 year ago

I encountered the same issue.

The root cause is conflicting module formats. The t in error message is a minified name of SortableJS module. By default sortablejs-vue3 is shipped as UMD which will be confused by ES structure of sortablejs, where constructor is available under default property 2023-07-19_16h00_34

I was able to fix it by manually specifying ES output in Webpack alias configuration:

resolve: {
  alias: {
    'sortablejs-vue3': 'sortablejs-vue3/dist/sortable-vue3.es',
    ...
  }
}