gridster.js icon indicating copy to clipboard operation
gridster.js copied to clipboard

Problem with import library v7 (angular2)

Open Rambuto opened this issue 8 years ago • 9 comments

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.

Rambuto avatar Mar 14 '17 15:03 Rambuto

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/[email protected]/jquery.gridster.js": {
         "format": "amd"
       }
    }

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

dfeufel avatar Mar 16 '17 07:03 dfeufel

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

Rambuto avatar Mar 20 '17 16:03 Rambuto

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.

dsmorse avatar Mar 20 '17 16:03 dsmorse

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

  • require('./jquery.draggable.js')
  • require('./jquery.collision.js')
  • require('./jquery.coords.js')
  • require('./utils.js'))

Thank you

Rambuto avatar Mar 22 '17 14:03 Rambuto

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

dlangerenken avatar Mar 29 '17 16:03 dlangerenken

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

tipa avatar Apr 17 '17 08:04 tipa

same here

piernik avatar Apr 20 '17 13:04 piernik

I think have next solution:

  • need remove all import in file which in dist directory
  • need add to directory dist next files: jquery.draggable.js, jquery.collision.js, jquery.coords.js, utils.js
  • copy src folder from bitbucket and after do some sing: import 'assets/gridster/jquery.gridster.js'; (this forking for me, but bad solution)

Rambuto avatar Apr 23 '17 21:04 Rambuto

I have the same problem!

ranran-weiresearch avatar Apr 27 '17 07:04 ranran-weiresearch