I'm following instructions here: A simple way to bundle an Angular 2 application and in this SO question: Including Concatenated Typescript JS outFile - Angular 2 + Typescript
I set up my tsconfig.json as follows:
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "system",
//"outDir": "../wwwroot/",
"outFile": "../wwwroot/dist/app.js",
"noEmitOnError": false,
"noImplicitAny": false,
"removeComments": true,
"sourceMap": true,
"target": "es5",
"moduleResolution": "node",
"suppressImplicitAnyIndexErrors": true,
"forceConsistentCasingInFileNames": false
},
"exclude": [
"../node_modules",
"../wwwroot"
]
}
This compiles seemingly without issues and produces dist/app.js
as expected. Inside the file, I can see the line that begins with System.register("main", ...
so module main
should be registered.
My index.html has this:
<script src="dist/app.js"></script>
System.import('main')
.then(null, console.error.bind(console));
I can see that app.js
is being loaded by the browser, however all I get are 404 errors and exceptions from ZoneJS (Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:5000/main.js
) attempting to load "main.js".
If I don't do this
System.import('main')
.then(null, console.error.bind(console));
then there are no errors, but the application does not start.
Any ideas what to do from here?