I was just trying to create proof-of-concept TS + SystemJS project with minimum possible setup - without "Angular2 starter kit" and such. I've spent an hour googling and tweaking this setup but it still doesn't work.
I have the following setup:
/src/
- model.ts
- bootstrap.ts
/dist/
tsconfig.json
system.config.js
index.html
My tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"sourceMap": true,
"removeComments": false,
"outDir": "./dist/"
},
"filesGlob": [
"./src/**/*.ts"
],
"compileOnSave": true
}
My SystemJS config
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
map: {
testapp: './src'
},
baseURL: './src',
packages: {
testapp: {
format: 'register',
defaultExtension: 'js'
}
},
});
My index.html
<script src="/node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="/node_modules/systemjs/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('bootstrap.ts')
.then(function(app) {
console.log('app bootstrap success!');
}, console.error.bind(console));
</script>
In the end I have following error in console:
system.src.js:1051 GET http://0.0.0.0:8080/src/bootstrap.ts.js 404 (Not Found)fetchTextFromURL @ system.src.js:1051....
Error: (SystemJS) XHR error (404 Not Found) loading
I run tsc -w
in one terminal tab and simple https server in the other.
Apparently - SystemJS wants to consume files with .ts.js extension while tsc generates .js and source maps but NOT .ts.js.
Do I miss webpack
or gulp
to do some part of the job? I thought SystemJS and tsc
could do the bundling and transpiling but apparently there's smth missing in the build process.
Explanation on the SystemJS setup rather than fixing the bug would be also very helpful.