javascript - using requirejs within a firefox xul extension -


i use requirejs manage code within firefox xul plugin, , can't find modules.

i know xul doesn't play nice data-main attribute, have main.js script 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 calls script, , require function available within main.js, when run

require(['lib1'], function(lib1){     alert(lib1.val1); }) 

the alert never gets popped (lib1 in same directory main.js).

i have tried within , without setting baseurl as

require.config({     baseurl: "chrome://mypackage/content/" }) 

and not work either way.

does know how can require.js in right place modules?

addendum **

i added error handling function , error code returned

http://requirejs.org/docs/errors.html#timeout 

i have loaded test module normal web page successfully. seems confirm issue path configuration (it takes 15 second timeout before failing)

firebug seems have working requirejs version. more importantly, have far better mini-require.js not pollute shared global scope when used in overlays (if used correctly :p)

i suggest have @ these implementations , code using it.

proactive warning: please note, if add-on uses code defines lots of new properties on scope in overlays (window) either defining global functions or variables or implicitly declaring variables within functions, may interfere other code running in same scope (the browser code , other add-ons). besides, should want submit add-on addons.mozilla.org, reviewer might not give public status if add-on "pollutes" global scope/namespace in main overlay.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -