Open cadorn opened 10 years ago
For version 1, we would need to take into consideration that the require call would be discovered by static analyzers in other environments, which would in turn fail to find the module. I know that Mr can be tricked but not sure about Browserify et al.
For version 2, does the addon-sdk still support overlays?
For version 1, we would need to take into consideration that the require call would be discovered by static analyzers in other environments, which would in turn fail to find the module. I know that Mr can be tricked but not sure about Browserify et al.
Yeah. Its unspecified ground. This is a common issue and requires a transformation/override step at some level.
For version 2, does the addon-sdk still support overlays?
No.
One solution that would make sense from my POV is to specify some annotation that can be put at the top of module files that specifies the expected globals and points to a spec for their implementation. Each environment can then map these common spec uris to their respective implementations and provide the requested globals to the module.
I think mozilla would accept such a solution into their loader as it can be secured.
I guess I am trying to arrive at a solution that is portable to other libraries. I can always put the one line into the top of q.js
using an automated patch; but that does not help the JS component ecosystem because its a common problem.
Wanted to ping in on this :) Any progress or new thoughts?
@cadorn What file did you add setTimeout
to? q.js is a dependency of another npm module and adding setTimeout just about everywhere within my codebase results in no improvement. :(
To get
q.js
working within mozilla addon-sdk I had to declaresetTimeout
:const { setTimeout } = require("sdk/timers");
The question is whether the above line should be run by
q.js
if the addon-sdk environment is detected; or; alternatively; add-on developers must configure/patch the default loader to makesetTimeout
available as a global.If we can reliably sniff the environment then I would vote for that. It would make the user experience nicer for add-on developers that wish to use stock
q.js
.