aurelia / bundler

A library for bundling JavaScript, HTML and CSS for use with SystemJS.
MIT License
37 stars 25 forks source link

Module definition with module-id not working #142

Closed gp-slick-coder closed 8 years ago

gp-slick-coder commented 8 years ago

I'm submitting a bug report

The application without bundling works fine. But after bundling I get an autoComplete is not defined error.

// code from the bundle
(function() {
  if (typeof define === 'function' && define.amd)
    define("github:gbreeze/JavaScript-autoComplete@master/auto-complete.js", [], function() {
      return window.autoComplete = autoComplete;
    }) && define("autoComplete", ["github:gbreeze/JavaScript-autoComplete@master/auto-complete.js"], function(m) {
      return m;
    });
   ...
})();

I think the problem is, that the first define function do return an undefined and so the second define function is not executed. If I change the code by removing this second define function in the bundle like following, everything works fine:

(function() {
  if (typeof define === 'function' && define.amd)
    define("autoComplete", [], function() {
      return autoComplete;
    });
    ...
})();

Here is the original module definition:

(function () {
    if (typeof define === 'function' && define.amd)
        define('autoComplete', function () { return autoComplete; });
    else if (typeof module !== 'undefined' && module.exports)
        module.exports = autoComplete;
    else
        window.autoComplete = autoComplete;
})();

If I search in my bundle for "&& define(" and set breakpoints, none of this second define functions are executed.

So who is manipulating the original module definition code on bundling and how to change/disable it?

Thanks


Please tell us about your environment:

gp-slick-coder commented 8 years ago

Adding a shim to the package.json solves this issue ;-) https://github.com/jspm/registry/wiki/Configuring-Packages-for-jspm#shim-configuration