angular-ui / ui-sortable

jQuery UI Sortable for AngularJS
http://angular-ui.github.io/ui-sortable/
MIT License
1.26k stars 444 forks source link

Use of angular-ui-sortable in es6 modules #561

Closed truedrug closed 5 years ago

truedrug commented 5 years ago

Hey,

I want to use angular-ui-sortable in es6 modules. Like so,

import angular from 'angular'; import uiSortable from 'angular-ui-sortable';

export default angular.module('abc', [uiSortable]);

Doing this, I am getting below error: Failed to instantiate module {} due to: Error: [ng:areq] Argument 'module' is not a function, got Object

I am using webpack to bundle packages. If I use it as export default angular.module('abc', ['ui.sortable']); , webpack will not bundle angular-ui-sortable package as a whole due to 'tree shaking'.

Please provide suggestions. I am not using webpack.config.js file directly, Its part of a scaffold, I am using.

TommyZJL commented 5 years ago

The reason you got those errors is you didnt import the module in a right way.

As you can see in the sourceCode. It does not export any es6 modules or something like that. Therefore, if you really want to use angular-ui-sortable module, what you can do here is

import 'angular-ui-sortable';

export angular.module('abc', ['ui.sortable']);

thgreasi commented 5 years ago

Thanks for answering this @TommyZJL