Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Param with name "module" can break packages in browser tests #32

Open
johnmdonahue opened this issue Mar 27, 2012 · 0 comments
Open

Param with name "module" can break packages in browser tests #32

johnmdonahue opened this issue Mar 27, 2012 · 0 comments

Comments

@johnmdonahue
Copy link

Hey man. Loving foounit so far!

I just wanted to let you know an issue I ran into working to add foounit browser tests to EpicEditor - which relies on Marked.

Seems like passing a param with the name module will break packages that rely on that keyword to check environment. More and more packages are doing things like this to try to be flexible enough to run in multiple contexts. In this case, it looks like Marked is added to the incorrect - or at least different/unexpected - scope.

Example:

(function(){
  if (typeof module !== 'undefined') {
    module.exports = marked;
  } else {
    this.marked = marked;
  }
}).call(this);

(function (window, undefined) {
  // Some other module
})(window);

foounit-browser.js

this.require = function (path){
    var code = get(path)
      , module = { exports: {} }
      , funcString = '(function (foounit, module, exports, __dirname, __filename){' + code + '});';

    try {
      var func = leval(funcString, path);
      func.call({}, foounit, module, module.exports, dirname(path), basename(path));
    } catch (e){
      console.error('Failed to load path: ' + path + ': ' + e.message, e);
    }

    return module.exports;
  };

I couldn't see where this was being used so I just removed references to module and exports as a temporary fix.

Let me know if I am missing something here. Maybe there is another way to wrap the code so that it doesn't cause conflicts, or maybe we should be setting up differently on our end?

Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant