Sortable is not a constructor

Iam using ‘jquery-sortablejs’

It worked fine in jspm but when i change my project to webpack it throwing below error

‘Sortable is not a constructor’

trying to resolve from long back. could any one help me out on this.


Added screen shot for your reference.

Thanks in advance!

1 Like

Sometimes, jQuery with its plugins in webpack could be a real hassle, especially when you are not familiar with webpack, or something wrong under the hood. I would suggest that for faster development time, move jQuery to global (from script tag usage), and later try to move it back to the bundle if needed.

For your scenario, it would mean something like this:

<script src="jquery"></script>
<script src="jquery-sortable"></script>

hassle free dev environment

Hi @bigopon,

im kind of late to frontend development (joined after when jQuery was the thing).
What´s wrong with importing 3rd-party libs anyway - besides global namespace and no treeshaking / importing only stuff one really needs.
Just curious…

Best

1 Like

There’s nothing wrong with jQuery at all. I was only suggesting an option to minimize the number of things to need to juggle at once to get the dev workflow smooth at first. If I remember correctly, jQuery supports UMD module format, which means you won’t leak jQuery into global, if the build is configured properly

Sorry, I meant to write “what´s wrong with importing via scripttag”?
Is it mainly because of the global, right?

Considering the “hassle-free” dev-option - i´ll definately give that a shot, when trying new things.
Thanks a lot!

1 Like