Skip to content

Merging namespaces optimization #16570

Closed
Closed
@blendsdk

Description

@blendsdk

I was wondering if typescript can/will merge classes in the same namespace when module format is set to amd and the results written in a single file?

Given tsconfig.json:

{
    "compilerOptions": {
        "module": "amd",
        "target": "es5",
        ........
        ........
        "outFile": "../../dist/js/app.js"
    },
    "files": [
           "Hammer.ts",
           "Saw.ts"
    ]
}

The generated code is:

var Utils;
(function (Utils) {
    var Hammer = (function () {
        function Hammer() {
        }
        return Hammer;
    }());
    Utils.Hammer = Hammer;
})(Utils || (Utils = {}));
(function (Utils) {
    var Saw = (function () {
        function Saw() {
        }
        return Saw;
    }());
    Utils.Saw = Saw;
})(Utils || (Utils = {}));

This could be merged to something like:

var Utils;
(function (Utils) {

    var Hammer = (function () {
        function Hammer() {
        }
        return Hammer;
    }());
    Utils.Hammer = Hammer;

    var Saw = (function () {
        function Saw() {
        }
        return Saw;
    }());
    Utils.Saw = Saw;
    
})(Utils || (Utils = {}));

In our case we have over 100 classes which makes the output considerably larger.

Is there a solution to this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions