Closed mbgonicus closed 6 years ago
If you're using qooxdoo-compiler, you can add them to your Manifest.json, either in your application or in a contrib:
provides: { /* ... snip ... */ },
externalResources: {
script: [ "myapp/thirdparty.js" ],
css: [ "myapp/thirdparty.css" ]
}
This format is going to change slightly fairly soon because it does not support separating "build" from "source" compilation.
The generator has support for add-script
and add-css
keys, which are documented here: http://www.qooxdoo.org/5.0.2/pages/tool/generator/generator_config_ref.html
All right, thank you again!
I'm using qooxdoo-compiler and got it working. Small caveat: The files referenced in "externalResources" must be in the source/resource folder.
I think this should be documented somewhere and I'm willing to provide a pr for the docs. But if it's going to change soon, it's obviously better to wait...
ah yes, sorry I forgot about the resources bit :) !
@johnspackman what if I want to add a CDN based script?
ah - it won't work, but it should just accept a URL - reopening
If asset accepts the URL, I can make a PR for that.
Yes please 👍
Do you mean in Application.getAssetUris
Application.js? That should not return external URLs (it should only return the <library namespace>:<library uri>
style), just skip those paths that are external URLs. Then Target.js needs to handle URIs differently too.
Finally, app/loader-browser.tmpl.js will need probably need some work
There's another aspect I came across regarding external js files.
Let's say we got an application foo
that uses a qx contrib bar
. bar
has a js file bar/source/resource/bar/baz.js
that I want to load. I add the following lines to the Manifest of bar
:
"externalResources" : {
"script": [ "bar/baz.js" ]
}
After compiling and loading in the browser, the browser tries to fetch ../resources/bar/baz.js
. But the file is available at ../resources/foo/js/baz.js
, leading to to the following change in bar/Manifest.json
:
"externalResources" : {
"script": [ "foo/js/baz.js" ]
}
Thus, I must use the application's name space in a contrib when it provides a js file.
I guess this needs a bit of a revamp (thanks for the feedback 👍 )
This issue was moved to qooxdoo/qooxdoo-compiler#79
Hi, this is more a question than an issue.
What is the intended way to use a 3rd party library? So I got a single js file that exposes a global variable that I like to use somewhere in my qx code.
I know about the contribs, but that requires to create a Manifest.json for each library.
Then there is also qx.util.DynamicScriptLoader to load something at runtime, but that is asynchronous which must be respected by any code that uses the library.
So I am looking for an easy way to include external libraries at compile-time. Is there a way to do it?