In my TypeScript project, I am trying to concatenate the compiled output into a single file. I am using the SystemJs module, but I am facing an issue where the output changes when I include an 'import' statement in the script files. For example, if my source file looks like this:
export class SimpleGame{
constructor(){
console.log('simple game');
}
}
window.onload = function(){
var game = new SimpleGame();
}
The output is:
var SimpleGame = (function () {
function SimpleGame() {
console.log('simple game');
}
return SimpleGame;
}());
window.onload = function () {
var game = new SimpleGame();
};
However, if I add another file called logic.ts
and include the statement:
import { Logic } from './logic';
The output changes to:
System.register("logic", [], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var Logic;
return {
setters: [],
execute: function () {
Logic = (function () {
function Logic() {
}
return Logic;
}());
exports_1("Logic", Logic);
}
};
});
System.register("game", [], function (exports_2, context_2) {
"use strict";
var __moduleName = context_2 && context_2.id;
var SimpleGame;
return {
setters: [],
execute: function () {
SimpleGame = (function () {
function SimpleGame() {
console.log('simple game');
}
return SimpleGame;
}());
window.onload = function () {
var game = new SimpleGame();
};
}
};
});
//# sourceMappingURL=game.js.map
As a result, the code window.onload
will not execute. Does anyone have any suggestions on how to resolve this issue and ensure the code executes as intended?