matt-gadd / umd-compat-loader

Apache License 2.0
8 stars 3 forks source link

Loader breaks with `export =` #5

Open nicknisi opened 7 years ago

nicknisi commented 7 years ago

Given a TS module like the following:

export = {
    foo: true,
    bar: 'baz'
};

With the following UMD 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"], factory);
    }
})(function (require, exports) {
    "use strict";
    return {
        foo: true,
        bar: 'baz'
    };
});

The loader outputs the following (a top-level return statement):

"use strict";
return {
    foo: true,
    bar: 'baz'
};

Ideally, this should output:

"use strict";
exports = {
    foo: true,
    bar: 'baz'
};