fix(tsc-wrapped): use tsickle's new source map composition feature (#14150)

Tsickle transforms typescript code, which can change the location of code.
This can cause issues such as runtime stack traces reporting that errors
were raised on the incorrect line in the orginal source.  This change replaces
the DecoratorDownlevelCompilerHost and the TsickleCompilerHost with tsickle's
TsickleCompilerHost, which automatically composes tsickle's source maps with
typescript's source maps, so that line numbers are correctly reported at
runtime.

PR Close #14150
This commit is contained in:
Lucas Sloan 2017-01-27 10:36:46 -08:00 committed by Miško Hevery
parent 2e1413016e
commit 5bccff0d7a
8 changed files with 1223 additions and 127 deletions

View File

@ -2901,6 +2901,466 @@
"version": "1.0.0", "version": "1.0.0",
"dev": true "dev": true
}, },
"fsevents": {
"version": "1.0.17",
"optional": true,
"dependencies": {
"abbrev": {
"version": "1.0.9",
"optional": true
},
"ansi-regex": {
"version": "2.0.0"
},
"ansi-styles": {
"version": "2.2.1",
"optional": true
},
"aproba": {
"version": "1.0.4",
"optional": true
},
"are-we-there-yet": {
"version": "1.1.2",
"optional": true
},
"asn1": {
"version": "0.2.3",
"optional": true
},
"assert-plus": {
"version": "0.2.0",
"optional": true
},
"asynckit": {
"version": "0.4.0",
"optional": true
},
"aws-sign2": {
"version": "0.6.0",
"optional": true
},
"aws4": {
"version": "1.5.0",
"optional": true
},
"balanced-match": {
"version": "0.4.2"
},
"bcrypt-pbkdf": {
"version": "1.0.0",
"optional": true
},
"block-stream": {
"version": "0.0.9"
},
"boom": {
"version": "2.10.1"
},
"brace-expansion": {
"version": "1.1.6"
},
"buffer-shims": {
"version": "1.0.0"
},
"caseless": {
"version": "0.11.0",
"optional": true
},
"chalk": {
"version": "1.1.3",
"optional": true,
"dependencies": {
"supports-color": {
"version": "2.0.0",
"optional": true
}
}
},
"code-point-at": {
"version": "1.1.0"
},
"combined-stream": {
"version": "1.0.5"
},
"commander": {
"version": "2.9.0",
"optional": true
},
"concat-map": {
"version": "0.0.1"
},
"console-control-strings": {
"version": "1.1.0"
},
"core-util-is": {
"version": "1.0.2"
},
"cryptiles": {
"version": "2.0.5",
"optional": true
},
"dashdash": {
"version": "1.14.1",
"optional": true,
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"optional": true
}
}
},
"debug": {
"version": "2.2.0",
"optional": true
},
"deep-extend": {
"version": "0.4.1",
"optional": true
},
"delayed-stream": {
"version": "1.0.0"
},
"delegates": {
"version": "1.0.0",
"optional": true
},
"ecc-jsbn": {
"version": "0.1.1",
"optional": true
},
"escape-string-regexp": {
"version": "1.0.5",
"optional": true
},
"extend": {
"version": "3.0.0",
"optional": true
},
"extsprintf": {
"version": "1.0.2"
},
"forever-agent": {
"version": "0.6.1",
"optional": true
},
"form-data": {
"version": "2.1.2",
"optional": true
},
"fs.realpath": {
"version": "1.0.0"
},
"fstream": {
"version": "1.0.10"
},
"fstream-ignore": {
"version": "1.0.5",
"optional": true
},
"gauge": {
"version": "2.7.2",
"optional": true
},
"generate-function": {
"version": "2.0.0",
"optional": true
},
"generate-object-property": {
"version": "1.2.0",
"optional": true
},
"getpass": {
"version": "0.1.6",
"optional": true,
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"optional": true
}
}
},
"glob": {
"version": "7.1.1"
},
"graceful-fs": {
"version": "4.1.11"
},
"graceful-readlink": {
"version": "1.0.1",
"optional": true
},
"har-validator": {
"version": "2.0.6",
"optional": true
},
"has-ansi": {
"version": "2.0.0",
"optional": true
},
"has-unicode": {
"version": "2.0.1",
"optional": true
},
"hawk": {
"version": "3.1.3",
"optional": true
},
"hoek": {
"version": "2.16.3"
},
"http-signature": {
"version": "1.1.1",
"optional": true
},
"inflight": {
"version": "1.0.6"
},
"inherits": {
"version": "2.0.3"
},
"ini": {
"version": "1.3.4",
"optional": true
},
"is-fullwidth-code-point": {
"version": "1.0.0"
},
"is-my-json-valid": {
"version": "2.15.0",
"optional": true
},
"is-property": {
"version": "1.0.2",
"optional": true
},
"is-typedarray": {
"version": "1.0.0",
"optional": true
},
"isarray": {
"version": "1.0.0"
},
"isstream": {
"version": "0.1.2",
"optional": true
},
"jodid25519": {
"version": "1.0.2",
"optional": true
},
"jsbn": {
"version": "0.1.0",
"optional": true
},
"json-schema": {
"version": "0.2.3",
"optional": true
},
"json-stringify-safe": {
"version": "5.0.1",
"optional": true
},
"jsonpointer": {
"version": "4.0.1",
"optional": true
},
"jsprim": {
"version": "1.3.1",
"optional": true
},
"mime-db": {
"version": "1.25.0"
},
"mime-types": {
"version": "2.1.13"
},
"minimatch": {
"version": "3.0.3"
},
"minimist": {
"version": "0.0.8"
},
"mkdirp": {
"version": "0.5.1"
},
"ms": {
"version": "0.7.1",
"optional": true
},
"node-pre-gyp": {
"version": "0.6.32",
"optional": true
},
"nopt": {
"version": "3.0.6",
"optional": true
},
"npmlog": {
"version": "4.0.2",
"optional": true
},
"number-is-nan": {
"version": "1.0.1"
},
"oauth-sign": {
"version": "0.8.2",
"optional": true
},
"object-assign": {
"version": "4.1.0",
"optional": true
},
"once": {
"version": "1.4.0"
},
"path-is-absolute": {
"version": "1.0.1"
},
"pinkie": {
"version": "2.0.4",
"optional": true
},
"pinkie-promise": {
"version": "2.0.1",
"optional": true
},
"process-nextick-args": {
"version": "1.0.7"
},
"punycode": {
"version": "1.4.1",
"optional": true
},
"qs": {
"version": "6.3.0",
"optional": true
},
"rc": {
"version": "1.1.6",
"optional": true,
"dependencies": {
"minimist": {
"version": "1.2.0",
"optional": true
}
}
},
"readable-stream": {
"version": "2.2.2",
"optional": true
},
"request": {
"version": "2.79.0",
"optional": true
},
"rimraf": {
"version": "2.5.4"
},
"semver": {
"version": "5.3.0",
"optional": true
},
"set-blocking": {
"version": "2.0.0",
"optional": true
},
"signal-exit": {
"version": "3.0.2",
"optional": true
},
"sntp": {
"version": "1.0.9",
"optional": true
},
"sshpk": {
"version": "1.10.1",
"optional": true,
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"optional": true
}
}
},
"string_decoder": {
"version": "0.10.31"
},
"string-width": {
"version": "1.0.2"
},
"stringstream": {
"version": "0.0.5",
"optional": true
},
"strip-ansi": {
"version": "3.0.1"
},
"strip-json-comments": {
"version": "1.0.4",
"optional": true
},
"supports-color": {
"version": "0.2.0",
"optional": true
},
"tar": {
"version": "2.2.1"
},
"tar-pack": {
"version": "3.3.0",
"optional": true,
"dependencies": {
"once": {
"version": "1.3.3",
"optional": true
},
"readable-stream": {
"version": "2.1.5",
"optional": true
}
}
},
"tough-cookie": {
"version": "2.3.2",
"optional": true
},
"tunnel-agent": {
"version": "0.4.3",
"optional": true
},
"tweetnacl": {
"version": "0.14.5",
"optional": true
},
"uid-number": {
"version": "0.0.6",
"optional": true
},
"util-deprecate": {
"version": "1.0.2"
},
"uuid": {
"version": "3.0.1",
"optional": true
},
"verror": {
"version": "1.3.6",
"optional": true
},
"wide-align": {
"version": "1.1.0",
"optional": true
},
"wrappy": {
"version": "1.0.2"
},
"xtend": {
"version": "4.0.1",
"optional": true
}
}
},
"fstream": { "fstream": {
"version": "0.1.31", "version": "0.1.31",
"dev": true "dev": true
@ -4382,8 +4842,7 @@
"dev": true "dev": true
}, },
"nan": { "nan": {
"version": "2.4.0", "version": "2.4.0"
"dev": true
}, },
"negotiator": { "negotiator": {
"version": "0.5.3", "version": "0.5.3",
@ -5725,7 +6184,7 @@
} }
}, },
"tsickle": { "tsickle": {
"version": "0.2.4", "version": "0.2.6",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"source-map": { "source-map": {

711
npm-shrinkwrap.json generated
View File

@ -4199,6 +4199,708 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"dev": true "dev": true
}, },
"fsevents": {
"version": "1.0.17",
"from": "fsevents@>=1.0.14 <2.0.0",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.0.17.tgz",
"optional": true,
"dependencies": {
"abbrev": {
"version": "1.0.9",
"from": "abbrev@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz",
"optional": true
},
"ansi-regex": {
"version": "2.0.0",
"from": "ansi-regex@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz"
},
"ansi-styles": {
"version": "2.2.1",
"from": "ansi-styles@>=2.2.1 <3.0.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
"optional": true
},
"aproba": {
"version": "1.0.4",
"from": "aproba@>=1.0.3 <2.0.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.0.4.tgz",
"optional": true
},
"are-we-there-yet": {
"version": "1.1.2",
"from": "are-we-there-yet@>=1.1.2 <1.2.0",
"resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz",
"optional": true
},
"asn1": {
"version": "0.2.3",
"from": "asn1@>=0.2.3 <0.3.0",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
"optional": true
},
"assert-plus": {
"version": "0.2.0",
"from": "assert-plus@>=0.2.0 <0.3.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
"optional": true
},
"asynckit": {
"version": "0.4.0",
"from": "asynckit@>=0.4.0 <0.5.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"optional": true
},
"aws-sign2": {
"version": "0.6.0",
"from": "aws-sign2@>=0.6.0 <0.7.0",
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz",
"optional": true
},
"aws4": {
"version": "1.5.0",
"from": "aws4@>=1.2.1 <2.0.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.5.0.tgz",
"optional": true
},
"balanced-match": {
"version": "0.4.2",
"from": "balanced-match@>=0.4.1 <0.5.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz"
},
"bcrypt-pbkdf": {
"version": "1.0.0",
"from": "bcrypt-pbkdf@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.0.tgz",
"optional": true
},
"block-stream": {
"version": "0.0.9",
"from": "block-stream@*",
"resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz"
},
"boom": {
"version": "2.10.1",
"from": "boom@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz"
},
"brace-expansion": {
"version": "1.1.6",
"from": "brace-expansion@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz"
},
"buffer-shims": {
"version": "1.0.0",
"from": "buffer-shims@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz"
},
"caseless": {
"version": "0.11.0",
"from": "caseless@>=0.11.0 <0.12.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz",
"optional": true
},
"chalk": {
"version": "1.1.3",
"from": "chalk@>=1.1.1 <2.0.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"optional": true,
"dependencies": {
"supports-color": {
"version": "2.0.0",
"from": "supports-color@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"optional": true
}
}
},
"code-point-at": {
"version": "1.1.0",
"from": "code-point-at@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz"
},
"combined-stream": {
"version": "1.0.5",
"from": "combined-stream@>=1.0.5 <1.1.0",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz"
},
"commander": {
"version": "2.9.0",
"from": "commander@>=2.9.0 <3.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz",
"optional": true
},
"concat-map": {
"version": "0.0.1",
"from": "concat-map@0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
},
"console-control-strings": {
"version": "1.1.0",
"from": "console-control-strings@>=1.1.0 <1.2.0",
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz"
},
"core-util-is": {
"version": "1.0.2",
"from": "core-util-is@>=1.0.0 <1.1.0",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
},
"cryptiles": {
"version": "2.0.5",
"from": "cryptiles@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz",
"optional": true
},
"dashdash": {
"version": "1.14.1",
"from": "dashdash@>=1.12.0 <2.0.0",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
"optional": true,
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"from": "assert-plus@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"optional": true
}
}
},
"debug": {
"version": "2.2.0",
"from": "debug@>=2.2.0 <2.3.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
"optional": true
},
"deep-extend": {
"version": "0.4.1",
"from": "deep-extend@>=0.4.0 <0.5.0",
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz",
"optional": true
},
"delayed-stream": {
"version": "1.0.0",
"from": "delayed-stream@>=1.0.0 <1.1.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz"
},
"delegates": {
"version": "1.0.0",
"from": "delegates@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
"optional": true
},
"ecc-jsbn": {
"version": "0.1.1",
"from": "ecc-jsbn@>=0.1.1 <0.2.0",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
"optional": true
},
"escape-string-regexp": {
"version": "1.0.5",
"from": "escape-string-regexp@>=1.0.2 <2.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"optional": true
},
"extend": {
"version": "3.0.0",
"from": "extend@>=3.0.0 <3.1.0",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz",
"optional": true
},
"extsprintf": {
"version": "1.0.2",
"from": "extsprintf@1.0.2",
"resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz"
},
"forever-agent": {
"version": "0.6.1",
"from": "forever-agent@>=0.6.1 <0.7.0",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
"optional": true
},
"form-data": {
"version": "2.1.2",
"from": "form-data@>=2.1.1 <2.2.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.2.tgz",
"optional": true
},
"fs.realpath": {
"version": "1.0.0",
"from": "fs.realpath@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
},
"fstream": {
"version": "1.0.10",
"from": "fstream@>=1.0.2 <2.0.0",
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.10.tgz"
},
"fstream-ignore": {
"version": "1.0.5",
"from": "fstream-ignore@>=1.0.5 <1.1.0",
"resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz",
"optional": true
},
"gauge": {
"version": "2.7.2",
"from": "gauge@>=2.7.1 <2.8.0",
"resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.2.tgz",
"optional": true
},
"generate-function": {
"version": "2.0.0",
"from": "generate-function@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz",
"optional": true
},
"generate-object-property": {
"version": "1.2.0",
"from": "generate-object-property@>=1.1.0 <2.0.0",
"resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz",
"optional": true
},
"getpass": {
"version": "0.1.6",
"from": "getpass@>=0.1.1 <0.2.0",
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.6.tgz",
"optional": true,
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"from": "assert-plus@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"optional": true
}
}
},
"glob": {
"version": "7.1.1",
"from": "glob@>=7.0.5 <8.0.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz"
},
"graceful-fs": {
"version": "4.1.11",
"from": "graceful-fs@>=4.1.2 <5.0.0",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz"
},
"graceful-readlink": {
"version": "1.0.1",
"from": "graceful-readlink@>=1.0.0",
"resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
"optional": true
},
"har-validator": {
"version": "2.0.6",
"from": "har-validator@>=2.0.6 <2.1.0",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz",
"optional": true
},
"has-ansi": {
"version": "2.0.0",
"from": "has-ansi@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
"optional": true
},
"has-unicode": {
"version": "2.0.1",
"from": "has-unicode@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz",
"optional": true
},
"hawk": {
"version": "3.1.3",
"from": "hawk@>=3.1.3 <3.2.0",
"resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz",
"optional": true
},
"hoek": {
"version": "2.16.3",
"from": "hoek@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz"
},
"http-signature": {
"version": "1.1.1",
"from": "http-signature@>=1.1.0 <1.2.0",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz",
"optional": true
},
"inflight": {
"version": "1.0.6",
"from": "inflight@>=1.0.4 <2.0.0",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz"
},
"inherits": {
"version": "2.0.3",
"from": "inherits@>=2.0.1 <2.1.0",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz"
},
"ini": {
"version": "1.3.4",
"from": "ini@>=1.3.0 <1.4.0",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz",
"optional": true
},
"is-fullwidth-code-point": {
"version": "1.0.0",
"from": "is-fullwidth-code-point@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz"
},
"is-my-json-valid": {
"version": "2.15.0",
"from": "is-my-json-valid@>=2.12.4 <3.0.0",
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz",
"optional": true
},
"is-property": {
"version": "1.0.2",
"from": "is-property@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
"optional": true
},
"is-typedarray": {
"version": "1.0.0",
"from": "is-typedarray@>=1.0.0 <1.1.0",
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
"optional": true
},
"isarray": {
"version": "1.0.0",
"from": "isarray@>=1.0.0 <1.1.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
},
"isstream": {
"version": "0.1.2",
"from": "isstream@>=0.1.2 <0.2.0",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"optional": true
},
"jodid25519": {
"version": "1.0.2",
"from": "jodid25519@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz",
"optional": true
},
"jsbn": {
"version": "0.1.0",
"from": "jsbn@>=0.1.0 <0.2.0",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.0.tgz",
"optional": true
},
"json-schema": {
"version": "0.2.3",
"from": "json-schema@0.2.3",
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
"optional": true
},
"json-stringify-safe": {
"version": "5.0.1",
"from": "json-stringify-safe@>=5.0.1 <5.1.0",
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"optional": true
},
"jsonpointer": {
"version": "4.0.1",
"from": "jsonpointer@>=4.0.0 <5.0.0",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz",
"optional": true
},
"jsprim": {
"version": "1.3.1",
"from": "jsprim@>=1.2.2 <2.0.0",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.3.1.tgz",
"optional": true
},
"mime-db": {
"version": "1.25.0",
"from": "mime-db@>=1.25.0 <1.26.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.25.0.tgz"
},
"mime-types": {
"version": "2.1.13",
"from": "mime-types@>=2.1.7 <2.2.0",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.13.tgz"
},
"minimatch": {
"version": "3.0.3",
"from": "minimatch@>=3.0.2 <4.0.0",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz"
},
"minimist": {
"version": "0.0.8",
"from": "minimist@0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz"
},
"mkdirp": {
"version": "0.5.1",
"from": "mkdirp@>=0.5.0 <0.6.0",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz"
},
"ms": {
"version": "0.7.1",
"from": "ms@0.7.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz",
"optional": true
},
"node-pre-gyp": {
"version": "0.6.32",
"from": "node-pre-gyp@>=0.6.29 <0.7.0",
"resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.32.tgz",
"optional": true
},
"nopt": {
"version": "3.0.6",
"from": "nopt@>=3.0.1 <3.1.0",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz",
"optional": true
},
"npmlog": {
"version": "4.0.2",
"from": "npmlog@>=4.0.1 <5.0.0",
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.0.2.tgz",
"optional": true
},
"number-is-nan": {
"version": "1.0.1",
"from": "number-is-nan@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz"
},
"oauth-sign": {
"version": "0.8.2",
"from": "oauth-sign@>=0.8.1 <0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
"optional": true
},
"object-assign": {
"version": "4.1.0",
"from": "object-assign@>=4.1.0 <5.0.0",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz",
"optional": true
},
"once": {
"version": "1.4.0",
"from": "once@>=1.3.0 <2.0.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz"
},
"path-is-absolute": {
"version": "1.0.1",
"from": "path-is-absolute@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz"
},
"pinkie": {
"version": "2.0.4",
"from": "pinkie@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz",
"optional": true
},
"pinkie-promise": {
"version": "2.0.1",
"from": "pinkie-promise@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz",
"optional": true
},
"process-nextick-args": {
"version": "1.0.7",
"from": "process-nextick-args@>=1.0.6 <1.1.0",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz"
},
"punycode": {
"version": "1.4.1",
"from": "punycode@>=1.4.1 <2.0.0",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"optional": true
},
"qs": {
"version": "6.3.0",
"from": "qs@>=6.3.0 <6.4.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.3.0.tgz",
"optional": true
},
"rc": {
"version": "1.1.6",
"from": "rc@>=1.1.0 <1.2.0",
"resolved": "https://registry.npmjs.org/rc/-/rc-1.1.6.tgz",
"optional": true,
"dependencies": {
"minimist": {
"version": "1.2.0",
"from": "minimist@>=1.2.0 <2.0.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"optional": true
}
}
},
"readable-stream": {
"version": "2.2.2",
"from": "readable-stream@>=2.0.0 <3.0.0||>=1.1.13 <2.0.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz",
"optional": true
},
"request": {
"version": "2.79.0",
"from": "request@>=2.79.0 <3.0.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.79.0.tgz",
"optional": true
},
"rimraf": {
"version": "2.5.4",
"from": "rimraf@>=2.5.4 <2.6.0",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz"
},
"semver": {
"version": "5.3.0",
"from": "semver@>=5.3.0 <5.4.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
"optional": true
},
"set-blocking": {
"version": "2.0.0",
"from": "set-blocking@>=2.0.0 <2.1.0",
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
"optional": true
},
"signal-exit": {
"version": "3.0.2",
"from": "signal-exit@>=3.0.0 <4.0.0",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
"optional": true
},
"sntp": {
"version": "1.0.9",
"from": "sntp@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz",
"optional": true
},
"sshpk": {
"version": "1.10.1",
"from": "sshpk@>=1.7.0 <2.0.0",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.10.1.tgz",
"optional": true,
"dependencies": {
"assert-plus": {
"version": "1.0.0",
"from": "assert-plus@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"optional": true
}
}
},
"string_decoder": {
"version": "0.10.31",
"from": "string_decoder@>=0.10.0 <0.11.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz"
},
"string-width": {
"version": "1.0.2",
"from": "string-width@>=1.0.1 <2.0.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz"
},
"stringstream": {
"version": "0.0.5",
"from": "stringstream@>=0.0.4 <0.1.0",
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
"optional": true
},
"strip-ansi": {
"version": "3.0.1",
"from": "strip-ansi@>=3.0.1 <4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz"
},
"strip-json-comments": {
"version": "1.0.4",
"from": "strip-json-comments@>=1.0.4 <1.1.0",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz",
"optional": true
},
"supports-color": {
"version": "0.2.0",
"from": "supports-color@>=0.2.0 <0.3.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz",
"optional": true
},
"tar": {
"version": "2.2.1",
"from": "tar@>=2.2.0 <2.3.0",
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz"
},
"tar-pack": {
"version": "3.3.0",
"from": "tar-pack@>=3.3.0 <3.4.0",
"resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.3.0.tgz",
"optional": true,
"dependencies": {
"once": {
"version": "1.3.3",
"from": "once@>=1.3.3 <1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz",
"optional": true
},
"readable-stream": {
"version": "2.1.5",
"from": "readable-stream@>=2.1.4 <2.2.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz",
"optional": true
}
}
},
"tough-cookie": {
"version": "2.3.2",
"from": "tough-cookie@>=2.3.0 <2.4.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz",
"optional": true
},
"tunnel-agent": {
"version": "0.4.3",
"from": "tunnel-agent@>=0.4.1 <0.5.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz",
"optional": true
},
"tweetnacl": {
"version": "0.14.5",
"from": "tweetnacl@>=0.14.0 <0.15.0",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
"optional": true
},
"uid-number": {
"version": "0.0.6",
"from": "uid-number@>=0.0.6 <0.1.0",
"resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz",
"optional": true
},
"util-deprecate": {
"version": "1.0.2",
"from": "util-deprecate@>=1.0.1 <1.1.0",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
},
"uuid": {
"version": "3.0.1",
"from": "uuid@>=3.0.0 <4.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz",
"optional": true
},
"verror": {
"version": "1.3.6",
"from": "verror@1.3.6",
"resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz",
"optional": true
},
"wide-align": {
"version": "1.1.0",
"from": "wide-align@>=1.1.0 <2.0.0",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.0.tgz",
"optional": true
},
"wrappy": {
"version": "1.0.2",
"from": "wrappy@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz"
},
"xtend": {
"version": "4.0.1",
"from": "xtend@>=4.0.0 <5.0.0",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
"optional": true
}
}
},
"fstream": { "fstream": {
"version": "0.1.31", "version": "0.1.31",
"from": "fstream@>=0.1.30 <1.0.0", "from": "fstream@>=0.1.30 <1.0.0",
@ -6368,8 +7070,7 @@
"nan": { "nan": {
"version": "2.4.0", "version": "2.4.0",
"from": "nan@latest", "from": "nan@latest",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.4.0.tgz", "resolved": "https://registry.npmjs.org/nan/-/nan-2.4.0.tgz"
"dev": true
}, },
"negotiator": { "negotiator": {
"version": "0.5.3", "version": "0.5.3",
@ -8343,9 +9044,9 @@
} }
}, },
"tsickle": { "tsickle": {
"version": "0.2.4", "version": "0.2.6",
"from": "tsickle@0.2.4", "from": "tsickle@0.2.6",
"resolved": "https://registry.npmjs.org/tsickle/-/tsickle-0.2.4.tgz", "resolved": "https://registry.npmjs.org/tsickle/-/tsickle-0.2.6.tgz",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"source-map": { "source-map": {

View File

@ -86,7 +86,7 @@
"source-map-support": "^0.4.2", "source-map-support": "^0.4.2",
"systemjs": "0.18.10", "systemjs": "0.18.10",
"ts-api-guardian": "0.1.4", "ts-api-guardian": "0.1.4",
"tsickle": "^0.2.4", "tsickle": "^0.2.6",
"tslint": "^4.1.1", "tslint": "^4.1.1",
"tslint-eslint-rules": "^3.1.0", "tslint-eslint-rules": "^3.1.0",
"typescript": "^2.0.2", "typescript": "^2.0.2",

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
export {DecoratorDownlevelCompilerHost, MetadataWriterHost} from './src/compiler_host'; export {MetadataWriterHost} from './src/compiler_host';
export {CodegenExtension, UserError, main} from './src/main'; export {CodegenExtension, UserError, main} from './src/main';
export {default as AngularCompilerOptions} from './src/options'; export {default as AngularCompilerOptions} from './src/options';

View File

@ -50,64 +50,6 @@ export abstract class DelegatingHost implements ts.CompilerHost {
directoryExists = (directoryName: string) => this.delegate.directoryExists(directoryName); directoryExists = (directoryName: string) => this.delegate.directoryExists(directoryName);
} }
export class DecoratorDownlevelCompilerHost extends DelegatingHost {
private ANNOTATION_SUPPORT = `
interface DecoratorInvocation {
type: Function;
args?: any[];
}
`;
/** Error messages produced by tsickle, if any. */
public diagnostics: ts.Diagnostic[] = [];
constructor(delegate: ts.CompilerHost, private program: ts.Program) { super(delegate); }
getSourceFile =
(fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void) => {
const originalContent = this.delegate.readFile(fileName);
let newContent = originalContent;
if (!/\.d\.ts$/.test(fileName)) {
try {
const converted = tsickle.convertDecorators(
this.program.getTypeChecker(), this.program.getSourceFile(fileName));
if (converted.diagnostics) {
this.diagnostics.push(...converted.diagnostics);
}
newContent = converted.output + this.ANNOTATION_SUPPORT;
} catch (e) {
console.error('Cannot convertDecorators on file', fileName);
throw e;
}
}
return ts.createSourceFile(fileName, newContent, languageVersion, true);
}
}
export class TsickleCompilerHost extends DelegatingHost {
/** Error messages produced by tsickle, if any. */
public diagnostics: ts.Diagnostic[] = [];
constructor(
delegate: ts.CompilerHost, private oldProgram: ts.Program, private options: NgOptions) {
super(delegate);
}
getSourceFile =
(fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void) => {
let sourceFile = this.oldProgram.getSourceFile(fileName);
let isDefinitions = /\.d\.ts$/.test(fileName);
// Don't tsickle-process any d.ts that isn't a compilation target;
// this means we don't process e.g. lib.d.ts.
if (isDefinitions) return sourceFile;
const es2015Target = this.options.target == ts.ScriptTarget.ES2015; // This covers ES6 too
let {output, externs, diagnostics} = tsickle.annotate(
this.oldProgram, sourceFile, {untyped: true, convertIndexImportShorthand: es2015Target},
this.delegate, this.options);
this.diagnostics = diagnostics;
return ts.createSourceFile(fileName, output, languageVersion, true);
}
}
const IGNORED_FILES = /\.ngfactory\.js$|\.ngstyle\.js$/; const IGNORED_FILES = /\.ngfactory\.js$|\.ngstyle\.js$/;
export class MetadataWriterHost extends DelegatingHost { export class MetadataWriterHost extends DelegatingHost {

View File

@ -8,12 +8,13 @@
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as tsickle from 'tsickle';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {check, tsc} from './tsc'; import {check, tsc} from './tsc';
import NgOptions from './options'; import NgOptions from './options';
import {MetadataWriterHost, DecoratorDownlevelCompilerHost, TsickleCompilerHost} from './compiler_host'; import {MetadataWriterHost} from './compiler_host';
import {CliOptions} from './cli_options'; import {CliOptions} from './cli_options';
import {VinylFile, isVinylFile} from './vinyl_file'; import {VinylFile, isVinylFile} from './vinyl_file';
@ -77,22 +78,40 @@ export function main(
let preprocessHost = host; let preprocessHost = host;
let programForJsEmit = programWithCodegen; let programForJsEmit = programWithCodegen;
const tsickleCompilerHostOptions: tsickle.Options = {
googmodule: false,
untyped: true,
convertIndexImportShorthand:
ngOptions.target === ts.ScriptTarget.ES2015, // This covers ES6 too
};
const tsickleHost: tsickle.TsickleHost = {
shouldSkipTsickleProcessing: (fileName) => false,
pathToModuleName: (context, importPath) => '',
shouldIgnoreWarningsForPath: (filePath) => false,
fileNameToModuleId: (fileName) => fileName,
};
const tsickleCompilerHost = new tsickle.TsickleCompilerHost(
preprocessHost, ngOptions, tsickleCompilerHostOptions, tsickleHost);
if (ngOptions.annotationsAs !== 'decorators') { if (ngOptions.annotationsAs !== 'decorators') {
if (diagnostics) console.time('NG downlevel'); if (diagnostics) console.time('NG downlevel');
const downlevelHost = new DecoratorDownlevelCompilerHost(preprocessHost, programForJsEmit); tsickleCompilerHost.reconfigureForRun(programForJsEmit, tsickle.Pass.DECORATOR_DOWNLEVEL);
// A program can be re-used only once; save the programWithCodegen to be reused by // A program can be re-used only once; save the programWithCodegen to be reused by
// metadataWriter // metadataWriter
programForJsEmit = createProgram(downlevelHost); programForJsEmit = createProgram(tsickleCompilerHost);
check(downlevelHost.diagnostics); check(tsickleCompilerHost.diagnostics);
preprocessHost = downlevelHost; preprocessHost = tsickleCompilerHost;
if (diagnostics) console.timeEnd('NG downlevel'); if (diagnostics) console.timeEnd('NG downlevel');
} }
if (ngOptions.annotateForClosureCompiler) { if (ngOptions.annotateForClosureCompiler) {
if (diagnostics) console.time('NG JSDoc'); if (diagnostics) console.time('NG JSDoc');
const tsickleHost = new TsickleCompilerHost(preprocessHost, programForJsEmit, ngOptions); tsickleCompilerHost.reconfigureForRun(programForJsEmit, tsickle.Pass.CLOSURIZE);
programForJsEmit = createProgram(tsickleHost); programForJsEmit = createProgram(tsickleCompilerHost);
check(tsickleHost.diagnostics); check(tsickleCompilerHost.diagnostics);
if (diagnostics) console.timeEnd('NG JSDoc'); if (diagnostics) console.timeEnd('NG JSDoc');
} }

View File

@ -1,51 +0,0 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as ts from 'typescript';
import NgOptions from '../src/options';
import {formatDiagnostics, TsickleCompilerHost} from '../src/compiler_host';
import {writeTempFile} from './test_support';
describe('Compiler Host', () => {
function makeProgram(fileName: string, source: string): [ts.Program, ts.CompilerHost, NgOptions] {
let fn = writeTempFile(fileName, source);
let opts: NgOptions = {
target: ts.ScriptTarget.ES5,
types: [],
genDir: '/tmp',
basePath: '/tmp',
noEmit: true,
};
// TsickleCompilerHost wants a ts.Program, which is the result of
// parsing and typechecking the code before tsickle processing.
// So we must create and run the entire stack of CompilerHost.
let host = ts.createCompilerHost(opts);
let program = ts.createProgram([fn], opts, host);
// To get types resolved, you must first call getPreEmitDiagnostics.
let diags = formatDiagnostics(ts.getPreEmitDiagnostics(program));
expect(diags).toEqual('');
return [program, host, opts];
}
it('inserts JSDoc annotations', () => {
const [program, host, opts] = makeProgram('foo.ts', 'let x: number = 123');
const tsickleHost = new TsickleCompilerHost(host, program, opts);
const f = tsickleHost.getSourceFile(program.getRootFileNames()[0], ts.ScriptTarget.ES5);
expect(f.text).toContain('/** @type {?} */');
});
it('reports diagnostics about existing JSDoc', () => {
const [program, host, opts] =
makeProgram('error.ts', '/** @param {string} x*/ function f(x: string){};');
const tsickleHost = new TsickleCompilerHost(host, program, opts);
const f = tsickleHost.getSourceFile(program.getRootFileNames()[0], ts.ScriptTarget.ES5);
expect(formatDiagnostics(tsickleHost.diagnostics)).toContain('redundant with TypeScript types');
});
});

View File

@ -238,4 +238,30 @@ describe('tsc-wrapped', () => {
}) })
.catch(e => done.fail(e)); .catch(e => done.fail(e));
}); });
it('should produce valid source maps', (done) => {
write('tsconfig.json', `{
"compilerOptions": {
"experimentalDecorators": true,
"types": [],
"outDir": "built",
"declaration": true,
"moduleResolution": "node",
"target": "es2015",
"sourceMap": true
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true
},
"files": ["test.ts"]
}`);
main(basePath, {basePath})
.then(() => {
const out = readOut('js.map');
expect(out).toContain('"sources":["../test.ts"]');
done();
})
.catch(e => done.fail(e));
});
}); });