My project folder structure is the same as quick-start ToH https://angular.io/docs/ts/latest/tutorial/toh-pt1.html
So to separate .ts file and .js file, I added to the tsconfig.json with "outDir": "dist"
. tsc then compiled all the .js and .map files into the dist folder. So far so good. dist folder is parallel to app folder.
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"outDir": "dist",
"suppressImplicitAnyIndexErrors":true
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
Next I changed the system.import in index.html
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
},
services: {defaultExtension: 'js'}
}
});
//System.import('app/main')
System.import('./dist/app/main')
.then(null, console.error.bind(console));
</script>
Now after npm start, the browser gave me
system.src.js:1154 GET http://localhost:3000/dist/app/main 404 (Not Found)
How can I let system import function find the main.js?
The folder structure looks like this
root
|--app // all .ts files are here
|--dist
|--app // all .js and .map files are here