SortableJS / Sortable

Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.
https://sortablejs.github.io/Sortable/
MIT License
29.58k stars 3.7k forks source link

Not compatible with angular-legacy-sortablejs when update form 1.9.0 to 1.10.0 #1728

Closed ChuckIsReady closed 4 years ago

ChuckIsReady commented 4 years ago

Problem:

in version 1.9.0, i use angular-legacy-sortablejs by setting this on index.js (with webpack)

require('angular-legacy-sortablejs-maintained/angular-legacy-sortable.js');

after i update to 1.10.0 there is a error on console:

TypeError: Sortable.create is not a function

image

Then i find 1.10.0 is completely reconstructed.

in 1.9.0 :


(function sortableModule(factory) {
    "use strict";

    if (typeof define === "function" && define.amd) {
        define(factory);
    }
    else if (typeof module != "undefined" && typeof module.exports != "undefined") {
        module.exports = factory();
    }
    else {
        /* jshint sub:true */
        window["Sortable"] = factory();
    }
})(...)

in 1.10.0 :

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  typeof define === 'function' && define.amd ? define(factory) :
  (global = global || self, global.Sortable = factory());
}(this, function (){...})

and angular-legacy-sortablejs get sortablejs by this way:

(function (factory) {
    'use strict';

    if (typeof define === 'function' && define.amd) {
        define(['angular', 'sortablejs'], factory);
    }
    else if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
        require('angular');
        factory(angular, require('sortablejs'));
        module.exports = 'ng-sortable';
    }
    else if (window.angular && window.Sortable) {
        factory(angular, Sortable);
    }
})(function (angular, Sortable) {...}

So can you think about adding some conditions so that sortablejs can continue to be used by angular-legacy-sortablejs

thank you !

owen-m1 commented 4 years ago

It's an issue with how angular-sortablejs imports it, which had to be solved in ngx-sortablejs. So you should open this issue in angular-sortablejs.

romain-gilliotte commented 4 years ago

IMO the issue is not how angular-sortablejs import it, but a semantic versionning bug on this module.

Since breaking changes were introduced, a new major version should have been issued, which would have prevented npm update from breaking all framework bindings which depend on this module.

(Nevertheless, this module is super convenient, thanks for the good work!)