webjars / jquery-file-upload

1 stars 5 forks source link

Cannot load module: jquery.ui.widget.js 404 (Not Found) #1

Open mariussoutier opened 11 years ago

mariussoutier commented 11 years ago

Hi,

I'm trying to use jQuery-File-Upload from WebJars & RequireJS. Problem is, no matter what I do, RequireJS tries to load an additional jquery.ui.widget.js (from the same folder where my main.js is), even though the file-upload WebJar already defines this as a dependency.

I also tried to manage this dependency explicitly:

requirejs.config({
  shim: {
    "webjars!jquery.ui.widget.js" : ["webjars!jquery.js"],
    "webjars!angular.js" : ["webjars!jquery.js"],
    "webjars!jquery.fileupload.js": ["webjars!jquery.js", "webjars!jquery.ui.widget.js"]
  },
  priority: ["webjars!jquery.js", "webjars!jquery.ui.widget.js"]
});

But the error doesn't go away, and file-upload fails to load. Do you have any clue how to solve this?

Thanks

mariussoutier commented 11 years ago

Ok, there seems to be an implicit requirement, I have to define jquery.ui.widget as a module with the same name:

define("jquery.ui.widget", ["webjars!ui/jquery.ui.widget.js", "jQuery"], function(w, jQuery) {});

This basically works, however sometimes it's not loaded in the correct order (jquery.ui.widget loads before jQuery), and everything blows up...

jamesward commented 11 years ago

Looks like I need to add the jquery.ui.widget definition to: https://github.com/webjars/jquery-ui/blob/master/src/main/resources/webjars-requirejs.js

I think it should be:

requirejs.config({
    shim: {
        'jquery-ui': [ 'webjars!jquery.js' ],
        'jquery.ui.widget': [ 'webjars!jquery.js' ]
    }
});

That seem right?

mariussoutier commented 11 years ago

Yes, looking good. But there should be some way to also check the requirejs.config from the loaded JS file. Otherwise we will run into this issue again and again.

mariussoutier commented 11 years ago

Do you have by chance a working example of WebJars + fileupload + RequireJS? As soon as I try to use fileupload's submodules (e.g. jquery.fileupload-angular.js), I get stuck in dependency hell.

This error makes no sense to me, so I guess it's again some missing sub-dependency:

GET http://localhost:9000/webjars/jquery-file-upload/8.4.2/js/jquery.fileupload 404 (Not Found)
jamesward commented 11 years ago

Maybe @huntc can help since he is the WebJars + RequireJS guru.