I have two typescript files, app.ts
, and `angular2.d.ts' (which contains type definitions for angular2)
my tsconfig.json
file looks like 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
would contain the compiled ts file.
Actual result - src/app.js
file is created, that contains the compiled ts file.
public/all.js
is also created, but it only contains the following line:
//# sourceMappingURL=all.js.map
(i.e. just the source mapping, no actual code)
When investigating further, the problematic line is:
import {Component, View, bootstrap} from 'angular2/angular2';
in src/app.ts
. as soon as I remove that line everything compiles correctly. as soon as i put it back - it causes the aforementioned problem.
What am I doing wrong?
Settings "out":"public/all.js"
and "module":"commonjs"
are mutually exclusive. You should either:
module
setting from config);"outDir":"public/"
and remove out
setting from config).commonjs
modules are meant for Node.js
, amd
modules are meant for require.js
. If you're doing frontend development, it's best to use amd
or internal modules.