Utilizing the Typescript compiler and the outFile function, I am attempting to merge my sources into a single file and then load it as usual with systemjs.
After running the tsc
command, I receive a well-structured bundle.js
file containing my main
code. However, upon loading it in the browser (either apache or lite server), the bundle.js
is loaded first as expected. Then, systemjs takes over and begins loading all the .js files individually -- main.js, app.component.js, etc. Although there are no errors, this process works fine but ideally should not require loading the separate .js files.
I have extensively reviewed a similar post (Load combined modular typescript file with SystemJS) but cannot identify what mistake I might be making.
index.html
<!doctype html>
<html lang="en">
<head>
<base href="/">
<meta charset="UTF-8">
<title>Solid Timesheet: Time-tracking made easy!</title>
<link rel="stylesheet" href="css/main.css">
<script type="text/javascript">
// temporary hack for enable bootstrap 4
window.__theme = 'bs4';
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
var localhost = document.location.href.match(/^http:\/\/localhost/);
ga('create', 'UA-18982324-19', localhost ? 'none' : 'auto');
</script>
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.min.js"></script>
<script src="node_modules/systemjs/dist/system.js"></script>
<script src="node_modules/rxjs/bundles/Rx.min.js"></script>
<script src="node_modules/angular2/bundles/router.min.js"></script>
<script src="node_modules/angular2/bundles/http.min.js"></script>
<script src="node_modules/angular2/bundles/angular2.min.js"></script>
<script src="node_modules/ng2-bootstrap/bundles/ng2-bootstrap.min.js"></script>
<script src="bundle.js"></script>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
},
"ng2-bootstrap": {
"defaultExtension": "js"
},
},
map: {
'ng2-bootstrap': 'node_modules/ng2-bootstrap/bundles/',
moment: 'node_modules/moment/moment.js',
}
});
System.import('app/main')
.then(null, console.error.bind(console));
</script>
</head>
<!-- 3. Display the application -->
<body>
<div class="container">
<my-app>Loading...</my-app>
</div>
</body>
</html>
tsconfig.json
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"module": "system",
"removeComments": true,
"sourceMap": false,
"noImplicitAny": false,
"outFile": "bundle.js"
},
"exclude": [
"node_modules",
"typings"
]
}
I'm currently utilizing typescript version 1.8.9