|
本帖最后由 hechengjin 于 2016-5-7 14:21 编辑
const { require } = Components.utils.import('resource://gre/modules/commonjs/toolkit/require.js', {})
thunderbird\modules\commonjs\toolkit\require.js
const { Loader: { Loader, Require, Module, main } } =
components.utils.import(rootURI + "toolkit/loader.js", {});
const loader = Loader({
id: "toolkit/require",
rootURI: rootURI,
isNative: true,
paths: {
"": rootURI,
"devtools/": "resource://gre/modules/devtools/"
}
});
\shell\WindowUtils.js
Object.defineProperty(window, 'require', {
get: function () {
const id = components.stack.caller.filename.toString()
if (!requires.has(id)) {
let newRequire = createRequire({
id: id,
window: window
})
requires.set(id, newRequire)
}
// console.log(`id: ${id}`)
return requires.get(id)
}
})
const { createRequire } = require('./RequireUtils.js')
return Loader.Require(loader, { id: options.id })
const { Loader, resolveURI } = require('toolkit/loader')
|
|