0

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?

Community
  • 1
  • 1
Andrei
  • 1,015
  • 1
  • 11
  • 19
  • This is most likely not related to your `tsconfig.json` but rather your SystemJS configuration. – martin Nov 05 '16 at 22:08
  • Maybe have a look at this question as well: http://stackoverflow.com/questions/35867660/build-angular2-html-and-typescript-to-a-single-file/35868706#35868706 – martin Nov 05 '16 at 22:09

0 Answers0