dsmorse / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://dsmorse.github.io/gridster.js/
MIT License
796 stars 195 forks source link

Problem with import library v7 (angular2) #86

Open Rambuto opened 7 years ago

Rambuto commented 7 years ago

Hi, i have problem when try import library like this import 'dsmorse-gridster/dist/jquery.gridster.min.js' In console i have next error:

Can't resolve './jquery.coords.js'
Can't resolve './utils.js'
Can't resolve './jquery.collision.js'
Can't resolve './jquery.draggable.js'

Problem have because in code have part which try add library if current library was imported.

In library part this is next code if (typeof exports === 'object') { module.exports = factory(require('jquery'), require('./jquery.draggable.js'), require('./jquery.collision.js'), require('./jquery.coords.js'), require('./utils.js')); } Can you fixe it please. This urgent for me :) Thks And sorry for my bad english.

dfeufel commented 7 years ago

Since you are using angular2 I assume you are loading the script via SystemJS. SystemJS detects the library to be in commonjs format. But the imports for that format seem to be broken. To workaround you can force SystemJS to load the script in amd format:

    meta: {
       "jspm_packages/npm/dsmorse-gridster@0.7.0/jquery.gridster.js": {
         "format": "amd"
       }
    }

That worked for me, but the imports for commonjs should be fixed nevertheless.

Rambuto commented 7 years ago

My problem what I using webpack and this import don't working for me :(

dsmorse commented 7 years ago

If you have a code change I'd be happy to accept it, but for the record, there are VERY good (if not better) angular versions of this library. I'd recommend leveraging one of those directly.

Rambuto commented 7 years ago

I find solution. I copy folder src from github to my project. But this very bad solution. And i want ask you add to npm folder src with all file which you use for library Because all project based on ES6/typescript will try import library which not exist in dist folder.

This list import which code can't find

Thank you

dlangerenken commented 7 years ago

utils.js and other files are indeed not included in the npm install.

tipa commented 7 years ago

Same issue here (Typescript, SystemJS), any plans to resolve this?

piernik commented 7 years ago

same here

Rambuto commented 7 years ago

I think have next solution:

ranran-weiresearch commented 7 years ago

I have the same problem!