Closed stevenvachon closed 11 years ago
Hey @stevenvachon,
This is a known problem in IE (all versions). I'm surprised to see this in Safari. Have you checked other browsers, too?
Fwiw, there's a way to ensure failure detection in IE (and other browsers): use the !exports
option. If you know a global variable that is declared in the legacy js file, you can check for it:
curl(
[
// for instance, file declares `someGlobal.property`
"js!scripts/library.js!exports=someGlobal.property",
"css!stylesheets/style.css",
"text!templates/template.html",
// for instance, file declares `anotherGlobalThingy`
"js!scripts/library123.js!exports=anotherGlobalThingy"
]
).then(
function(){ console.log(arguments); },
function(){ console.log("ERROR"); } // never called
);
More info: https://github.com/cujojs/curl/wiki/js#exports-option
Maybe use this as a work-around while we investigate?
-- John
This may also be an issue with the file:// scheme instead of http://, have you tested using an http server?
Running it on http fixed it. Kind of a pain as I like to work local, but works. Is it possible to fix this?
Hey @stevenvachon,
It's up to the browser vendors. They place lots of restrictions on XHR and script injection, including access to the file: protocol. Afaik, there's not anything we can do about it. :(
Each browser handles the situation in different ways. Some block all file: script injections, some just fail to provide proper feedback. I guess that's why I didn't recognize the problem immediately.
This sounds like a documentation problem. I'll add some more obvious info about this and then close the issue.
Regards,
-- John
I added some notes to the README.
@stevenvachon There are many simple HTTP servers arround, but I use serv. npm install -g serv
. By default serv
will start an HTTP server in the current working directory and expose those files to localhost.
Thanks Scott. I forgot to mention that! We also include serv in cujojs/seed. That makes it super easy to create a cujojs app. npm install && npm start
Done!
Thanks guys!
I combined curl with the plugins: css, j, text
Here is the browser (Safari) error in the console:
Failed to load resource file://localhost/Users/user/Desktop/Test/scripts/library123.js