2

I'm adding this code to a Addon-SDK addon:

var {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
var {WebConsoleFrame} = devtools.require("devtools/webconsole/webconsole");

Although this works in a normal (old style) addon, with cfx run I get:

ModuleNotFoundError: unable to satisfy: require(devtools/webconsole/webconsole) from
(thefilename.js)

To clarify, I'm trying to add those 2 lines into here: https://github.com/DavidBruant/usefulStackTrace/blob/master/lib/trackStack.js

Is this not possible within the Addon SDK's restartless addon system?

NoBugs
  • 9,310
  • 13
  • 80
  • 146

1 Answers1

4

A quick-and-not-so-dirty workaround

var {WebConsoleFrame} = devtools["require"]("devtools/webconsole/webconsole");
paa
  • 5,048
  • 1
  • 18
  • 22
  • Wow! How did you know to do this? This works, although it should be exactly the same as my second line. Maybe `cfx` is over-checking things somehow? – NoBugs Feb 23 '14 at 22:29
  • It's not a matter of javascript. During the build process a python script checks the source code for `require`s. The regular expression used catches the dot notation. So using the bracket notation gives you a free pass. – paa Feb 23 '14 at 22:42
  • yeah, the cfx python script is being a little overzealous in its validation. Glad to see this work-around! – robcee Jun 25 '14 at 12:43