typescript - tsc --out weird behavior when using 'import' in my files -


i have 2 typescript files, app.ts, , `angular2.d.ts' (which contains type definitions angular2)

my tsconfig.json file looks so:

{ "compileroptions": {     "module": "commonjs",     "out": "public/all.js",     "sourcemap": true,     "watch": true,     "target": "es5" }, "files": [     "typings/angular2/angular2.d.ts",     "src/app.ts"    ]} 

expected result - public/all.js contain compiled ts file.

actual result - src/app.js file created, contains compiled ts file. public/all.js created, contains following line: //# sourcemappingurl=all.js.map (i.e. source mapping, no actual code)

when investigating further, problematic line is: import {component, view, bootstrap} 'angular2/angular2'; in src/app.ts. remove line compiles correctly. put - causes aforementioned problem.

what doing wrong?

settings "out":"public/all.js" , "module":"commonjs" mutually exclusive. should either:

  1. use internal modules , let compiler concatenate output file (remove module setting config);
    @basarat advise against it, think it's not bad, small projects.
  2. use external modules , concatenate output files other tools (set "outdir":"public/" , remove out setting config).

commonjs modules meant node.js, amd modules meant require.js. if you're doing frontend development, it's best use amd or internal modules.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -