firefox - How I can require script from data folder -
firefox - How I can require script from data folder -
i want load js file page , require in background page.
i seek utilize 2 re-create in lib , in info folder, have problem review.
i can load lib folder in page, uncomfortable other browsers.
i can load via loader:
mono = require('toolkit/loader').main(require('toolkit/loader').loader({ paths: { 'sdk/': 'resource://gre/modules/commonjs/sdk/', 'data/': self.data.url('js/'), '': 'resource:///modules/' }, name: self.name, prefixuri: 'resource://'+self.id.slice(1, -1)+'/' }), "data/mono");
but have problem with:
require('net/xhr').xmlhttprequest
i seek utilize options it, have same problems.
require('@loader/options')
now utilize it, require objects send via arguments.
have ideas?
upd utilize code, allow require modules , don't store in memory, think. need declare modules previously.
mono = require('toolkit/loader').main(require('toolkit/loader').loader({ paths: { 'data/': self.data.url('js/') }, name: self.name, prefixuri: 'resource://'+self.id.slice(1, -1)+'/', globals: { console: console, _require: function(path) { switch (path) { case 'sdk/timers': homecoming require('sdk/timers'); case 'sdk/simple-storage': homecoming require('sdk/simple-storage'); case 'sdk/window/utils': homecoming require('sdk/window/utils'); case 'sdk/self': homecoming require('sdk/self'); default: console.log('module not found!', path); } } } }), "data/mono");
i think blogpost erikvold addresses problem facing: http://work.erikvold.com/jetpack/2014/09/23/jp-pro-tip-reusing-js.html
firefox firefox-addon firefox-addon-sdk
Comments
Post a Comment