Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of knockoutJS fails to properly register library #74

Open
purtuga opened this issue Dec 20, 2014 · 1 comment
Open

Handling of knockoutJS fails to properly register library #74

purtuga opened this issue Dec 20, 2014 · 1 comment

Comments

@purtuga
Copy link
Contributor

purtuga commented Dec 20, 2014

KnockoutJS has (I think) an unusual way to register its self under AMD... its code looks like this (ref here):

// Support three module loading scenarios
    if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
        // [1] CommonJS/Node.js
        var target = module['exports'] || exports; // module.exports is for Node.js
        factory(target, require);
    } else if (typeof define === 'function' && define['amd']) {
        // [2] AMD anonymous module
        define(['exports', 'require'], factory);
    } else {
        // [3] No module loader (plain <script> tag) - put directly in global namespace
        factory(window['ko'] = {});
    }

amdclean converts this to:

// Support three module loading scenarios
      if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
        // [1] CommonJS/Node.js
        var target = module['exports'] || exports;
        // module.exports is for Node.js
        factory(target, require);
      } else if (true) {
        knockout = function (exports, require) {
          return typeof factory === 'function' ? factory(exports, require) : factory;
        }({}, {});
      } else {
        // [3] No module loader (plain <script> tag) - put directly in global namespace
        factory(window['ko'] = {});
      }

This however, does not register the module because the knockoutjs factory does not return anything - it simply adds its methods to the exports provided on input

Anyway I can fix this during the build process? or get around it?

Thanks in advance.

/Paul.

@purtuga
Copy link
Contributor Author

purtuga commented Jan 24, 2015

Hi Greg, have you had a chance to look at this?

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

No branches or pull requests

1 participant