Using URI inside a Firefox Add-on. #44

Closed
dtuite opened this Issue Aug 27, 2012 · 2 comments

Projects

None yet

2 participants

dtuite commented Aug 27, 2012

The Firefox extension environment uses CommonJS to require files. However, it isn't possible to use npm packages.

Basically that means that I have to place the src/uri.js file directly into my project and then require it like this:

// /lib/services/some_file.js

if (typeof exports !== 'undefined') {
  var URI = require('../uri');

  // Some tests to try and figure out wtf is going on..
  console.log("IS URI defined", typeof URI != 'undefined'); // true
  console.log("IS URI defined", URI instanceof Array);  // false
  console.log("IS URI defined", URI instanceof Function); // false
  console.log("IS URI defined", URI instanceof Object); // false 
  console.log("IS URI defined", URI.constructor == String); // false
  console.log("IS URI defined", URI.constructor == Number); // false 
  console.log("IS URI defined", URI.constructor == Boolean); // false
  console.log "IS URI defined", Object.prototype.toString.call(URI); // [object Object]
}


Whenever I try to use URI in the file (with ot without the new keyword) I get the following error:

TypeError: URI is not a function

Anyone got any idea what is going on? I'm using URI v1.7.1 and I've just upgraded from v1.5.0 which was working with this same setup.

Owner

Maybe change that dependency handling stuff to UMD

Owner

Issue resolved with v1.8.0

@rodneyrehm rodneyrehm closed this Nov 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment