Monday, 26 August 2013

using requirejs within a firefox xul extension

using requirejs within a firefox xul extension

I would like to use requirejs to manage my code within a firefox xul
plugin, and I can't get it to find my modules.
I know that xul doesn't play nice with the data-main attribute, so I have
my main.js script as a second script:
<script src="chrome://myPackage/content/require.js"
type="application/x-javascript"></script>
<script src="chrome://myPackage/content/main.js"
type="application/x-javascript"></script>
This successfully calls the script, and the require function is available
within main.js, but when I run
require(['lib1'], function(lib1){
alert(lib1.val1);
})
the alert never gets popped (lib1 is in the same directory as main.js).
I have tried this within and without setting the baseUrl as
require.config({
baseUrl: "chrome://myPackage/content/"
})
and it does not work either way.
Does anyone know how I can get require.js to look in the right place for
my modules?

No comments:

Post a Comment