sortablejs-vue3 icon indicating copy to clipboard operation
sortablejs-vue3 copied to clipboard

typeError: t is not a constructor

Open volodymyr-pictime opened this issue 2 years ago • 1 comments

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?

volodymyr-pictime avatar May 31 '23 09:05 volodymyr-pictime

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',
    ...
  }
}

zofoklecja avatar Jul 19 '23 14:07 zofoklecja