I want to debug the typescript source code of angular2. But I can not find source map file in bundles directory.So how angular2 creates bundles directory? And Can I generate it myself?
1 Answer
You could configure SystemJS to load Angular2 modules from separate files instead of the bundled ones.
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script>
System.config({
defaultJSExtensions: true,
map: {
angular2: 'node_modules/angular2',
rxjs: 'node_modules/rxjs'
},
packages: {
app: {
defaultExtension: 'js',
format: 'register'
},
angular2: {
defaultExtension: 'js',
}
}
});
System.import('app/boot')
.then(null, console.error.bind(console));
</script>
Source maps are embedded in JS files in the node_modules/angular2 folder this way:
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjoz(...)
This way you will be able to put breakpoints into Angular2 TypeScript files using DevTools.
Notice that the application load will be longer with this approach...
See this article for more details:
- How to debug the TypeScript source code of Angular2: https://medium.com/@ttemplier/how-to-debug-the-typescript-source-code-of-angular2-99a593e2983f#.fc5xoqt0b
4 Comments
small fish
Ii does not work! Can you show me in plunker? Thanks a lot!
Thierry Templier
What do you exactly mean by "it does not work"? ;-) You can't load the application or you can't set breakpoints in TypeScript files?
Thierry Templier
It's difficult to explain within an answer. So I created an article on the medium with screenshots: medium.com/@ttemplier/…. Hope it will answer your question ;-)
Max Koretskyi
@ThierryTemplier, have you tried that approach on the newest npm package that doesn't contain sources? I've posted the question, appreciate any feedback

sourceMap: truein your tsconfig.json