Skip to content

Conversation

@xi
Copy link

@xi xi commented Sep 22, 2015

Typescript added support for generating UMD in 1.5. Unfortunately, their style does not yet work with the r.js optimizer.

I added a test case and tried to fix it. It works on my test data, but I feel like the implementation could be a lot more elegant.

I just submittet a CLA.

xi pushed a commit to liqd/adhocracy3 that referenced this pull request Sep 22, 2015
TypeScript UMD and the require.js optimizer do not yet play well with
each other. I submitted a fix at
requirejs/r.js#857. Until that fix is available,
here is a workaround in adhocracy.
@jrburke
Copy link
Member

jrburke commented Sep 22, 2015

Do you know if it is possible to just ask them to change their output? I have not tested it to confirm with the r.js optimizer, but I expect this will work and is slightly smaller than their current output:

(function (factory) {
    if (typeof module === 'object' && typeof module.exports === 'object') {
        var v = factory(require, exports); if (v !== undefined) module.exports = v;
    }
    else if (typeof define === 'function' && define.amd) {
        define(['require', 'exports', 'lib'], factory);
    }
})(function (require, exports) {
    var lib = require('lib');
});

@jrburke
Copy link
Member

jrburke commented Sep 22, 2015

Also, some standard umd patterns are here:
https://github.com/umdjs/umd

The reason to create some common patterns is to make it easier for tools to work together, so if one of those could not be used it would be good to know why in case something was missed in their construction. They seem to have worked out well over the years though.

@xi
Copy link
Author

xi commented Apr 2, 2016

Has been fixed on the Typescript side.

@xi xi closed this Apr 2, 2016
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

Successfully merging this pull request may close these issues.

2 participants