I'm trying to use the Typescript compiler and the outFile function to bundle my sources into a single file and load that as normal with systemjs.
When I run the tsc
command I get a nice bundle.js
, which includes my main
code. When I load it in the browser (either apache or lite server) the bundle.js
gets loaded first as intended and then systemjs kicks in and starts loading all the .js files separately -- main.js, app.component.js, etc etc. There's no errors -- it simply works, but it shouldn't need to load all the seperate .js files..
I've looked hard at a related post (Load combined modular typescript file with SystemJS) but can't seem to find what I'm doing wrong..
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 using typescript 1.8.9