├── .editorconfig ├── .gitignore ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── examples ├── angular │ ├── index-bundle.html │ ├── index-inject.html │ ├── index.html │ ├── jspm.browser.js │ ├── jspm.config.js │ ├── package.json │ ├── src │ │ ├── _references.d.ts │ │ ├── another-tsconfig.json │ │ ├── example-controller.ts │ │ ├── example-service.ts │ │ ├── example-template.html │ │ ├── example-types.ts │ │ ├── index.css │ │ └── index.ts │ └── tsconfig.json ├── angular2 │ ├── index-bundle.html │ ├── index-inject.html │ ├── index.html │ ├── jspm.browser.js │ ├── jspm.config.js │ ├── package.json │ ├── shims.js │ ├── src │ │ ├── _references.d.ts │ │ ├── calculator-component.ts │ │ ├── calculator-store.ts │ │ ├── calculator-view.html │ │ ├── index.css │ │ └── index.ts │ └── tsconfig.json ├── nodejs │ ├── generate.ts │ ├── jspm.browser.js │ ├── jspm.config.js │ ├── main.ts │ └── package.json ├── react │ ├── index-bundle.html │ ├── index-inject.html │ ├── index.html │ ├── jspm.browser.js │ ├── jspm.config.js │ ├── package.json │ ├── src │ │ ├── __tests__ │ │ │ ├── calculator-store-tests.js │ │ │ └── calculator-tests.js │ │ ├── calculator-store.tsx │ │ ├── calculator.css │ │ ├── calculator.tsx │ │ └── index.tsx │ └── tsconfig.json └── tasks │ ├── build.js │ └── start.js ├── lib └── plugin.js ├── package.json ├── rollup.config.js ├── src ├── compiler-host.ts ├── format-errors.ts ├── logger.ts ├── plugin.ts ├── resolve-options.ts ├── transpiler.ts ├── types.d.ts └── utils.ts ├── test ├── builder-spec.ts ├── compiler-host-spec.ts ├── environment.js ├── fixtures-es6 │ ├── _references.d.ts │ ├── ambients │ │ ├── ambient-consumer.ts │ │ ├── ambient-import-js.ts │ │ ├── ambient-nested.ts │ │ ├── ambient-reference-disabled.ts │ │ ├── ambient-requires.d.ts │ │ ├── ambient-requires.ts │ │ ├── ambient-resolve.ts │ │ ├── backslash-reference.ts │ │ └── resolved │ │ │ └── ambient │ │ │ ├── ambient.d.ts │ │ │ ├── ambient.js │ │ │ ├── ambient.ts │ │ │ └── ambient2.d.ts │ ├── attypes │ │ ├── index.ts │ │ └── resolved │ │ │ └── @types │ │ │ └── react │ │ │ └── index.d.ts │ ├── augmentation │ │ ├── ambient-aug.d.ts │ │ ├── ambient-global-aug.d.ts │ │ ├── ambient-global.ts │ │ ├── ambient.ts │ │ ├── external.ts │ │ ├── global-aug.d.ts │ │ ├── global.ts │ │ └── resolved │ │ │ └── somelib │ │ │ └── somelib.d.ts │ ├── circular │ │ ├── circular.ts │ │ ├── circular1.d.ts │ │ └── circular2.d.ts │ ├── css │ │ ├── import-css.ts │ │ └── some-css.css │ ├── es3 │ │ └── trailing-comma.ts │ ├── external.d.ts │ ├── external │ │ ├── dependency.ts │ │ ├── entry.ts │ │ └── other.ts │ ├── html │ │ ├── html-cjs.d.ts │ │ ├── html-es6.d.ts │ │ ├── import-html-cjs.ts │ │ ├── import-html.ts │ │ └── some-html.html │ ├── plugin-text.js │ ├── plugin │ │ ├── ambient │ │ │ └── index.ts │ │ ├── attypes │ │ │ ├── @types │ │ │ │ └── reacty │ │ │ │ │ └── index.d.ts │ │ │ ├── index.tsx │ │ │ └── reacty │ │ │ │ └── index.js │ │ ├── commonjs │ │ │ ├── index.js │ │ │ └── index.ts │ │ ├── dynamic │ │ │ ├── dynamic-dependency.ts │ │ │ └── index.ts │ │ ├── elisions-exports │ │ │ ├── index.ts │ │ │ └── types.ts │ │ ├── elisions │ │ │ ├── bad │ │ │ │ ├── index.ts │ │ │ │ └── types.ts │ │ │ ├── index.ts │ │ │ └── types.ts │ │ ├── es6 │ │ │ ├── index.js │ │ │ ├── promise.ts │ │ │ └── second.js │ │ ├── execute │ │ │ ├── counter.ts │ │ │ ├── elided.ts │ │ │ ├── imported.ts │ │ │ └── index.ts │ │ ├── external │ │ │ ├── external.d.ts │ │ │ ├── external.js │ │ │ └── second.d.ts │ │ ├── html │ │ │ ├── index.ts │ │ │ └── template.html │ │ ├── js │ │ │ └── somelib.js │ │ ├── mixture │ │ │ └── index.ts │ │ ├── reference │ │ │ ├── index.ts │ │ │ └── types.d.ts │ │ ├── strict │ │ │ ├── fail.ts │ │ │ └── missing.ts │ │ ├── syntax │ │ │ ├── index.js │ │ │ └── index.ts │ │ ├── synthetic │ │ │ ├── index.ts │ │ │ └── somelib.d.ts │ │ └── tsconfig │ │ │ ├── extend1 │ │ │ └── tsconfig.json │ │ │ ├── extend2 │ │ │ └── tsconfig.json │ │ │ ├── extends-package.json │ │ │ ├── extends-relative.json │ │ │ ├── extends-transitive.json │ │ │ ├── good.ts │ │ │ ├── index.ts │ │ │ └── tsconfig.json │ ├── program1 │ │ ├── const-enums.ts │ │ ├── jsx-preserve.tsx │ │ ├── missing-import.ts │ │ ├── nested-type-error.ts │ │ ├── no-imports.ts │ │ ├── one-import.ts │ │ ├── ref-import.ts │ │ ├── ref-syntax-error.ts │ │ ├── symbol.ts │ │ ├── syntax-error.d.ts │ │ ├── syntax-error.ts │ │ └── type-error.ts │ ├── tsconfig │ │ ├── alternate.json │ │ ├── declaration.json │ │ ├── default.json │ │ └── theirmodule.d.ts │ └── typings │ │ ├── angular2-typings.ts │ │ ├── css-typings.ts │ │ ├── missing-package.ts │ │ ├── missing-typings.ts │ │ ├── missing.d.ts │ │ ├── resolved │ │ ├── @angular2 │ │ │ └── core │ │ │ │ ├── core.d.ts │ │ │ │ ├── core.js │ │ │ │ ├── nested.d.ts │ │ │ │ ├── package.json │ │ │ │ └── shims.d.ts │ │ ├── cssmodules │ │ │ ├── mystyles.css │ │ │ └── mystyles.d.ts │ │ ├── missing │ │ │ ├── missing.js │ │ │ └── package.json │ │ └── rxjs │ │ │ ├── Rx.d.ts │ │ │ ├── package.json │ │ │ └── rxjs.js │ │ └── rxjs-typings.ts ├── plugin-spec.ts ├── resolve-options-spec.ts ├── transpiler-spec.ts ├── tsconfig.json └── utils-spec.ts └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | indent_size = 3 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | node_modules/ 3 | jspm_packages/ 4 | build/ 5 | components/ 6 | coverage/ 7 | tmp/ 8 | oldsrc/ 9 | oldtest/ 10 | package-lock.json -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .* 3 | *.json 4 | examples/ 5 | node_modules/ 6 | src/ 7 | test/ 8 | typings/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6.9" 4 | - "8.9" 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## [5.1.1](https://github.com/frankwallis/plugin-typescript/compare/5.1.0...5.1.1) (2016-09-04) 3 | 4 | 5 | ### Features 6 | 7 | * **typings:** automatically resolve typings files under 'typings' packages ([b01b26a](https://github.com/frankwallis/plugin-typescript/commit/b01b26a)) 8 | * **typings:** add 'typings' compiler option ([ee8551d](https://github.com/frankwallis/plugin-typescript/commit/ee8551d)) 9 | 10 | 11 | 12 | 13 | ## [5.0.20](https://github.com/frankwallis/plugin-typescript/compare/5.0.19...5.0.20) (2016-09-03) 14 | 15 | 16 | ### Bug Fixes 17 | 18 | * **scoped-packages:** fix for typings resolution under scoped package, bump 5.0.20 ([956a5ad](https://github.com/frankwallis/plugin-typescript/commit/956a5ad)) 19 | * **types:** patch for jspm[@0](https://github.com/0).16 defaultJsExtensions, bump 5.0.19 ([cea087f](https://github.com/frankwallis/plugin-typescript/commit/cea087f)) 20 | 21 | 22 | 23 | 24 | ## [5.0.18](https://github.com/frankwallis/plugin-typescript/compare/5.0.17...5.0.18) (2016-08-23) 25 | 26 | 27 | ### Bug Fixes 28 | 29 | * **logging:** remove debug logging ([e09945c](https://github.com/frankwallis/plugin-typescript/commit/e09945c)) 30 | 31 | 32 | 33 | 34 | ## [5.0.17](https://github.com/frankwallis/plugin-typescript/compare/5.0.16...5.0.17) (2016-08-22) 35 | 36 | 37 | ### Features 38 | 39 | * **@types:** use existing 'types' compiler option ([caf89c1](https://github.com/frankwallis/plugin-typescript/commit/caf89c1)) 40 | * **attypes:** fix for resolving type references ([987e7f2](https://github.com/frankwallis/plugin-typescript/commit/987e7f2)) 41 | * **@types:** support type reference directives ([4527d8e](https://github.com/frankwallis/plugin-typescript/commit/4527d8e)) 42 | * **@types:** default [@types](https://github.com/types) main to index.d.ts ([1c7674d](https://github.com/frankwallis/plugin-typescript/commit/1c7674d)) 43 | * **@types:** new 'types' compiler option for [@types](https://github.com/types) support, bump 5.0.12 ([953bcf7](https://github.com/frankwallis/plugin-typescript/commit/953bcf7)) 44 | 45 | 46 | 47 | 48 | ## [5.0.11](https://github.com/frankwallis/plugin-typescript/compare/5.0.9...5.0.11) (2016-08-21) 49 | 50 | 51 | ### Bug Fixes 52 | 53 | * **reporting:** suppress duplicate module resolution errors ([af18c80](https://github.com/frankwallis/plugin-typescript/commit/af18c80)) 54 | 55 | ### Features 56 | 57 | * **lib-option:** provide back-support for targetLib, don't load lib files when transpiring ([3b9dc3b](https://github.com/frankwallis/plugin-typescript/commit/3b9dc3b)) 58 | * **typescript-2.0:** add support for lib compiler option ([b2367de](https://github.com/frankwallis/plugin-typescript/commit/b2367de)) 59 | 60 | 61 | 62 | 63 | ## [5.0.9](https://github.com/frankwallis/plugin-typescript/compare/5.0.8...5.0.9) (2016-08-03) 64 | 65 | 66 | ### Features 67 | 68 | * **perf:** prevent unnecessary calls to getAllDiagnostics ([b14ed99](https://github.com/frankwallis/plugin-typescript/commit/b14ed99)) 69 | * **rollup:** fix failing tests ([542da97](https://github.com/frankwallis/plugin-typescript/commit/542da97)) 70 | * **rollup:** fix failing tests ([6f6dd92](https://github.com/frankwallis/plugin-typescript/commit/6f6dd92)) 71 | * **rollup:** fix failing tests ([928eb88](https://github.com/frankwallis/plugin-typescript/commit/928eb88)) 72 | 73 | 74 | 75 | 76 | ## [5.0.8](https://github.com/frankwallis/plugin-typescript/compare/5.0.6...5.0.8) (2016-07-17) 77 | 78 | 79 | ### Features 80 | 81 | * **rollup:** don't automatically switch output from system -> es6 modules ([50198a2](https://github.com/frankwallis/plugin-typescript/commit/50198a2)) 82 | * **rollup:** default allowSyntheticDefaultImports to true ([3774d4e](https://github.com/frankwallis/plugin-typescript/commit/3774d4e)) 83 | 84 | 85 | 86 | 87 | ## [5.0.6](https://github.com/frankwallis/plugin-typescript/compare/5.0.4...5.0.6) (2016-07-16) 88 | 89 | 90 | ### Features 91 | 92 | * **logging:** specify type of log message ([f10d977](https://github.com/frankwallis/plugin-typescript/commit/f10d977)) 93 | * **rollup:** fix for bundling issue when outputting commonjs ([c83e7ab](https://github.com/frankwallis/plugin-typescript/commit/c83e7ab)) 94 | 95 | 96 | 97 | 98 | ## [5.0.4](https://github.com/frankwallis/plugin-typescript/compare/5.0.1...5.0.4) (2016-07-16) 99 | 100 | 101 | ### Features 102 | 103 | * **strict-mode:** improve typeCheck 'strict' ([217d67b](https://github.com/frankwallis/plugin-typescript/commit/217d67b)) 104 | * **rollup:** support rollup when bundling ([f4bbce2](https://github.com/frankwallis/plugin-typescript/commit/f4bbce2)) 105 | * **strict-mode:** improve typeCheck 'strict' ([dd81c4a](https://github.com/frankwallis/plugin-typescript/commit/dd81c4a)) 106 | 107 | 108 | ### Bug Fixes 109 | 110 | * **augmentation:** warn when trying to resolve module 'global', patch for [#144](https://github.com/frankwallis/plugin-typescript/issues/144) ([0890792](https://github.com/frankwallis/plugin-typescript/commit/0890792)) 111 | 112 | 113 | 114 | 115 | ## [5.0.1](https://github.com/frankwallis/plugin-typescript/compare/5.0.0...5.0.1) (2016-07-12) 116 | 117 | 118 | ### Features 119 | 120 | * **wildcard-modules:** remove deprecated supportHtmlImports/resolveAmbientRefs from examples and docs ([8cb83f6](https://github.com/frankwallis/plugin-typescript/commit/8cb83f6)) 121 | * **esm-deps:** es modules now support metadata.deps, remove workaround ([0a88fda](https://github.com/frankwallis/plugin-typescript/commit/0a88fda)) 122 | * **typescript-2.0.0:** upgrade to typescript[@2](https://github.com/2).0.0, bump 5.0.0 ([1aa05b3](https://github.com/frankwallis/plugin-typescript/commit/1aa05b3)) 123 | 124 | 125 | 126 | 127 | ## [4.0.16](https://github.com/frankwallis/plugin-typescript/compare/4.0.15...4.0.16) (2016-05-16) 128 | 129 | 130 | ### Bug Fixes 131 | 132 | * **plugin-json:** fix for issue importing json with plugin-json, bump 4.0.16 ([d47f836](https://github.com/frankwallis/plugin-typescript/commit/d47f836)) 133 | 134 | 135 | 136 | 137 | ## [4.0.15](https://github.com/frankwallis/plugin-typescript/compare/4.0.10...4.0.15) (2016-05-15) 138 | 139 | 140 | ### Bug Fixes 141 | 142 | * **html-imports:** fix for html imports using commonjs/es6, bump 4.0.15 ([ea6bd13](https://github.com/frankwallis/plugin-typescript/commit/ea6bd13)) 143 | * **logging:** turn off debug logging, bump 4.0.14 ([8beb22f](https://github.com/frankwallis/plugin-typescript/commit/8beb22f)) 144 | * **elided-imports:** add fix for plugin, bump 4.0.12 ([da5a93e](https://github.com/frankwallis/plugin-typescript/commit/da5a93e)) 145 | * **elided-imports:** add fix for es6 output, bump 4.0.11 ([bc9bfb0](https://github.com/frankwallis/plugin-typescript/commit/bc9bfb0)) 146 | * **elided-imports:** add fix to set metadata.deps after instantiation ([647828a](https://github.com/frankwallis/plugin-typescript/commit/647828a)) 147 | 148 | ### Features 149 | 150 | * **e2e:** add some integration tests ([ba1ca96](https://github.com/frankwallis/plugin-typescript/commit/ba1ca96)) 151 | * **elided-imports:** add tests for builder ([c5b26ee](https://github.com/frankwallis/plugin-typescript/commit/c5b26ee)) 152 | * **elided-imports:** add tests for execution ([d75baaa](https://github.com/frankwallis/plugin-typescript/commit/d75baaa)) 153 | 154 | 155 | 156 | ## [4.0.10](https://github.com/frankwallis/plugin-typescript/compare/4.0.9...4.0.10) (2016-05-09) 157 | 158 | 159 | ### Bug Fixes 160 | 161 | * **ambientExternalModules:** fix for issue compiling `declare module '../somemodule'`, closes [#125](https://github.com/frankwallis/plugin-typescript/issues/125), bump 4.0.10 ([ea8a49c](https://github.com/frankwallis/plugin-typescript/commit/ea8a49c)) 162 | 163 | 164 | 165 | 166 | ## [4.0.9](https://github.com/frankwallis/plugin-typescript/compare/4.0.8...4.0.9) (2016-05-04) 167 | 168 | 169 | ### Bug Fixes 170 | 171 | * **relative-typings:** lookup typings for all js imports, add test, bump 4.0.9 ([a15da0d](https://github.com/frankwallis/plugin-typescript/commit/a15da0d)) 172 | 173 | 174 | 175 | 176 | ## [4.0.8](https://github.com/frankwallis/plugin-typescript/compare/4.0.7...4.0.8) (2016-04-30) 177 | 178 | 179 | ### Bug Fixes 180 | 181 | * **build-execution:** use metadata.deps to inject files into build or add import source when outputting es6 ([08631fc](https://github.com/frankwallis/plugin-typescript/commit/08631fc)) 182 | 183 | 184 | 185 | 186 | ## [4.0.7](https://github.com/frankwallis/plugin-typescript/compare/4.0.6...4.0.7) (2016-04-22) 187 | 188 | 189 | ### Bug Fixes 190 | 191 | * **double-evaluation:** fix for modules being evaluated twice, closes [#119](https://github.com/frankwallis/plugin-typescript/issues/119), bump 4.0.7 ([3ae63b7](https://github.com/frankwallis/plugin-typescript/commit/3ae63b7)) 192 | 193 | 194 | 195 | 196 | ## [4.0.6](https://github.com/frankwallis/plugin-typescript/compare/4.0.5...4.0.6) (2016-04-17) 197 | 198 | 199 | ### Bug Fixes 200 | 201 | * **elided-imports:** fix for issue where .ts import file was being elided, closes [#117](https://github.com/frankwallis/plugin-typescript/issues/117), bump 4.0.6 ([58cc11c](https://github.com/frankwallis/plugin-typescript/commit/58cc11c)) 202 | 203 | 204 | 205 | 206 | ## [4.0.5](https://github.com/frankwallis/plugin-typescript/compare/4.0.4...4.0.5) (2016-03-27) 207 | 208 | 209 | ### Bug Fixes 210 | 211 | * **strict:** fix for typeCheck: 'strict' ([7560f57](https://github.com/frankwallis/plugin-typescript/commit/7560f57)) 212 | 213 | 214 | 215 | 216 | ## [4.0.4](https://github.com/frankwallis/plugin-typescript/compare/4.0.2...4.0.4) (2016-03-27) 217 | 218 | ### Bug Fixes 219 | 220 | * **hot-reload:** add relativeTo setting for chokidar ([6c6fd1c](https://github.com/frankwallis/plugin-typescript/commit/6c6fd1c)) 221 | * **html-import:** fix for importing html with module: 'es6' ([7455a00](https://github.com/frankwallis/plugin-typescript/commit/7455a00)) 222 | 223 | 224 | 225 | 226 | ## [4.0.2](https://github.com/frankwallis/plugin-typescript/compare/4.0.1...4.0.2) (2016-03-02) 227 | 228 | 229 | ### Bug Fixes 230 | 231 | * **angular2:** fix the clear button ([72bd341](https://github.com/frankwallis/plugin-typescript/commit/72bd341)) 232 | * **errors:** improve error reporting when files are missing ([5d03379](https://github.com/frankwallis/plugin-typescript/commit/5d03379)) 233 | 234 | 235 | ### Features 236 | 237 | * **angular2:** improve angular2 example ([e1047f6](https://github.com/frankwallis/plugin-typescript/commit/e1047f6)) 238 | 239 | 240 | 241 | 242 | ## [4.0.1](https://github.com/frankwallis/plugin-typescript/compare/4.0.0...4.0.1) (2016-02-22) 243 | 244 | ### Features 245 | 246 | * **typings:** enable typings to be specified with filename of bundle ([0d99c42](https://github.com/frankwallis/plugin-typescript/commit/0d99c42)) 247 | * **typings:** get typings configuration from meta ([b055f46](https://github.com/frankwallis/plugin-typescript/commit/b055f46)) 248 | 249 | 250 | 251 | 252 | ## [3.0.3](https://github.com/frankwallis/plugin-typescript/compare/3.0.2...3.0.3) (2016-02-14) 253 | 254 | 255 | ### Features 256 | 257 | * **typingsMap:** add typingsMap option ([e843a48](https://github.com/frankwallis/plugin-typescript/commit/e843a48)) 258 | * **typingsMap:** enable type-checking in angular2 example ([4334271](https://github.com/frankwallis/plugin-typescript/commit/4334271)) 259 | 260 | 261 | 262 | 263 | ## [3.0.2](https://github.com/frankwallis/plugin-typescript/compare/3.0.1...3.0.2) (2016-02-08) 264 | 265 | 266 | ### Bug Fixes 267 | 268 | * **bundling:** revert rollup support change ([57c0250](https://github.com/frankwallis/plugin-typescript/commit/57c0250)) 269 | 270 | 271 | 272 | 273 | ## [3.0.1](https://github.com/frankwallis/plugin-typescript/compare/2.6.0...3.0.1) (2016-02-06) 274 | 275 | 276 | ### Bug Fixes 277 | 278 | * **transpile:** override noEmit option in tsconfig ([921a829](https://github.com/frankwallis/plugin-typescript/commit/921a829)) 279 | 280 | ### Features 281 | 282 | * **rollup:** output es6 when bundling ([c81dd2d](https://github.com/frankwallis/plugin-typescript/commit/c81dd2d)) 283 | 284 | 285 | 286 | 287 | # [2.6.0](https://github.com/frankwallis/plugin-typescript/compare/2.5.11...2.6.0) (2016-02-04) 288 | 289 | 290 | ### Bug Fixes 291 | 292 | * **sourceMap:** set metadata.sourceMap as object not string ([9563d72](https://github.com/frankwallis/plugin-typescript/commit/9563d72)) 293 | 294 | 295 | 296 | 297 | ## [2.5.11](https://github.com/frankwallis/plugin-typescript/compare/2.5.10...2.5.11) (2016-02-04) 298 | 299 | 300 | ### Features 301 | 302 | * **targetLib:** add the targetLib option to use lib.d.ts ([22cf0d8](https://github.com/frankwallis/plugin-typescript/commit/22cf0d8)) 303 | 304 | 305 | 306 | 307 | ## [2.5.10](https://github.com/frankwallis/plugin-typescript/compare/2.5.8...2.5.10) (2016-02-03) 308 | 309 | 310 | ### Bug Fixes 311 | 312 | * **bundling:** switch to using System.import instead of metadata.deps ([671ad1e](https://github.com/frankwallis/plugin-typescript/commit/671ad1e)) 313 | * **transpile:** add new 'suppressOutputPathCheck' option when transpiling ([d2158e0](https://github.com/frankwallis/plugin-typescript/commit/d2158e0)) 314 | 315 | 316 | 317 | 318 | ## [2.5.8](https://github.com/frankwallis/plugin-typescript/compare/2.5.3...2.5.8) (2016-01-31) 319 | 320 | 321 | ### Bug Fixes 322 | 323 | * **source-maps:** undo previous change to fix source maps ([9a8937f](https://github.com/frankwallis/plugin-typescript/commit/9a8937f)) 324 | * **js-transpile:** redirect transpiler output to prevent 'cannot overwrite existing file' error in typescript-1.8.0-beta ([6a02fe5](https://github.com/frankwallis/plugin-typescript/commit/6a02fe5)) 325 | * **windows:** fix tests on windows ([9183e0d](https://github.com/frankwallis/plugin-typescript/commit/9183e0d)) 326 | 327 | 328 | 329 | 330 | ## [2.5.3](https://github.com/frankwallis/plugin-typescript/compare/2.5.1...2.5.3) (2016-01-26) 331 | 332 | 333 | ### Bug Fixes 334 | 335 | * **example:** add workaround for module detection issue ([8743a79](https://github.com/frankwallis/plugin-typescript/commit/8743a79)) 336 | * **references:** fix to suppress type errors from reference files without references ([2dc7b8a](https://github.com/frankwallis/plugin-typescript/commit/2dc7b8a)) 337 | 338 | 339 | ### Features 340 | 341 | * **hot-reload:** add support for hot-reloading css in examples ([8ecbf6b](https://github.com/frankwallis/plugin-typescript/commit/8ecbf6b)) 342 | * **jspm-0.17:** fix the bundle, rename bundle -> build ([28b8ccf](https://github.com/frankwallis/plugin-typescript/commit/28b8ccf)) 343 | * **jspm-0.17:** update angular2 project (zonejs issue in browser) ([bffdf6e](https://github.com/frankwallis/plugin-typescript/commit/bffdf6e)) 344 | * **jspm-0.17:** update readme ([0ded2dc](https://github.com/frankwallis/plugin-typescript/commit/0ded2dc)) 345 | * **jspm-0.17:** upgrade react and angular packages ([679a06e](https://github.com/frankwallis/plugin-typescript/commit/679a06e)) 346 | * **jspm-0.17:** use plugin-typescript as default transpiler ([edd5b6c](https://github.com/frankwallis/plugin-typescript/commit/edd5b6c)) 347 | * **npm:** exclude files from npm ([5fb8a43](https://github.com/frankwallis/plugin-typescript/commit/5fb8a43)) 348 | 349 | 350 | 351 | 352 | ## [2.5.1](https://github.com/frankwallis/plugin-typescript/compare/2.5.0...2.5.1) (2016-01-23) 353 | 354 | 355 | ### Bug Fixes 356 | 357 | * **example:** fix react example ([17e4dc0](https://github.com/frankwallis/plugin-typescript/commit/17e4dc0)) 358 | * **hot-reload:** re-check files when dependents change ([33e7505](https://github.com/frankwallis/plugin-typescript/commit/33e7505)) 359 | 360 | 361 | 362 | 363 | # [2.5.0](https://github.com/frankwallis/plugin-typescript/compare/2.4.9...2.5.0) (2016-01-23) 364 | 365 | 366 | ### Features 367 | 368 | * **hot-reload:** support hot-reloading ([95fd23e](https://github.com/frankwallis/plugin-typescript/commit/95fd23e)) 369 | * **warnings:** add a warning if output format is not system.register ([8282b3c](https://github.com/frankwallis/plugin-typescript/commit/8282b3c)) 370 | 371 | 372 | 373 | 374 | ## [2.4.9](https://github.com/frankwallis/plugin-typescript/compare/2.4.8...2.4.9) (2016-01-20) 375 | 376 | 377 | ### Bug Fixes 378 | 379 | * **bundling:** fix for babel bundling ([2ae35c3](https://github.com/frankwallis/plugin-typescript/commit/2ae35c3)) 380 | 381 | 382 | 383 | 384 | ## [2.4.8](https://github.com/frankwallis/plugin-typescript/compare/2.4.7...2.4.8) (2016-01-20) 385 | 386 | 387 | ### Bug Fixes 388 | 389 | * **bundling:** workaround for resolution errors when bundling, switch to system.register format ([467cada](https://github.com/frankwallis/plugin-typescript/commit/467cada)) 390 | 391 | 392 | 393 | 394 | ## [2.4.7](https://github.com/frankwallis/plugin-typescript/compare/2.4.6...2.4.7) (2016-01-16) 395 | 396 | 397 | ### Bug Fixes 398 | 399 | * **source-maps:** fix for source-maps not working ([d628f2a](https://github.com/frankwallis/plugin-typescript/commit/d628f2a)) 400 | * **tests:** fix paths issue when running tests on windows ([396adbc](https://github.com/frankwallis/plugin-typescript/commit/396adbc)) 401 | 402 | 403 | 404 | 405 | ## [2.4.6](https://github.com/frankwallis/plugin-typescript/compare/2.4.5...2.4.6) (2016-01-09) 406 | 407 | 408 | ### Bug Fixes 409 | 410 | * **translate:** translate should return load.source instead of load, closes [#81](https://github.com/frankwallis/plugin-typescript/issues/81) ([ff32996](https://github.com/frankwallis/plugin-typescript/commit/ff32996)) 411 | * **typings:** fix for non-relative typings path, closes [#80](https://github.com/frankwallis/plugin-typescript/issues/80) ([dca6aca](https://github.com/frankwallis/plugin-typescript/commit/dca6aca)) 412 | 413 | 414 | 415 | 416 | ## [2.4.5](https://github.com/frankwallis/plugin-typescript/compare/2.4.4...2.4.5) (2016-01-02) 417 | 418 | 419 | ### Bug Fixes 420 | 421 | * **moduleResolution:** force module resolution into classic mode, bump 2.4.5 ([c3b71bf](https://github.com/frankwallis/plugin-typescript/commit/c3b71bf)) 422 | 423 | 424 | 425 | 426 | ## [2.4.4](https://github.com/frankwallis/plugin-typescript/compare/2.4.3...2.4.4) (2015-12-23) 427 | 428 | 429 | ### Bug Fixes 430 | 431 | * **noEmitOnErrors:** fix for transpiler not reporting/overriding options which are invalid with isolatedModules, closes [#75](https://github.com/frankwallis/plugin-typescript/issues/75), bump 2.4.4 ([c95c40f](https://github.com/frankwallis/plugin-typescript/commit/c95c40f)) 432 | 433 | 434 | 435 | 436 | ## [2.4.3](https://github.com/frankwallis/plugin-typescript/compare/2.4.2...2.4.3) (2015-12-12) 437 | 438 | 439 | ### Bug Fixes 440 | 441 | * **source-maps:** fix for source-maps not work due to previous change ([f3f4d21](https://github.com/frankwallis/plugin-typescript/commit/f3f4d21)) 442 | 443 | 444 | 445 | 446 | ## [2.4.2](https://github.com/frankwallis/plugin-typescript/compare/2.4.1...2.4.2) (2015-12-10) 447 | 448 | 449 | ### Bug Fixes 450 | 451 | * **parse-error:** fix for parse error when source map undefined ([2eb92c0](https://github.com/frankwallis/plugin-typescript/commit/2eb92c0)) 452 | 453 | 454 | 455 | 456 | ## [2.4.1](https://github.com/frankwallis/plugin-typescript/compare/2.4.0...2.4.1) (2015-12-10) 457 | 458 | 459 | ### Bug Fixes 460 | 461 | * **IE10-Map:** remove references to map, bump 2.4.1, closes [#70](https://github.com/frankwallis/plugin-typescript/issues/70) ([59df643](https://github.com/frankwallis/plugin-typescript/commit/59df643)) 462 | 463 | 464 | 465 | 466 | # [2.4.0](https://github.com/frankwallis/plugin-typescript/compare/2.3.2...2.4.0) (2015-12-05) 467 | 468 | 469 | ### Bug Fixes 470 | 471 | * **module:** support output of js in module formats other than 'system' (e.g. 'es6' piped to babel), bump 2.4.0 ([f2a6554](https://github.com/frankwallis/plugin-typescript/commit/f2a6554)) 472 | 473 | 474 | 475 | 476 | ## [2.3.2](https://github.com/frankwallis/plugin-typescript/compare/2.3.0...2.3.2) (2015-12-01) 477 | 478 | 479 | ### Bug Fixes 480 | 481 | * **__moduleName:** don't emit __moduleName in build mode ([1cee03a](https://github.com/frankwallis/plugin-typescript/commit/1cee03a)) 482 | * **strict-mode:** fail the build when typeCheck errors in strict mode ([14141ab](https://github.com/frankwallis/plugin-typescript/commit/14141ab)) 483 | 484 | 485 | 486 | 487 | # [2.3.0](https://github.com/frankwallis/plugin-typescript/compare/2.2.3...2.3.0) (2015-12-01) 488 | 489 | 490 | 491 | 492 | ## [2.2.3](https://github.com/frankwallis/plugin-typescript/compare/2.2.2...2.2.3) (2015-11-29) 493 | 494 | 495 | ### Bug Fixes 496 | 497 | * **Object.assign:** remove usage of Object.assign, closes [#61](https://github.com/frankwallis/plugin-typescript/issues/61) ([7ee0da7](https://github.com/frankwallis/plugin-typescript/commit/7ee0da7)) 498 | 499 | 500 | 501 | 502 | ## [2.2.2](https://github.com/frankwallis/plugin-typescript/compare/2.2.0...2.2.2) (2015-11-15) 503 | 504 | 505 | ### Features 506 | 507 | * **typings:** support loading typings from package.son (resolveTypings: true) ([519baa1](https://github.com/frankwallis/plugin-typescript/commit/519baa1)) 508 | 509 | 510 | 511 | 512 | # [2.2.0](https://github.com/frankwallis/plugin-typescript/compare/2.1.6...2.2.0) (2015-11-04) 513 | 514 | 515 | ### Bug Fixes 516 | 517 | * **extensions:** sanitize extensions ([b3c1fc5](https://github.com/frankwallis/plugin-typescript/commit/b3c1fc5)) 518 | * **resolution:** fix for json file resolution ([f642d49](https://github.com/frankwallis/plugin-typescript/commit/f642d49)) 519 | 520 | 521 | ### Features 522 | 523 | * **no-lib:** observe no-lib option ([591dca4](https://github.com/frankwallis/plugin-typescript/commit/591dca4)) 524 | * **no-lib-check:** use the built in skipDefaultLibCheck compiler option ([1d2d09d](https://github.com/frankwallis/plugin-typescript/commit/1d2d09d)) 525 | 526 | 527 | 528 | 529 | ## [2.1.6](https://github.com/frankwallis/plugin-typescript/compare/2.1.5...2.1.6) (2015-11-03) 530 | 531 | 532 | ### Bug Fixes 533 | 534 | * **module:** fix for __moduleName reference error ([7d8b545](https://github.com/frankwallis/plugin-typescript/commit/7d8b545)) 535 | * **source-maps:** fix for source maps ([dcd2a3f](https://github.com/frankwallis/plugin-typescript/commit/dcd2a3f)) 536 | * **tsconfig:** fix for error when declaration files present but typeCheck false, bump 2.1.6 ([c92c0c1](https://github.com/frankwallis/plugin-typescript/commit/c92c0c1)) 537 | 538 | 539 | ### Features 540 | 541 | * **0.17:** convert source to typescript and precompile ([2310fbd](https://github.com/frankwallis/plugin-typescript/commit/2310fbd)) 542 | * **0.17:** target es5 but use lib.es6.d.ts, strip comments ([800f702](https://github.com/frankwallis/plugin-typescript/commit/800f702)) 543 | * **examples:** use jspm.Builder instead of systemjs-builder ([d1e064d](https://github.com/frankwallis/plugin-typescript/commit/d1e064d)) 544 | 545 | 546 | 547 | 548 | ## [2.1.5](https://github.com/frankwallis/plugin-typescript/compare/2.1.4...2.1.5) (2015-11-01) 549 | 550 | 551 | ### Bug Fixes 552 | 553 | * **example:** fix angular2 config ([b3a56dd](https://github.com/frankwallis/plugin-typescript/commit/b3a56dd)) 554 | * **logger:** fix for typo in logger, bump 2.1.5 ([de4e46b](https://github.com/frankwallis/plugin-typescript/commit/de4e46b)) 555 | 556 | 557 | 558 | 559 | ## [2.1.4](https://github.com/frankwallis/plugin-typescript/compare/2.1.3...2.1.4) (2015-10-26) 560 | 561 | 562 | ### Features 563 | 564 | * **linked-errors:** link errors to location in source file, bump 2.1.4 ([aeabfa9](https://github.com/frankwallis/plugin-typescript/commit/aeabfa9)) 565 | 566 | 567 | 568 | 569 | ## [2.1.3](https://github.com/frankwallis/plugin-typescript/compare/2.1.2...2.1.3) (2015-10-26) 570 | 571 | 572 | ### Bug Fixes 573 | 574 | * **strict:** fix bug in strict mode, bump 2.1.3 ([e36836c](https://github.com/frankwallis/plugin-typescript/commit/e36836c)) 575 | 576 | 577 | 578 | 579 | ## [2.1.2](https://github.com/frankwallis/plugin-typescript/compare/2.1.1...2.1.2) (2015-10-21) 580 | 581 | 582 | ### Bug Fixes 583 | 584 | * **config:** fix for config parsing [#47](https://github.com/frankwallis/plugin-typescript/issues/47) ([0f9e78a](https://github.com/frankwallis/plugin-typescript/commit/0f9e78a)) 585 | * **typescript@1.7:** add support for typescript 1.7 nightly build ([05bfa62](https://github.com/frankwallis/plugin-typescript/commit/05bfa62)) 586 | 587 | 588 | 589 | 590 | # [2.1.0](https://github.com/frankwallis/plugin-typescript/compare/2.0.17...2.1.0) (2015-10-14) 591 | 592 | 593 | ### Features 594 | 595 | * **strict:** add a strict mode which fails the build on type-check errors ([673f416](https://github.com/frankwallis/plugin-typescript/commit/673f416)) 596 | * **tsconfig:** load compiler options from tsconfig.json ([70c10bf](https://github.com/frankwallis/plugin-typescript/commit/70c10bf)) 597 | * **tsconfig:** load declaration files from tsconfig.json ([2760c34](https://github.com/frankwallis/plugin-typescript/commit/2760c34)) 598 | * **tsconfig:** use tsconfig in examples ([5ad7e45](https://github.com/frankwallis/plugin-typescript/commit/5ad7e45)) 599 | 600 | 601 | 602 | 603 | ## [2.0.17](https://github.com/frankwallis/plugin-typescript/compare/2.0.11...2.0.17) (2015-09-19) 604 | 605 | 606 | ### Bug Fixes 607 | 608 | * **bundling:** fix for type-checking error when bundling with systemjs-builder[@0](https://github.com/0).14, bump 2.0.17 ([c33811e](https://github.com/frankwallis/plugin-typescript/commit/c33811e)) 609 | * **transpiler:** fix for incorrect return type from resolveModuleNames, bump 2.0.16 ([07e7162](https://github.com/frankwallis/plugin-typescript/commit/07e7162)) 610 | * **type-checker:** put back unneeded code, bump 2.0.15 ([e2da77d](https://github.com/frankwallis/plugin-typescript/commit/e2da77d)) 611 | * **incremental-build:** fix the flow task ([916c38b](https://github.com/frankwallis/plugin-typescript/commit/916c38b)) 612 | 613 | 614 | 615 | 616 | ## [2.0.11](https://github.com/frankwallis/plugin-typescript/compare/2.0.10...2.0.11) (2015-09-01) 617 | 618 | 619 | ### Features 620 | 621 | * **host-resolution:** sanitisation of tsx.ts -> tsx is no longer needed ([9c6c01f](https://github.com/frankwallis/plugin-typescript/commit/9c6c01f)) 622 | * **multiple-packages:** support type-checking over multiple packages ([a702177](https://github.com/frankwallis/plugin-typescript/commit/a702177)) 623 | 624 | 625 | 626 | 627 | ## [2.0.10](https://github.com/frankwallis/plugin-typescript/compare/2.0.9...2.0.10) (2015-08-31) 628 | 629 | 630 | ### Features 631 | 632 | * **angular2:** try out ng-model ([6cc6802](https://github.com/frankwallis/plugin-typescript/commit/6cc6802)) 633 | * **external-modules:** import example-service from external package ([490a1f9](https://github.com/frankwallis/plugin-typescript/commit/490a1f9)) 634 | * **html-templates:** add support for importing .html files as strings without type-check errors, bump 2.0.10 ([0d138e2](https://github.com/frankwallis/plugin-typescript/commit/0d138e2)) 635 | 636 | 637 | 638 | 639 | ## [2.0.9](https://github.com/frankwallis/plugin-typescript/compare/2.0.8...2.0.9) (2015-08-27) 640 | 641 | 642 | ### Features 643 | 644 | * **react:** add support for tsx files ([773f75a](https://github.com/frankwallis/plugin-typescript/commit/773f75a)) 645 | * **react:** allow import a from "file.tsx", bump 2.0.9 ([1e46a2b](https://github.com/frankwallis/plugin-typescript/commit/1e46a2b)) 646 | 647 | 648 | 649 | 650 | ## [2.0.8](https://github.com/frankwallis/plugin-typescript/compare/2.0.7...2.0.8) (2015-08-27) 651 | 652 | 653 | ### Bug Fixes 654 | 655 | * **example:** fix the example project bundling ([fa80ac1](https://github.com/frankwallis/plugin-typescript/commit/fa80ac1)) 656 | 657 | 658 | ### Features 659 | 660 | * **react:** add angular1 example back again ([fda0002](https://github.com/frankwallis/plugin-typescript/commit/fda0002)) 661 | * **react:** add react example ([eec3ce4](https://github.com/frankwallis/plugin-typescript/commit/eec3ce4)) 662 | * **react:** move angular2 example to subfolder ([408975d](https://github.com/frankwallis/plugin-typescript/commit/408975d)) 663 | * **react:** support the jsx configuration option, bump 2.0.8 ([e51793d](https://github.com/frankwallis/plugin-typescript/commit/e51793d)) 664 | 665 | 666 | 667 | 668 | ## [2.0.7](https://github.com/frankwallis/plugin-typescript/compare/2.0.0...2.0.7) (2015-08-24) 669 | 670 | 671 | ### Bug Fixes 672 | 673 | * **source-maps:** fix source-maps, bump 2.0.6 ([a74c768](https://github.com/frankwallis/plugin-typescript/commit/a74c768)) 674 | * **es3:** add support for target="es3" ([d899a97](https://github.com/frankwallis/plugin-typescript/commit/d899a97)) 675 | * **example:** add correct jspm version to devDependencies ([df46c9a](https://github.com/frankwallis/plugin-typescript/commit/df46c9a)) 676 | * **typescriptOptions:** fix for undefined error when typescriptOptions not specified ([d0f24bb](https://github.com/frankwallis/plugin-typescript/commit/d0f24bb)) 677 | * **bundling:** fix for bundling error ([f4d945e](https://github.com/frankwallis/plugin-typescript/commit/f4d945e)) 678 | 679 | 680 | 681 | 682 | # [2.0.0](https://github.com/frankwallis/plugin-typescript/compare/2.0.0-beta...2.0.0) (2015-07-02) 683 | 684 | 685 | ### Bug Fixes 686 | 687 | * **performance:** don't type-check the default lib for better performance ([1c093c8](https://github.com/frankwallis/plugin-typescript/commit/1c093c8)) 688 | * **deps:** fix to use anonymous modules ([475a4ea](https://github.com/frankwallis/plugin-typescript/commit/475a4ea)) 689 | * **reference-errors:** trap compiler errors in reference files ([b5b8066](https://github.com/frankwallis/plugin-typescript/commit/b5b8066)) 690 | * **module-name:** set __moduleName variable ([848c475](https://github.com/frankwallis/plugin-typescript/commit/848c475)) 691 | 692 | 693 | ### Features 694 | 695 | * **transpile:** working transpile ([df0354c](https://github.com/frankwallis/plugin-typescript/commit/df0354c)) 696 | * **transpiler:** error on syntax error ([a75c497](https://github.com/frankwallis/plugin-typescript/commit/a75c497)) 697 | * **type-check:** implement type-checking ([ec0fa6d](https://github.com/frankwallis/plugin-typescript/commit/ec0fa6d)) 698 | 699 | 700 | 701 | 702 | ## [1.0.5](https://github.com/frankwallis/plugin-typescript/compare/1.0.4...1.0.5) (2015-06-08) 703 | 704 | 705 | ### Features 706 | 707 | * **es6:** enable setting of target output via options ([2ee7380](https://github.com/frankwallis/plugin-typescript/commit/2ee7380)) 708 | * **inject:** add index-inject.html ([71a2216](https://github.com/frankwallis/plugin-typescript/commit/71a2216)) 709 | * **resolveAmbientRefs:** add option "resolveAmbientRefs" to disable systems resolution of ambient reference files, default is true ([7c9f531](https://github.com/frankwallis/plugin-typescript/commit/7c9f531)) 710 | 711 | 712 | 713 | 714 | ## [1.0.4](https://github.com/frankwallis/plugin-typescript/compare/1.0.0...1.0.4) (2015-05-19) 715 | 716 | 717 | ### Bug Fixes 718 | 719 | * **inject:** enable using bundles created with jspm bundle --inject, fixes [#19](https://github.com/frankwallis/plugin-typescript/issues/19) ([dfc8e5d](https://github.com/frankwallis/plugin-typescript/commit/dfc8e5d)) 720 | * **import-css:** bundling issue when css import present, fixes [#19](https://github.com/frankwallis/plugin-typescript/issues/19) ([ecc42a3](https://github.com/frankwallis/plugin-typescript/commit/ecc42a3)) 721 | * **import-js:** fix to enable importing javascript files and for strange compiler bug ([93387eb](https://github.com/frankwallis/plugin-typescript/commit/93387eb)) 722 | 723 | 724 | 725 | 726 | # [1.0.0](https://github.com/frankwallis/plugin-typescript/compare/0.6.7...1.0.0) (2015-04-20) 727 | 728 | 729 | ### Features 730 | 731 | * **es6:** update the example project to use Map ([3e11374](https://github.com/frankwallis/plugin-typescript/commit/3e11374)) 732 | * **es6:** use lib.es6.d.ts to enable Symbol ([76f0928](https://github.com/frankwallis/plugin-typescript/commit/76f0928)) 733 | 734 | 735 | 736 | 737 | ## [0.6.7](https://github.com/frankwallis/plugin-typescript/compare/0.6.4...0.6.7) (2015-04-09) 738 | 739 | 740 | ### Bug Fixes 741 | 742 | * **export-import:** export import no longer available ([e20930c](https://github.com/frankwallis/plugin-typescript/commit/e20930c)) 743 | * **ts-15:** add tests for export import ([3f8174e](https://github.com/frankwallis/plugin-typescript/commit/3f8174e)) 744 | * **ts-15:** rename Filename -> FileName ([38f11c4](https://github.com/frankwallis/plugin-typescript/commit/38f11c4)) 745 | 746 | 747 | 748 | 749 | ## [0.6.4](https://github.com/frankwallis/plugin-typescript/compare/0.6.3...0.6.4) (2015-04-02) 750 | 751 | 752 | ### Bug Fixes 753 | 754 | * **deps:** pin typescript at 1.4.1 ([84fe362](https://github.com/frankwallis/plugin-typescript/commit/84fe362)) 755 | * **bundling:** fix the bundling example ([d1e95b4](https://github.com/frankwallis/plugin-typescript/commit/d1e95b4)) 756 | 757 | 758 | ### Features 759 | 760 | * **jspm-0.15:** update to jspm 0.15 ([92efd81](https://github.com/frankwallis/plugin-typescript/commit/92efd81)) 761 | * **options:** add support for "typescriptOptions" ([a7a53f2](https://github.com/frankwallis/plugin-typescript/commit/a7a53f2)) 762 | 763 | 764 | 765 | 766 | ## [0.6.2](https://github.com/frankwallis/plugin-typescript/compare/0.6.1...0.6.2) (2015-03-26) 767 | 768 | 769 | ### Bug Fixes 770 | 771 | * **ambient-refs:** ensure that the ambient references are resolved to the same file ([693fa53](https://github.com/frankwallis/plugin-typescript/commit/693fa53)) 772 | * **bundling:** change the registry from nom -> jspm ([3aae941](https://github.com/frankwallis/plugin-typescript/commit/3aae941)) 773 | * **bundling:** update to systemjs-builder 0.10.0 and fix the bundle task ([7467a61](https://github.com/frankwallis/plugin-typescript/commit/7467a61)) 774 | * **lib.d.ts:** improve performance by tagging lib.d.ts correctly ([e382d99](https://github.com/frankwallis/plugin-typescript/commit/e382d99)) 775 | 776 | 777 | 778 | 779 | ## [0.6.1](https://github.com/frankwallis/plugin-typescript/compare/0.5.10...0.6.1) (2015-03-24) 780 | 781 | 782 | ### Bug Fixes 783 | 784 | * **lib.d.ts:** put in workaround for __moduleName not set correctly with traceur 0.0.84 ([32a3d60](https://github.com/frankwallis/plugin-typescript/commit/32a3d60)) 785 | * **lib.d.ts:** yet another fix for lib.d.ts resolution ([af9d9d9](https://github.com/frankwallis/plugin-typescript/commit/af9d9d9)) 786 | * **reference-errors:** fix for issue where errors in reference files were not picked up ([950b2dc](https://github.com/frankwallis/plugin-typescript/commit/950b2dc)) 787 | * **references:** add tests for ambient references ([c162d8a](https://github.com/frankwallis/plugin-typescript/commit/c162d8a)) 788 | * **references:** add tests for circular references and reference file type errors ([22cbf3b](https://github.com/frankwallis/plugin-typescript/commit/22cbf3b)) 789 | 790 | 791 | ### Features 792 | 793 | * **ambient-references:** add proper support for ambient references ([8af5cca](https://github.com/frankwallis/plugin-typescript/commit/8af5cca)) 794 | 795 | 796 | 797 | 798 | ## [0.5.10](https://github.com/frankwallis/plugin-typescript/compare/0.5.7...0.5.10) (2015-02-22) 799 | 800 | 801 | ### Bug Fixes 802 | 803 | * **dependencies:** add the jspm dependencies back in and bump 0.5.9 ([3cbf1e6](https://github.com/frankwallis/plugin-typescript/commit/3cbf1e6)) 804 | * **example:** swap http-server for live-server (high cpu) ([b6bbf3f](https://github.com/frankwallis/plugin-typescript/commit/b6bbf3f)) 805 | * **nested-types:** add fix for nested type errors issue ([fa152c1](https://github.com/frankwallis/plugin-typescript/commit/fa152c1)) 806 | * **nested-types:** bump 0.5.10 ([02fe3e9](https://github.com/frankwallis/plugin-typescript/commit/02fe3e9)) 807 | * **dependencies:** fix the development dependencies & tests ([809352e](https://github.com/frankwallis/plugin-typescript/commit/809352e)) 808 | 809 | 810 | ### Features 811 | 812 | * **example:** open the example project automatcally ([2b108c7](https://github.com/frankwallis/plugin-typescript/commit/2b108c7)) 813 | * **travis-ci:** add the travis configuration ([a79978f](https://github.com/frankwallis/plugin-typescript/commit/a79978f)) 814 | 815 | 816 | 817 | 818 | ## [0.5.7](https://github.com/frankwallis/plugin-typescript/compare/0.5.5...0.5.7) (2015-02-06) 819 | 820 | 821 | ### Features 822 | 823 | * **default-lib:** resolve the default lib properly ([789f616](https://github.com/frankwallis/plugin-typescript/commit/789f616)) 824 | * **es6:** restructure and es6ify ([ecb6a6f](https://github.com/frankwallis/plugin-typescript/commit/ecb6a6f)) 825 | * **integration:** configure the example project ([ef08576](https://github.com/frankwallis/plugin-typescript/commit/ef08576)) 826 | * **language-service:** working build with language service ([13ab811](https://github.com/frankwallis/plugin-typescript/commit/13ab811)) 827 | * **language-services:** Compile with language services ([14809bf](https://github.com/frankwallis/plugin-typescript/commit/14809bf)) 828 | * **plugin:** get the example project/plugin working ([6213f36](https://github.com/frankwallis/plugin-typescript/commit/6213f36)) 829 | * **publish:** reduce logging ([ba47c5a](https://github.com/frankwallis/plugin-typescript/commit/ba47c5a)) 830 | * **source-maps:** get the source maps working ([4705ac8](https://github.com/frankwallis/plugin-typescript/commit/4705ac8)) 831 | 832 | 833 | 834 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Frank Wallis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | plugin-typescript 2 | ============================ 3 | TypeScript loader for SystemJS 4 | 5 | [![build status](https://secure.travis-ci.org/frankwallis/plugin-typescript.png?branch=master)](http://travis-ci.org/frankwallis/plugin-typescript) 6 | 7 | ## Overview ## 8 | 9 | A plugin for [SystemJS](https://github.com/systemjs/systemjs) which enables you to ```System.import``` TypeScript files directly. The files are transpiled in the browser and compilation errors written to the console. 10 | 11 | Starting with JSPM 0.17.0 (currently in beta) this plugin will be the officially supported mechanism for transpiling TypeScript. It provides the ability to transpile TypeScript and ES2015+ files on the fly when then are loaded by SystemJS. 12 | 13 | plugin-typescript supports TypeScript 2.0.0 and higher 14 | For TypeScript 1.8.1 use plugin-typescript 4.0.16 15 | For TypeScript 1.7.5 and below use plugin-typescript 2.x.x 16 | 17 | ## Installation ## 18 | 19 | #### JSPM #### 20 | 21 | Install plugin-typescript like this: 22 | 23 | ```sh 24 | jspm install ts 25 | ``` 26 | 27 | All the SystemJS configuration will be created automatically by JSPM. 28 | 29 | #### If you are using SystemJS without JSPM #### 30 | 31 | Add SystemJS map configuration for plugin-typescript and typescript: 32 | 33 | ```js 34 | SystemJS.config({ 35 | packages: { 36 | "ts": { 37 | "main": "lib/plugin.js" 38 | }, 39 | "typescript": { 40 | "main": "lib/typescript.js", 41 | "meta": { 42 | "lib/typescript.js": { 43 | "exports": "ts" 44 | } 45 | } 46 | } 47 | }, 48 | map: { 49 | "ts": "path/to/plugin-typescript", 50 | "typescript": "path/to/typescript" 51 | }, 52 | transpiler: 'ts' 53 | }); 54 | ``` 55 | 56 | ## Setup ## 57 | 58 | #### Make plugin-typescript the default transpiler for js and ts files #### 59 | 60 | ```js 61 | System.config({ 62 | transpiler: "ts", 63 | packages: { 64 | "app": { 65 | "defaultExtension": "ts", 66 | } 67 | } 68 | }); 69 | ``` 70 | 71 | This will tell SystemJS to transpile all modules (.js and .ts) using plugin-typescript. It is also possible to configure plugin-typescript to load specific files, using ```packages``` configuration 72 | 73 | ```js 74 | System.config({ 75 | transpiler: "babel", 76 | packages: { 77 | "src": { 78 | "defaultExtension": "ts", 79 | "meta": { 80 | "*.ts": { 81 | "loader": "ts" 82 | } 83 | } 84 | } 85 | } 86 | }); 87 | ``` 88 | 89 | This will cause all .ts files in the "src" package to be loaded through plugin-typescript. 90 | 91 | See the example projects contained within this repository for a working setup. 92 | 93 | ## Configuration ## 94 | 95 | Configuration settings can be passed to the compiler via "typescriptOptions": 96 | 97 | ```js 98 | System.config({ 99 | typescriptOptions: { 100 | module: "system", 101 | noImplicitAny: true, 102 | tsconfig: true // also accepts a path 103 | } 104 | }); 105 | ``` 106 | 107 | It is also possible to override the default configuration for specific files, using ```meta``` configuration: 108 | 109 | ```js 110 | System.config({ 111 | transpiler: "typescript", 112 | packages: { 113 | "src": { 114 | "defaultExtension": "ts", 115 | "meta": { 116 | "*.ts": { 117 | "typescriptOptions": { 118 | "noImplicitAny": true 119 | } 120 | } 121 | } 122 | } 123 | } 124 | }); 125 | ``` 126 | 127 | All the usual TypeScript compiler options are supported, as well as these additional ones: 128 | 129 | #### tsconfig #### 130 | 131 | A boolean flag which instructs the plugin to load configuration from "tsconfig.json". To override the location of the file set this option to the path of the configuration file, which will be resolved using normal SystemJS resolution. 132 | 133 | The file location will be resolved using normal SystemJS resolution, and compiler options which do not conflict with those required by plugin-typescript will be loaded from the ```compilerOptions``` section of the file. 134 | 135 | ## Features ## 136 | 137 | #### Hot-Reload support #### 138 | 139 | The example projects show how to use plugin-typescript in conjuntion with [systemjs-hot-reloader](https://github.com/capaj/systemjs-hot-reloader) 140 | 141 | #### Rollup support #### 142 | 143 | Rollup is supported when transpiling with ```module: "es6"```. It can help to reduce the size of your bundles by stripping out unused modules. For more information see [here](https://github.com/rollup/rollup) 144 | 145 | #### Link to source from transpiler errors #### 146 | 147 | When compiling in the browser, transpiler errors contain a link to the exact location of the error in the source. This is particularly helpful if you are using Chrome DevTools as your IDE. 148 | 149 | #### Override TypeScript version #### 150 | 151 | To override the version of TypeScript used by the plugin, add an override to the ```jspm``` section of your package.json 152 | 153 | ```json 154 | "devDependencies": { 155 | "css": "systemjs/plugin-css@0.1.10", 156 | "ts": "frankwallis/plugin-typescript@^7.0.5" 157 | }, 158 | "overrides": { 159 | "github:frankwallis/plugin-typescript@5.0.1": { 160 | "dependencies": { 161 | "typescript": "npm:typescript@2.3.0-dev.20170228" 162 | } 163 | } 164 | } 165 | ``` 166 | 167 | ## Examples ## 168 | 169 | To run the example projects: 170 | ``` 171 | > git clone https://github.com/frankwallis/plugin-typescript.git 172 | > cd plugin-typescript 173 | > npm install 174 | > cd examples/react // or examples/angular2 or examples/angular 175 | > jspm install 176 | > npm start 177 | ``` 178 | To bundle each example project: 179 | ``` 180 | > npm run build // or jspm build src build/build.js 181 | ``` 182 | -------------------------------------------------------------------------------- /examples/angular/index-bundle.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | plugin-typescript angular example 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/angular/index-inject.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | plugin-typescript angular example 12 | 13 | 14 | 15 | 16 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /examples/angular/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | plugin-typescript angular example 13 | 14 | 15 | 16 | 17 | 18 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /examples/angular/jspm.browser.js: -------------------------------------------------------------------------------- 1 | SystemJS.config({ 2 | baseURL: ".", 3 | paths: { 4 | "github:": "jspm_packages/github/", 5 | "npm:": "jspm_packages/npm/" 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /examples/angular/jspm.config.js: -------------------------------------------------------------------------------- 1 | SystemJS.config({ 2 | transpiler: "ts", 3 | typescriptOptions: { 4 | "module": "system", 5 | "noImplicitAny": false, 6 | "tsconfig": "src/another-tsconfig.json" 7 | }, 8 | packages: { 9 | "src": { 10 | "main": "index", 11 | "defaultExtension": "ts", 12 | "meta": { 13 | "*.css": { 14 | "loader": "css" 15 | }, 16 | "*.html": { 17 | "loader": "text" 18 | } 19 | } 20 | } 21 | } 22 | }); 23 | -------------------------------------------------------------------------------- /examples/angular/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "node ../tasks/start", 4 | "example": "node ../tasks/start", 5 | "build": "node ../tasks/build", 6 | "bundle": "node ../tasks/build" 7 | }, 8 | "jspm": { 9 | "registry": "github", 10 | "dependencies": { 11 | "@types/angular": "npm:@types/angular@^1.5.12", 12 | "@types/jquery": "npm:@types/jquery@^2.0.34", 13 | "angular": "angular/bower-angular@^1.5.8" 14 | }, 15 | "devDependencies": { 16 | "assert": "npm:jspm-nodelibs-assert@^0.2.0", 17 | "buffer": "npm:jspm-nodelibs-buffer@^0.2.0", 18 | "child_process": "npm:jspm-nodelibs-child_process@^0.2.0", 19 | "clean-css": "npm:clean-css@^3.4.3", 20 | "constants": "npm:jspm-nodelibs-constants@^0.2.0", 21 | "crypto": "npm:jspm-nodelibs-crypto@^0.2.0", 22 | "css": "systemjs/plugin-css@^0.1.32", 23 | "events": "npm:jspm-nodelibs-events@^0.2.0", 24 | "fs": "npm:jspm-nodelibs-fs@^0.2.0", 25 | "http": "npm:jspm-nodelibs-http@^0.2.0", 26 | "https": "npm:jspm-nodelibs-https@^0.2.0", 27 | "module": "npm:jspm-nodelibs-module@^0.2.0", 28 | "net": "npm:jspm-nodelibs-net@^0.2.0", 29 | "os": "npm:jspm-nodelibs-os@^0.2.0", 30 | "path": "npm:jspm-nodelibs-path@^0.2.0", 31 | "process": "npm:jspm-nodelibs-process@^0.2.0", 32 | "stream": "npm:jspm-nodelibs-stream@^0.2.0", 33 | "string_decoder": "npm:jspm-nodelibs-string_decoder@^0.2.0", 34 | "systemjs-hot-reloader": "alexisvincent/systemjs-hot-reloader@^1.0.0", 35 | "text": "systemjs/plugin-text@^0.0.8", 36 | "ts": "frankwallis/plugin-typescript@^7.0.2", 37 | "typescript": "npm:typescript@^2.0.0", 38 | "url": "npm:jspm-nodelibs-url@^0.2.0", 39 | "util": "npm:jspm-nodelibs-util@^0.2.0", 40 | "vm": "npm:jspm-nodelibs-vm@^0.2.0" 41 | }, 42 | "overrides": { 43 | "github:angular/bower-angular@1.6.2": { 44 | "main": "angular", 45 | "meta": { 46 | "angular.js": { 47 | "exports": "angular", 48 | "format": "global" 49 | } 50 | } 51 | }, 52 | "github:socketio/socket.io-client@1.7.2": { 53 | "main": "dist/socket.io.js" 54 | }, 55 | "npm:debug@2.6.1": { 56 | "main": "src/browser.js", 57 | "jspmNodeConversion": false, 58 | "format": "cjs", 59 | "map": { 60 | "./src/browser.js": { 61 | "node": "./src/node.js" 62 | }, 63 | "./node.js": { 64 | "browser": "./src/browser.js" 65 | }, 66 | "fs": "@node/fs", 67 | "net": "@node/net", 68 | "tty": "@node/tty", 69 | "util": "@node/util" 70 | } 71 | }, 72 | "npm:inherits@2.0.3": { 73 | "ignore": [ 74 | "test.js" 75 | ] 76 | }, 77 | "npm:ms@0.7.2": { 78 | "jspmNodeConversion": false, 79 | "format": "cjs" 80 | }, 81 | "npm:typescript@2.2.0": { 82 | "browser": {}, 83 | "map": { 84 | "buffer": "@empty", 85 | "child_process": "@empty", 86 | "fs": "@empty", 87 | "path": "@empty", 88 | "process": "@empty", 89 | "readline": "@empty" 90 | }, 91 | "dependencies": { 92 | "source-map-support": "*" 93 | } 94 | } 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /examples/angular/src/_references.d.ts: -------------------------------------------------------------------------------- 1 | declare var __moduleName; 2 | 3 | declare module "*.html" { 4 | var a: string; 5 | export default a; 6 | } 7 | -------------------------------------------------------------------------------- /examples/angular/src/another-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5" 4 | }, 5 | "files": [ 6 | "./index.ts", 7 | "./_references.d.ts" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /examples/angular/src/example-controller.ts: -------------------------------------------------------------------------------- 1 | import {IExampleService} from './example-types' 2 | 3 | export class ExampleController { 4 | 5 | public static $inject = ['exampleService']; 6 | 7 | constructor(private exampleService: IExampleService) { 8 | console.log('constructing ExampleController'); 9 | try { 10 | console.log('moduleName is ' + __moduleName); 11 | } 12 | catch (ex) {} 13 | } 14 | 15 | public name: string; 16 | public greeting: string; 17 | 18 | public greet() { 19 | console.log('greeting'); 20 | this.greeting = this.exampleService.greet(this.name); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/angular/src/example-service.ts: -------------------------------------------------------------------------------- 1 | import {IExampleService} from './example-types' 2 | 3 | export class ExampleService implements IExampleService { 4 | 5 | constructor() { 6 | this.cache = new Map(); 7 | 8 | //var a = Symbol(); 9 | } 10 | 11 | private cache: Map; 12 | 13 | greet(name: string): string { 14 | name = name || "clint"; // obligatory 15 | let greeting = this.cache[name] ? this.cache[name] : "Hello " + name; 16 | this.cache[name] = greeting; 17 | 18 | return greeting; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/angular/src/example-template.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |

{{cx.greeting}}

6 |
7 | -------------------------------------------------------------------------------- /examples/angular/src/example-types.ts: -------------------------------------------------------------------------------- 1 | export interface IExampleService { 2 | greet(name: string): string; 3 | } 4 | 5 | export enum Fruits { 6 | Apple, 7 | Banana, 8 | Cherry 9 | } 10 | -------------------------------------------------------------------------------- /examples/angular/src/index.css: -------------------------------------------------------------------------------- 1 | .greeting { 2 | font-family: comic-sans 3 | } 4 | 5 | button { 6 | text-transform: uppercase 7 | } 8 | -------------------------------------------------------------------------------- /examples/angular/src/index.ts: -------------------------------------------------------------------------------- 1 | import angular from 'angular'; 2 | import './index.css'; 3 | 4 | import exampleTemplate from './example-template.html'; 5 | import {ExampleService} from './example-service'; 6 | import {ExampleController} from './example-controller'; 7 | 8 | export var Module = angular.module("example", []); 9 | 10 | Module.service("exampleService", ExampleService); 11 | 12 | Module.component('exampleForm', { 13 | template: exampleTemplate, 14 | controller: ExampleController, 15 | controllerAs: 'cx' 16 | }); 17 | -------------------------------------------------------------------------------- /examples/angular/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "system" 5 | }, 6 | "files": [ 7 | "./src/index.ts", 8 | "./src/_references.d.ts" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /examples/angular2/index-bundle.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | plugin-typescript angular2 example 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/angular2/index-inject.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | plugin-typescript angular2 example 12 | 13 | 14 | 15 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /examples/angular2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | plugin-typescript angular2 example 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /examples/angular2/jspm.browser.js: -------------------------------------------------------------------------------- 1 | SystemJS.config({ 2 | baseURL: ".", 3 | paths: { 4 | "github:": "jspm_packages/github/", 5 | "npm:": "jspm_packages/npm/" 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /examples/angular2/jspm.config.js: -------------------------------------------------------------------------------- 1 | SystemJS.config({ 2 | transpiler: "ts", 3 | typescriptOptions: { 4 | "module": "system", 5 | "target": "es5", 6 | "tsconfig": true, 7 | "sourceMap": true 8 | }, 9 | packages: { 10 | "src": { 11 | "main": "index", 12 | "defaultExtension": "ts", 13 | "meta": { 14 | "*.css": { 15 | "loader": "css" 16 | }, 17 | "*.html": { 18 | "loader": "text" 19 | } 20 | } 21 | } 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /examples/angular2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "node ../tasks/start", 4 | "example": "node ../tasks/start", 5 | "build": "node ../tasks/build", 6 | "bundle": "node ../tasks/build" 7 | }, 8 | "jspm": { 9 | "registry": "github", 10 | "dependencies": { 11 | "@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@^4.0.0-rc.1", 12 | "reflect-metadata": "npm:reflect-metadata@^0.1.9" 13 | }, 14 | "devDependencies": { 15 | "buffer": "npm:jspm-nodelibs-buffer@^0.2.0", 16 | "child_process": "npm:jspm-nodelibs-child_process@^0.2.0", 17 | "clean-css": "npm:clean-css@^4.0.7", 18 | "constants": "npm:jspm-nodelibs-constants@^0.2.0", 19 | "css": "frankwallis/plugin-css@master", 20 | "http": "npm:jspm-nodelibs-http@^0.2.0", 21 | "https": "npm:jspm-nodelibs-https@^0.2.0", 22 | "module": "npm:jspm-nodelibs-module@^0.2.0", 23 | "net": "npm:jspm-nodelibs-net@^0.2.0", 24 | "os": "npm:jspm-nodelibs-os@^0.2.0", 25 | "path": "npm:jspm-nodelibs-path@^0.2.0", 26 | "readline": "npm:jspm-nodelibs-readline@^0.2.0", 27 | "stream": "npm:jspm-nodelibs-stream@^0.2.0", 28 | "string_decoder": "npm:jspm-nodelibs-string_decoder@^0.2.0", 29 | "systemjs-hot-reloader": "alexisvincent/systemjs-hot-reloader@^1.0.0", 30 | "text": "systemjs/plugin-text@^0.0.9", 31 | "ts": "frankwallis/plugin-typescript@^7.0.2", 32 | "typescript": "npm:typescript@^2.2.0", 33 | "url": "npm:jspm-nodelibs-url@^0.2.0", 34 | "util": "npm:jspm-nodelibs-util@^0.2.0" 35 | }, 36 | "peerDependencies": { 37 | "@angular/common": "npm:@angular/common@4.0.0-rc.1", 38 | "@angular/compiler": "npm:@angular/compiler@4.0.0-rc.1", 39 | "@angular/core": "npm:@angular/core@4.0.0-rc.1", 40 | "@angular/platform-browser": "npm:@angular/platform-browser@4.0.0-rc.1", 41 | "assert": "npm:jspm-nodelibs-assert@^0.2.0", 42 | "crypto": "npm:jspm-nodelibs-crypto@^0.2.0", 43 | "events": "npm:jspm-nodelibs-events@^0.2.0", 44 | "fs": "npm:jspm-nodelibs-fs@^0.2.0", 45 | "process": "npm:jspm-nodelibs-process@^0.2.0", 46 | "rxjs": "npm:rxjs@^5.0.1", 47 | "timers": "npm:jspm-nodelibs-timers@^0.2.0", 48 | "vm": "npm:jspm-nodelibs-vm@^0.2.0", 49 | "zone.js": "npm:zone.js@^0.7.2" 50 | }, 51 | "overrides": { 52 | "npm:inherits@2.0.3": { 53 | "ignore": [ 54 | "test.js" 55 | ] 56 | }, 57 | "npm:reflect-metadata@0.1.10": { 58 | "jspmNodeConversion": false, 59 | "map": { 60 | "crypto": { 61 | "node": "@node/crypto", 62 | "default": "@empty" 63 | } 64 | } 65 | }, 66 | "npm:typescript@2.2.1": { 67 | "browser": {}, 68 | "map": { 69 | "buffer": "@empty", 70 | "child_process": "@empty", 71 | "fs": "@empty", 72 | "path": "@empty", 73 | "process": "@empty", 74 | "readline": "@empty" 75 | }, 76 | "dependencies": { 77 | "source-map-support": "*" 78 | } 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /examples/angular2/shims.js: -------------------------------------------------------------------------------- 1 | import 'reflect-metadata' 2 | import 'zone.js' 3 | -------------------------------------------------------------------------------- /examples/angular2/src/_references.d.ts: -------------------------------------------------------------------------------- 1 | /* import all html files as stings */ 2 | declare module "*.html" { 3 | var __html__: string; 4 | export default __html__; 5 | } 6 | -------------------------------------------------------------------------------- /examples/angular2/src/calculator-component.ts: -------------------------------------------------------------------------------- 1 | import {Component} from '@angular/core'; 2 | import {CalculatorStore, CalculatorState} from "./calculator-store"; 3 | import calculatorTemplate from "./calculator-view.html"; 4 | 5 | @Component({ 6 | selector: 'calculator-component', 7 | template: calculatorTemplate 8 | }) 9 | export class CalculatorComponent { 10 | 11 | constructor(private calculatorStore: CalculatorStore) { 12 | console.log('constructing CalculatorComponent'); 13 | this.state = { 14 | total: 0.0, 15 | operand: 0.0 16 | }; 17 | var [x, y] = [1, 2]; 18 | } 19 | 20 | private state: CalculatorState; 21 | 22 | public get operand() { 23 | return this.state.operand; 24 | } 25 | 26 | public get total() { 27 | return this.state.total; 28 | } 29 | 30 | public async input(digit: number) { 31 | this.state = await this.calculatorStore.input(digit, this.state); 32 | } 33 | 34 | public async clear() { 35 | this.state = await this.calculatorStore.clear(this.state); 36 | } 37 | 38 | public async sum() { 39 | this.state = await this.calculatorStore.sum(this.state); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/angular2/src/calculator-store.ts: -------------------------------------------------------------------------------- 1 | export type CalculatorState = { 2 | total: number; 3 | operand: number; 4 | } 5 | 6 | export class CalculatorStore { 7 | constructor() { 8 | 9 | } 10 | 11 | public input(digit, state: CalculatorState): Promise { 12 | return Promise.resolve({ 13 | total: state.total, 14 | operand: (state.operand * 10) + digit 15 | }); 16 | } 17 | 18 | public sum(state: CalculatorState): Promise { 19 | return Promise.resolve({ 20 | total: state.total + state.operand, 21 | operand: 0.0 22 | }); 23 | } 24 | 25 | public clear(state: CalculatorState): Promise { 26 | return Promise.resolve({ 27 | total: 0.0, 28 | operand: 0.0 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/angular2/src/calculator-view.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • 3 | 4 | {{ operand }} 5 | 6 |
  • 7 |
  • 8 | 9 | {{ total }} 10 | 11 |
  • 12 |
  • 13 | 14 | 15 | 16 |
  • 17 |
  • 18 | 19 | 20 | 21 |
  • 22 |
  • 23 | 24 | 25 | 26 |
  • 27 |
  • 28 | 29 | 30 | 31 |
  • 32 |
-------------------------------------------------------------------------------- /examples/angular2/src/index.css: -------------------------------------------------------------------------------- 1 | .adder-container { 2 | font-size: 2rem; 3 | list-style: none; 4 | padding: 0; 5 | margin: 0; 6 | } 7 | 8 | .adder-row { 9 | display: flex; 10 | } 11 | 12 | .adder-display { 13 | box-sizing: border-box; 14 | border: solid 2px gray; 15 | border-radius: .2em; 16 | width: 6em; 17 | display: block; 18 | margin-bottom: .2em; 19 | padding: 2px; 20 | } 21 | 22 | .adder-button { 23 | font-size: 2rem; 24 | width: 2em; 25 | height: 2em; 26 | } 27 | 28 | .adder-button-clear { 29 | background: orangered; 30 | } 31 | 32 | .adder-button-sum { 33 | background: mediumseagreen; 34 | } 35 | 36 | .adder-button-digit { 37 | background: dodgerblue; 38 | } -------------------------------------------------------------------------------- /examples/angular2/src/index.ts: -------------------------------------------------------------------------------- 1 | import '../shims.js' 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' 3 | import { BrowserModule } from '@angular/platform-browser' 4 | import { NgModule } from '@angular/core' 5 | 6 | import { CalculatorStore } from './calculator-store' 7 | import { CalculatorComponent } from './calculator-component' 8 | import './index.css' 9 | 10 | @NgModule({ 11 | imports: [ BrowserModule ], 12 | declarations: [ CalculatorComponent ], 13 | bootstrap: [ CalculatorComponent ], 14 | providers: [ CalculatorStore ] 15 | }) 16 | class CalculatorApp { } 17 | 18 | platformBrowserDynamic().bootstrapModule(CalculatorApp) 19 | -------------------------------------------------------------------------------- /examples/angular2/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2015", 4 | "module": "commonjs", 5 | "emitDecoratorMetadata": true, 6 | "experimentalDecorators": true, 7 | "rootDir": ".", 8 | "baseUrl": ".", 9 | "paths": { 10 | "@angular/core": [ 11 | "jspm_packages/npm/@angular/core@2.0.0-rc.4" 12 | ], 13 | "@angular/platform-browser-dynamic": [ 14 | "jspm_packages/npm/@angular/platform-browser-dynamic@2.0.0-rc.4" 15 | ], 16 | "rxjs/*": [ 17 | "jspm_packages/npm/rxjs@5.0.0-beta.6/*" 18 | ] 19 | } 20 | }, 21 | "files": [ 22 | "./src/index.ts", 23 | "./src/_references.d.ts" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /examples/nodejs/generate.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return Math.floor(new Date().getTime() / 3456); 3 | } 4 | -------------------------------------------------------------------------------- /examples/nodejs/jspm.browser.js: -------------------------------------------------------------------------------- 1 | SystemJS.config({ 2 | paths: { 3 | "github:": "/jspm_packages/github/", 4 | "npm:": "/jspm_packages/npm/" 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /examples/nodejs/jspm.config.js: -------------------------------------------------------------------------------- 1 | SystemJS.config({ 2 | devConfig: { 3 | 'map': { 4 | 'ts': 'github:frankwallis/plugin-typescript@5.2.7', 5 | 'os': 'github:jspm/nodelibs-os@0.2.0-alpha', 6 | 'crypto': 'github:jspm/nodelibs-crypto@0.2.0-alpha', 7 | 'buffer': 'github:jspm/nodelibs-buffer@0.2.0-alpha', 8 | 'vm': 'github:jspm/nodelibs-vm@0.2.0-alpha', 9 | 'fs': 'github:jspm/nodelibs-fs@0.2.0-alpha', 10 | 'constants': 'github:jspm/nodelibs-constants@0.2.0-alpha', 11 | 'stream': 'github:jspm/nodelibs-stream@0.2.0-alpha', 12 | 'util': 'github:jspm/nodelibs-util@0.2.0-alpha', 13 | 'string_decoder': 'github:jspm/nodelibs-string_decoder@0.2.0-alpha', 14 | 'process': 'github:jspm/nodelibs-process@0.2.0-alpha', 15 | 'assert': 'github:jspm/nodelibs-assert@0.2.0-alpha', 16 | 'path': 'github:jspm/nodelibs-path@0.2.0-alpha', 17 | 'events': 'github:jspm/nodelibs-events@0.2.0-alpha' 18 | }, 19 | 'packages': { 20 | 'github:frankwallis/plugin-typescript@5.2.7': { 21 | 'map': { 22 | 'typescript': 'npm:typescript@2.0.3' 23 | } 24 | }, 25 | 'github:jspm/nodelibs-os@0.2.0-alpha': { 26 | 'map': { 27 | 'os-browserify': 'npm:os-browserify@0.2.1' 28 | } 29 | }, 30 | 'github:jspm/nodelibs-crypto@0.2.0-alpha': { 31 | 'map': { 32 | 'crypto-browserify': 'npm:crypto-browserify@3.11.0' 33 | } 34 | }, 35 | 'npm:crypto-browserify@3.11.0': { 36 | 'map': { 37 | 'browserify-cipher': 'npm:browserify-cipher@1.0.0', 38 | 'pbkdf2': 'npm:pbkdf2@3.0.9', 39 | 'create-hash': 'npm:create-hash@1.1.2', 40 | 'create-hmac': 'npm:create-hmac@1.1.4', 41 | 'public-encrypt': 'npm:public-encrypt@4.0.0', 42 | 'create-ecdh': 'npm:create-ecdh@4.0.0', 43 | 'randombytes': 'npm:randombytes@2.0.3', 44 | 'diffie-hellman': 'npm:diffie-hellman@5.0.2', 45 | 'inherits': 'npm:inherits@2.0.3', 46 | 'browserify-sign': 'npm:browserify-sign@4.0.0' 47 | } 48 | }, 49 | 'npm:pbkdf2@3.0.9': { 50 | 'map': { 51 | 'create-hmac': 'npm:create-hmac@1.1.4' 52 | } 53 | }, 54 | 'npm:create-hmac@1.1.4': { 55 | 'map': { 56 | 'create-hash': 'npm:create-hash@1.1.2', 57 | 'inherits': 'npm:inherits@2.0.3' 58 | } 59 | }, 60 | 'npm:public-encrypt@4.0.0': { 61 | 'map': { 62 | 'create-hash': 'npm:create-hash@1.1.2', 63 | 'randombytes': 'npm:randombytes@2.0.3', 64 | 'parse-asn1': 'npm:parse-asn1@5.0.0', 65 | 'browserify-rsa': 'npm:browserify-rsa@4.0.1', 66 | 'bn.js': 'npm:bn.js@4.11.6' 67 | } 68 | }, 69 | 'npm:create-hash@1.1.2': { 70 | 'map': { 71 | 'inherits': 'npm:inherits@2.0.3', 72 | 'sha.js': 'npm:sha.js@2.4.5', 73 | 'cipher-base': 'npm:cipher-base@1.0.3', 74 | 'ripemd160': 'npm:ripemd160@1.0.1' 75 | } 76 | }, 77 | 'npm:diffie-hellman@5.0.2': { 78 | 'map': { 79 | 'randombytes': 'npm:randombytes@2.0.3', 80 | 'miller-rabin': 'npm:miller-rabin@4.0.0', 81 | 'bn.js': 'npm:bn.js@4.11.6' 82 | } 83 | }, 84 | 'npm:browserify-cipher@1.0.0': { 85 | 'map': { 86 | 'browserify-des': 'npm:browserify-des@1.0.0', 87 | 'browserify-aes': 'npm:browserify-aes@1.0.6', 88 | 'evp_bytestokey': 'npm:evp_bytestokey@1.0.0' 89 | } 90 | }, 91 | 'npm:browserify-des@1.0.0': { 92 | 'map': { 93 | 'inherits': 'npm:inherits@2.0.3', 94 | 'cipher-base': 'npm:cipher-base@1.0.3', 95 | 'des.js': 'npm:des.js@1.0.0' 96 | } 97 | }, 98 | 'npm:browserify-aes@1.0.6': { 99 | 'map': { 100 | 'create-hash': 'npm:create-hash@1.1.2', 101 | 'inherits': 'npm:inherits@2.0.3', 102 | 'evp_bytestokey': 'npm:evp_bytestokey@1.0.0', 103 | 'cipher-base': 'npm:cipher-base@1.0.3', 104 | 'buffer-xor': 'npm:buffer-xor@1.0.3' 105 | } 106 | }, 107 | 'npm:evp_bytestokey@1.0.0': { 108 | 'map': { 109 | 'create-hash': 'npm:create-hash@1.1.2' 110 | } 111 | }, 112 | 'npm:browserify-sign@4.0.0': { 113 | 'map': { 114 | 'create-hash': 'npm:create-hash@1.1.2', 115 | 'create-hmac': 'npm:create-hmac@1.1.4', 116 | 'inherits': 'npm:inherits@2.0.3', 117 | 'parse-asn1': 'npm:parse-asn1@5.0.0', 118 | 'browserify-rsa': 'npm:browserify-rsa@4.0.1', 119 | 'elliptic': 'npm:elliptic@6.3.2', 120 | 'bn.js': 'npm:bn.js@4.11.6' 121 | } 122 | }, 123 | 'npm:create-ecdh@4.0.0': { 124 | 'map': { 125 | 'elliptic': 'npm:elliptic@6.3.2', 126 | 'bn.js': 'npm:bn.js@4.11.6' 127 | } 128 | }, 129 | 'npm:sha.js@2.4.5': { 130 | 'map': { 131 | 'inherits': 'npm:inherits@2.0.3' 132 | } 133 | }, 134 | 'npm:cipher-base@1.0.3': { 135 | 'map': { 136 | 'inherits': 'npm:inherits@2.0.3' 137 | } 138 | }, 139 | 'npm:parse-asn1@5.0.0': { 140 | 'map': { 141 | 'browserify-aes': 'npm:browserify-aes@1.0.6', 142 | 'create-hash': 'npm:create-hash@1.1.2', 143 | 'evp_bytestokey': 'npm:evp_bytestokey@1.0.0', 144 | 'pbkdf2': 'npm:pbkdf2@3.0.9', 145 | 'asn1.js': 'npm:asn1.js@4.8.1' 146 | } 147 | }, 148 | 'npm:browserify-rsa@4.0.1': { 149 | 'map': { 150 | 'randombytes': 'npm:randombytes@2.0.3', 151 | 'bn.js': 'npm:bn.js@4.11.6' 152 | } 153 | }, 154 | 'npm:elliptic@6.3.2': { 155 | 'map': { 156 | 'inherits': 'npm:inherits@2.0.3', 157 | 'hash.js': 'npm:hash.js@1.0.3', 158 | 'brorand': 'npm:brorand@1.0.6', 159 | 'bn.js': 'npm:bn.js@4.11.6' 160 | } 161 | }, 162 | 'npm:des.js@1.0.0': { 163 | 'map': { 164 | 'inherits': 'npm:inherits@2.0.3', 165 | 'minimalistic-assert': 'npm:minimalistic-assert@1.0.0' 166 | } 167 | }, 168 | 'npm:miller-rabin@4.0.0': { 169 | 'map': { 170 | 'brorand': 'npm:brorand@1.0.6', 171 | 'bn.js': 'npm:bn.js@4.11.6' 172 | } 173 | }, 174 | 'npm:hash.js@1.0.3': { 175 | 'map': { 176 | 'inherits': 'npm:inherits@2.0.3' 177 | } 178 | }, 179 | 'npm:asn1.js@4.8.1': { 180 | 'map': { 181 | 'inherits': 'npm:inherits@2.0.3', 182 | 'minimalistic-assert': 'npm:minimalistic-assert@1.0.0', 183 | 'bn.js': 'npm:bn.js@4.11.6' 184 | } 185 | }, 186 | 'github:jspm/nodelibs-buffer@0.2.0-alpha': { 187 | 'map': { 188 | 'buffer-browserify': 'npm:buffer@4.9.1' 189 | } 190 | }, 191 | 'npm:buffer@4.9.1': { 192 | 'map': { 193 | 'base64-js': 'npm:base64-js@1.2.0', 194 | 'ieee754': 'npm:ieee754@1.1.8', 195 | 'isarray': 'npm:isarray@1.0.0' 196 | } 197 | }, 198 | 'github:jspm/nodelibs-stream@0.2.0-alpha': { 199 | 'map': { 200 | 'stream-browserify': 'npm:stream-browserify@2.0.1' 201 | } 202 | }, 203 | 'npm:stream-browserify@2.0.1': { 204 | 'map': { 205 | 'inherits': 'npm:inherits@2.0.3', 206 | 'readable-stream': 'npm:readable-stream@2.1.5' 207 | } 208 | }, 209 | 'github:jspm/nodelibs-string_decoder@0.2.0-alpha': { 210 | 'map': { 211 | 'string_decoder-browserify': 'npm:string_decoder@0.10.31' 212 | } 213 | }, 214 | 'npm:readable-stream@2.1.5': { 215 | 'map': { 216 | 'inherits': 'npm:inherits@2.0.3', 217 | 'isarray': 'npm:isarray@1.0.0', 218 | 'string_decoder': 'npm:string_decoder@0.10.31', 219 | 'core-util-is': 'npm:core-util-is@1.0.2', 220 | 'buffer-shims': 'npm:buffer-shims@1.0.0', 221 | 'util-deprecate': 'npm:util-deprecate@1.0.2', 222 | 'process-nextick-args': 'npm:process-nextick-args@1.0.7' 223 | } 224 | } 225 | } 226 | }, 227 | transpiler: 'ts', 228 | packages: { 229 | '.': { 230 | 'defaultExtension': 'ts' 231 | } 232 | } 233 | }); 234 | 235 | SystemJS.config({ 236 | packageConfigPaths: [ 237 | 'npm:@*/*.json', 238 | 'npm:*.json', 239 | 'github:*/*.json' 240 | ] 241 | }); 242 | -------------------------------------------------------------------------------- /examples/nodejs/main.ts: -------------------------------------------------------------------------------- 1 | import generate from './generate' 2 | console.log('and the answer is: ' + generate()) 3 | -------------------------------------------------------------------------------- /examples/nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "jspm run ./main.ts", 4 | "debug": "node --debug-brk ../../node_modules/.bin/jspm run ./main.ts" 5 | }, 6 | "jspm": { 7 | "registry": "npm", 8 | "devDependencies": { 9 | "assert": "github:jspm/nodelibs-assert@^0.2.0-alpha", 10 | "buffer": "github:jspm/nodelibs-buffer@^0.2.0-alpha", 11 | "constants": "github:jspm/nodelibs-constants@^0.2.0-alpha", 12 | "crypto": "github:jspm/nodelibs-crypto@^0.2.0-alpha", 13 | "events": "github:jspm/nodelibs-events@^0.2.0-alpha", 14 | "fs": "github:jspm/nodelibs-fs@^0.2.0-alpha", 15 | "os": "github:jspm/nodelibs-os@^0.2.0-alpha", 16 | "path": "github:jspm/nodelibs-path@^0.2.0-alpha", 17 | "process": "github:jspm/nodelibs-process@^0.2.0-alpha", 18 | "stream": "github:jspm/nodelibs-stream@^0.2.0-alpha", 19 | "string_decoder": "github:jspm/nodelibs-string_decoder@^0.2.0-alpha", 20 | "ts": "github:frankwallis/plugin-typescript@^5.2.7", 21 | "util": "github:jspm/nodelibs-util@^0.2.0-alpha", 22 | "vm": "github:jspm/nodelibs-vm@^0.2.0-alpha" 23 | }, 24 | "overrides": { 25 | "npm:inherits@2.0.3": { 26 | "ignore": [ 27 | "test.js" 28 | ] 29 | }, 30 | "npm:typescript@2.0.3": { 31 | "browser": {}, 32 | "map": { 33 | "buffer": "@empty", 34 | "child_process": "@empty", 35 | "fs": "@empty", 36 | "path": "@empty", 37 | "process": "@empty", 38 | "readline": "@empty" 39 | } 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/react/index-bundle.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | plugin-typescript react example 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/react/index-inject.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | plugin-typescript react example 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /examples/react/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | plugin-typescript react example 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /examples/react/jspm.browser.js: -------------------------------------------------------------------------------- 1 | SystemJS.config({ 2 | baseURL: ".", 3 | paths: { 4 | "github:": "jspm_packages/github/", 5 | "npm:": "jspm_packages/npm/" 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /examples/react/jspm.config.js: -------------------------------------------------------------------------------- 1 | SystemJS.config({ 2 | transpiler: "ts", 3 | typescriptOptions: { 4 | "module": "system", 5 | "noImplicitAny": false, 6 | "tsconfig": true 7 | }, 8 | packages: { 9 | "src": { 10 | "main": "index.tsx", 11 | "defaultExtension": "tsx", 12 | "meta": { 13 | "*.css": { 14 | "loader": "css" 15 | } 16 | } 17 | } 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /examples/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "node ../tasks/start", 4 | "example": "node ../tasks/start", 5 | "build": "node ../tasks/build", 6 | "bundle": "node ../tasks/build" 7 | }, 8 | "jspm": { 9 | "registry": "npm", 10 | "dependencies": { 11 | "@types/react": "^0.14.32", 12 | "@types/react-dom": "^0.14.15", 13 | "react-dom": "^15.2.1" 14 | }, 15 | "devDependencies": { 16 | "clean-css": "^3.4.3", 17 | "css": "github:systemjs/plugin-css@^0.1.32", 18 | "systemjs-hot-reloader": "github:alexisvincent/systemjs-hot-reloader@^1.0.0", 19 | "ts": "github:frankwallis/plugin-typescript@^7.0.2", 20 | "tty": "jspm-nodelibs-tty@^0.2.0" 21 | }, 22 | "peerDependencies": { 23 | "assert": "jspm-nodelibs-assert@^0.2.0", 24 | "buffer": "jspm-nodelibs-buffer@^0.2.0", 25 | "child_process": "jspm-nodelibs-child_process@^0.2.0", 26 | "constants": "jspm-nodelibs-constants@^0.2.0", 27 | "crypto": "jspm-nodelibs-crypto@^0.2.0", 28 | "domain": "jspm-nodelibs-domain@^0.2.0", 29 | "events": "jspm-nodelibs-events@^0.2.0", 30 | "fs": "jspm-nodelibs-fs@^0.2.0", 31 | "http": "jspm-nodelibs-http@^0.2.0", 32 | "https": "jspm-nodelibs-https@^0.2.0", 33 | "module": "jspm-nodelibs-module@^0.2.0", 34 | "net": "jspm-nodelibs-net@^0.2.0", 35 | "os": "jspm-nodelibs-os@^0.2.0", 36 | "path": "jspm-nodelibs-path@^0.2.0", 37 | "process": "jspm-nodelibs-process@^0.2.0", 38 | "react": "^15.4.2", 39 | "stream": "jspm-nodelibs-stream@^0.2.0", 40 | "string_decoder": "jspm-nodelibs-string_decoder@^0.2.0", 41 | "typescript": "^2.0.0", 42 | "url": "jspm-nodelibs-url@^0.2.0", 43 | "util": "jspm-nodelibs-util@^0.2.0", 44 | "vm": "jspm-nodelibs-vm@^0.2.0", 45 | "zlib": "jspm-nodelibs-zlib@^0.2.0" 46 | }, 47 | "overrides": { 48 | "npm:browserify-zlib@0.1.4": { 49 | "dependencies": { 50 | "readable-stream": "^2.0.2", 51 | "pako": "~0.2.0" 52 | }, 53 | "map": { 54 | "_stream_transform": "readable-stream/transform" 55 | } 56 | }, 57 | "npm:inherits@2.0.3": { 58 | "ignore": [ 59 | "test.js" 60 | ] 61 | }, 62 | "npm:typescript@2.2.1": { 63 | "browser": {}, 64 | "map": { 65 | "buffer": "@empty", 66 | "child_process": "@empty", 67 | "fs": "@empty", 68 | "path": "@empty", 69 | "process": "@empty", 70 | "readline": "@empty" 71 | }, 72 | "dependencies": { 73 | "source-map-support": "*" 74 | } 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /examples/react/src/__tests__/calculator-store-tests.js: -------------------------------------------------------------------------------- 1 | import {CalculatorStore} from "../calculator-store"; 2 | 3 | describe('CalculatorStore', () => { 4 | 5 | it('initially all values are zero', () => { 6 | let calculatorStore = new CalculatorStore(); 7 | expect(calculatorStore.total).toEqual(0); 8 | expect(calculatorStore.operand).toEqual(0); 9 | }); 10 | 11 | it('handles valid input digits', () => { 12 | let calculatorStore = new CalculatorStore(); 13 | calculatorStore.input(0); 14 | expect(calculatorStore.operand).toEqual(0); 15 | calculatorStore.input(5); 16 | expect(calculatorStore.operand).toEqual(5); 17 | calculatorStore.input(1); 18 | expect(calculatorStore.operand).toEqual(51); 19 | }); 20 | 21 | xit('handles invalid input digits', () => { 22 | let calculatorStore = new CalculatorStore(); 23 | calculatorStore.input(99); 24 | expect(calculatorStore.operand).toEqual(0); 25 | calculatorStore.input('a'); 26 | expect(calculatorStore.operand).toEqual(0); 27 | calculatorStore.input({}); 28 | expect(calculatorStore.operand).toEqual(0); 29 | }); 30 | 31 | it('adds numbers', () => { 32 | let calculatorStore = new CalculatorStore(); 33 | calculatorStore.input(5); 34 | calculatorStore.add(); 35 | expect(calculatorStore.total).toEqual(5); 36 | expect(calculatorStore.operand).toEqual(0); 37 | 38 | calculatorStore.input(66); 39 | calculatorStore.add(); 40 | expect(calculatorStore.total).toEqual(71); 41 | expect(calculatorStore.operand).toEqual(0); 42 | 43 | calculatorStore.add(); 44 | expect(calculatorStore.total).toEqual(71); 45 | expect(calculatorStore.operand).toEqual(0); 46 | }); 47 | 48 | }); 49 | -------------------------------------------------------------------------------- /examples/react/src/__tests__/calculator-tests.js: -------------------------------------------------------------------------------- 1 | import {Calculator} from "../calculator.jsx"; 2 | 3 | import React from "react/addons"; 4 | let TestUtils = React.addons.TestUtils; 5 | 6 | describe('Calculator', () => { 7 | 8 | it('initialises correctly', () => { 9 | let calculator = TestUtils.renderIntoDocument(React.createElement(Calculator)); 10 | let buttons = TestUtils.scryRenderedDOMComponentsWithTag(calculator, 'button'); 11 | expect(buttons.length).toEqual(12); 12 | 13 | let operand = TestUtils.findRenderedDOMComponentWithClass(calculator, 'adder-operand'); 14 | expect(operand.props.children).toEqual(0); 15 | 16 | let total = TestUtils.findRenderedDOMComponentWithClass(calculator, 'adder-total'); 17 | expect(total.props.children).toEqual(0); 18 | }); 19 | 20 | it('handles digit clicks', () => { 21 | let calculator = TestUtils.renderIntoDocument(React.createElement(Calculator)); 22 | 23 | let digits = TestUtils.scryRenderedDOMComponentsWithClass(calculator, 'adder-button-digit'); 24 | let digit = digits[0]; 25 | 26 | TestUtils.Simulate.click(digit); 27 | 28 | let operand = TestUtils.findRenderedDOMComponentWithClass(calculator, 'adder-operand'); 29 | expect(operand.props.children).toEqual(digit.props.children); 30 | }); 31 | 32 | it('handles add button click', () => { 33 | let calculator = TestUtils.renderIntoDocument(React.createElement(Calculator)); 34 | 35 | let digits = TestUtils.scryRenderedDOMComponentsWithClass(calculator, 'adder-button-digit'); 36 | let digit = digits[0]; 37 | 38 | TestUtils.Simulate.click(digit); 39 | 40 | let operand = TestUtils.findRenderedDOMComponentWithClass(calculator, 'adder-operand'); 41 | expect(operand.props.children).toEqual(digit.props.children); 42 | 43 | let add = TestUtils.findRenderedDOMComponentWithClass(calculator, 'adder-button-add'); 44 | TestUtils.Simulate.click(add); 45 | 46 | let total = TestUtils.findRenderedDOMComponentWithClass(calculator, 'adder-total'); 47 | expect(total.props.children).toEqual(digit.props.children); 48 | expect(operand.props.children).toEqual(0); 49 | }); 50 | 51 | it('handles clear button click', () => { 52 | let calculator = TestUtils.renderIntoDocument(React.createElement(Calculator)); 53 | 54 | let digits = TestUtils.scryRenderedDOMComponentsWithClass(calculator, 'adder-button-digit'); 55 | let digit = digits[0]; 56 | 57 | TestUtils.Simulate.click(digit); 58 | 59 | let clear = TestUtils.findRenderedDOMComponentWithClass(calculator, 'adder-button-clear'); 60 | TestUtils.Simulate.click(clear); 61 | 62 | let operand = TestUtils.findRenderedDOMComponentWithClass(calculator, 'adder-operand'); 63 | expect(operand.props.children).toEqual(0); 64 | 65 | let total = TestUtils.findRenderedDOMComponentWithClass(calculator, 'adder-total'); 66 | expect(total.props.children).toEqual(0); 67 | }); 68 | 69 | }); 70 | -------------------------------------------------------------------------------- /examples/react/src/calculator-store.tsx: -------------------------------------------------------------------------------- 1 | export class CalculatorStore { 2 | constructor() { 3 | this.clear(); 4 | } 5 | 6 | public operand: number; 7 | public total: number; 8 | 9 | public input(digit) { 10 | this.operand = (this.operand * 10) + digit; 11 | } 12 | 13 | public add() { 14 | this.total = this.total + this.operand; 15 | this.operand = 0.0; 16 | } 17 | 18 | public clear() { 19 | this.total = 0.0; 20 | this.operand = 0.0; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/react/src/calculator.css: -------------------------------------------------------------------------------- 1 | 2 | .adder-container { 3 | font-size: 2rem; 4 | } 5 | 6 | .adder-display { 7 | box-sizing: border-box; 8 | border: solid 2px gray; 9 | border-radius: .2em; 10 | width: 6em; 11 | display: block; 12 | margin-bottom: .2em; 13 | padding: 2px; 14 | } 15 | 16 | .adder-button { 17 | font-size: 2rem; 18 | width: 2em; 19 | height: 2em; 20 | } 21 | 22 | .adder-button-clear { 23 | background: orangered; 24 | } 25 | 26 | .adder-button-add { 27 | background: mediumseagreen; 28 | } 29 | 30 | .adder-button-digit { 31 | background: dodgerblue; 32 | } -------------------------------------------------------------------------------- /examples/react/src/calculator.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {CalculatorStore} from './calculator-store'; 3 | 4 | export class Calculator extends React.Component { 5 | constructor(props) { 6 | super(props); 7 | this.calculatorStore = new CalculatorStore(); 8 | } 9 | 10 | private calculatorStore: CalculatorStore; 11 | 12 | input(digit) { 13 | this.calculatorStore.input(digit); 14 | this.forceUpdate(); 15 | } 16 | 17 | clear() { 18 | this.calculatorStore.clear(); 19 | this.forceUpdate(); 20 | } 21 | 22 | add() { 23 | this.calculatorStore.add(); 24 | this.forceUpdate(); 25 | } 26 | 27 | inputButton(digit: number) { 28 | return ; 31 | } 32 | 33 | render() { 34 | // build the rows of digits 35 | let buttons = [ 36 | [1, 2, 3].map((digit) => this.inputButton(digit)), 37 | [4, 5, 6].map((digit) => this.inputButton(digit)), 38 | [7, 8, 9].map((digit) => this.inputButton(digit)) 39 | ]; 40 | 41 | // add the bottom row 42 | buttons.push([ 43 | , 46 | this.inputButton(0), 47 | 50 | ]); 51 | 52 | // wrap with row divs 53 | let buttonrows = buttons.map((row, idx) => { 54 | return ( 55 |
56 | {row} 57 |
58 | ); 59 | }); 60 | 61 | return ( 62 |
63 |
64 | {this.calculatorStore.operand} 65 |
66 | 67 |
68 | {this.calculatorStore.total} 69 |
70 | 71 | {buttonrows} 72 |
73 | ); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /examples/react/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import {Calculator} from './calculator'; 4 | import './calculator.css'; 5 | 6 | ReactDOM.render(, document.getElementById('body')); 7 | 8 | -------------------------------------------------------------------------------- /examples/react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react", 4 | "target": "es5", 5 | "module": "system" 6 | }, 7 | "files": [ 8 | "./src/index.tsx" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /examples/tasks/build.js: -------------------------------------------------------------------------------- 1 | var Builder = require('jspm').Builder 2 | var builder = new Builder() 3 | 4 | builder.buildStatic('src', 'build/build.js', { rollup: true, sourceMaps: true, globalName: 'calculator' }) 5 | .then(function() { 6 | console.log('Build complete, go to http://127.0.0.1:8080/index-bundle.html') 7 | }) 8 | .catch(function(err) { 9 | console.log(err) 10 | }) 11 | -------------------------------------------------------------------------------- /examples/tasks/start.js: -------------------------------------------------------------------------------- 1 | var hs = require("http-server") 2 | var open = require('open') 3 | var chokidar = require('chokidar-socket-emitter') 4 | var server = hs.createServer({ "root": process.cwd(), cache: -1 }) 5 | chokidar({ app: server.server, relativeTo: process.cwd(), dir: process.cwd(), path: process.cwd() }) 6 | server.listen(8080) 7 | open("http://127.0.0.1:8080") 8 | -------------------------------------------------------------------------------- /lib/plugin.js: -------------------------------------------------------------------------------- 1 | System.register(["typescript"], function (exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | function __awaiter(thisArg, _arguments, P, generator) { 5 | return new (P || (P = Promise))(function (resolve, reject) { 6 | function fulfilled(value) { try { 7 | step(generator.next(value)); 8 | } 9 | catch (e) { 10 | reject(e); 11 | } } 12 | function rejected(value) { try { 13 | step(generator["throw"](value)); 14 | } 15 | catch (e) { 16 | reject(e); 17 | } } 18 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 19 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 20 | }); 21 | } 22 | function __generator(thisArg, body) { 23 | var _ = { label: 0, sent: function () { if (t[0] & 1) 24 | throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 25 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g; 26 | function verb(n) { return function (v) { return step([n, v]); }; } 27 | function step(op) { 28 | if (f) 29 | throw new TypeError("Generator is already executing."); 30 | while (_) 31 | try { 32 | if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) 33 | return t; 34 | if (y = 0, t) 35 | op = [0, t.value]; 36 | switch (op[0]) { 37 | case 0: 38 | case 1: 39 | t = op; 40 | break; 41 | case 4: 42 | _.label++; 43 | return { value: op[1], done: false }; 44 | case 5: 45 | _.label++; 46 | y = op[1]; 47 | op = [0]; 48 | continue; 49 | case 7: 50 | op = _.ops.pop(); 51 | _.trys.pop(); 52 | continue; 53 | default: 54 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { 55 | _ = 0; 56 | continue; 57 | } 58 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { 59 | _.label = op[1]; 60 | break; 61 | } 62 | if (op[0] === 6 && _.label < t[1]) { 63 | _.label = t[1]; 64 | t = op; 65 | break; 66 | } 67 | if (t && _.label < t[2]) { 68 | _.label = t[2]; 69 | _.ops.push(op); 70 | break; 71 | } 72 | if (t[2]) 73 | _.ops.pop(); 74 | _.trys.pop(); 75 | continue; 76 | } 77 | op = body.call(thisArg, _); 78 | } 79 | catch (e) { 80 | op = [6, e]; 81 | y = 0; 82 | } 83 | finally { 84 | f = t = 0; 85 | } 86 | if (op[0] & 5) 87 | throw op[1]; 88 | return { value: op[0] ? op[1] : void 0, done: true }; 89 | } 90 | } 91 | function convertErrors(diags) { 92 | return diags.reduce(function (result, diag) { 93 | var locationText = undefined; 94 | if (diag.file) { 95 | var position = diag.file.getLineAndCharacterOfPosition(diag.start); 96 | var filename = diag.file.fileName; 97 | locationText = filename + ":" + (position.line + 1) + ":" + (position.character + 1); 98 | } 99 | var messageText = typescript_1["default"].flattenDiagnosticMessageText(diag.messageText, "\n"); 100 | messageText = messageText + " (TS" + diag.code + ")"; 101 | result.push({ 102 | messageText: messageText, 103 | locationText: locationText, 104 | category: diag.category, 105 | errorCode: diag.code 106 | }); 107 | return result; 108 | }, []); 109 | } 110 | function outputErrors(errors, logger) { 111 | errors.slice(0, 10).forEach(function (error) { 112 | var write = (error.category === typescript_1["default"].DiagnosticCategory.Error) ? logger.error : logger.warn; 113 | if (error.locationText) 114 | write(error.locationText); 115 | write(error.messageText); 116 | }); 117 | } 118 | function formatErrors(diags, logger) { 119 | var errors = convertErrors(diags); 120 | outputErrors(errors, logger); 121 | } 122 | function resolveOptions(globalOptions, fileOptions, fileAddress, fetchJson) { 123 | return __awaiter(this, void 0, void 0, function () { 124 | var globalTsconfigOptions, fileTsconfigOptions, mergedOptions, finalOptions; 125 | return __generator(this, function (_a) { 126 | switch (_a.label) { 127 | case 0: return [4, loadTsconfigOptions(globalOptions, '', fetchJson)]; 128 | case 1: 129 | globalTsconfigOptions = _a.sent(); 130 | return [4, loadTsconfigOptions(fileOptions, fileAddress, fetchJson)]; 131 | case 2: 132 | fileTsconfigOptions = _a.sent(); 133 | mergedOptions = __assign({}, globalTsconfigOptions, globalOptions, fileTsconfigOptions, fileOptions); 134 | finalOptions = parseOptions(mergedOptions); 135 | validateOptions(finalOptions); 136 | return [2, finalOptions]; 137 | } 138 | }); 139 | }); 140 | } 141 | function loadTsconfigOptions(options, parentAddress, fetchJson) { 142 | return __awaiter(this, void 0, void 0, function () { 143 | var tsconfigName; 144 | return __generator(this, function (_a) { 145 | tsconfigName = options && options.tsconfig; 146 | if (tsconfigName === true) 147 | tsconfigName = 'tsconfig.json'; 148 | if (tsconfigName) { 149 | return [2, loadTsconfigFile(tsconfigName, parentAddress, fetchJson)]; 150 | } 151 | else { 152 | return [2, undefined]; 153 | } 154 | return [2]; 155 | }); 156 | }); 157 | } 158 | function loadTsconfigFile(filename, parentAddress, fetchJson) { 159 | return __awaiter(this, void 0, void 0, function () { 160 | var tsconfigText, result, extendedTsconfig, _a; 161 | return __generator(this, function (_b) { 162 | switch (_b.label) { 163 | case 0: return [4, fetchJson(filename, parentAddress)]; 164 | case 1: 165 | tsconfigText = _b.sent(); 166 | result = typescript_1["default"].parseConfigFileTextToJson(filename, tsconfigText); 167 | if (!result.error) 168 | return [3, 2]; 169 | formatErrors([result.error], logger$2); 170 | throw new Error("failed to load tsconfig from " + filename); 171 | case 2: 172 | if (!result.config["extends"]) 173 | return [3, 4]; 174 | return [4, loadTsconfigFile(result.config["extends"], filename, fetchJson)]; 175 | case 3: 176 | _a = _b.sent(); 177 | return [3, 5]; 178 | case 4: 179 | _a = undefined; 180 | _b.label = 5; 181 | case 5: 182 | extendedTsconfig = _a; 183 | return [2, __assign({}, extendedTsconfig, result.config.compilerOptions)]; 184 | } 185 | }); 186 | }); 187 | } 188 | function parseOptions(options) { 189 | var result = options || {}; 190 | result.module = getEnum(result.module, typescript_1["default"].ModuleKind, typescript_1["default"].ModuleKind.System); 191 | result.target = getEnum(result.target, typescript_1["default"].ScriptTarget, typescript_1["default"].ScriptTarget.ES5); 192 | result.jsx = getEnum(result.jsx, typescript_1["default"].JsxEmit, typescript_1["default"].JsxEmit.None); 193 | result.allowNonTsExtensions = (result.allowNonTsExtensions !== false); 194 | result.skipDefaultLibCheck = (result.skipDefaultLibCheck !== false); 195 | result.noResolve = true; 196 | result.allowSyntheticDefaultImports = (result.allowSyntheticDefaultImports !== false); 197 | result.moduleResolution = typescript_1["default"].ModuleResolutionKind.Classic; 198 | return result; 199 | } 200 | function getEnum(enumValue, enumType, defaultValue) { 201 | if (enumValue == undefined) 202 | return defaultValue; 203 | for (var enumProp in enumType) { 204 | if (enumProp.toLowerCase() === enumValue.toString().toLowerCase()) { 205 | if (typeof enumType[enumProp] === "string") 206 | return enumType[enumType[enumProp]]; 207 | else 208 | return enumType[enumProp]; 209 | } 210 | } 211 | throw new Error("Unrecognised value [" + enumValue + "]"); 212 | } 213 | function validateOptions(options) { 214 | if ((options.module !== typescript_1["default"].ModuleKind.System) && (options.module !== typescript_1["default"].ModuleKind.ES2015) && (options.module !== typescript_1["default"].ModuleKind.ESNext)) { 215 | logger$2.warn("transpiling to " + typescript_1["default"].ModuleKind[options.module] + ", consider setting module: \"system\" in typescriptOptions to transpile directly to System.register format"); 216 | } 217 | if (options['supportHtmlImports']) { 218 | logger$2.warn("The 'supportHtmlImports' option is no longer supported"); 219 | } 220 | if (options['resolveAmbientRefs']) { 221 | logger$2.warn("The 'resolveAmbientRefs' option is no longer supported"); 222 | } 223 | if (options['targetLib']) { 224 | logger$2.warn("The 'targetLib' option is no longer supported"); 225 | } 226 | if (options['typeCheck']) { 227 | logger$2.error("The 'typeCheck' option is no longer supported"); 228 | } 229 | } 230 | function isTypescript(filename) { 231 | return typescriptRegex.test(filename); 232 | } 233 | function isJavaScript(filename) { 234 | return javascriptRegex.test(filename); 235 | } 236 | function isJSX(filename) { 237 | return jsxRegex.test(filename); 238 | } 239 | function isSourceMap(filename) { 240 | return mapRegex.test(filename); 241 | } 242 | function isTypescriptDeclaration(filename) { 243 | return declarationRegex.test(filename); 244 | } 245 | function isJson(filename) { 246 | return jsonRegex.test(filename); 247 | } 248 | function stripDoubleExtension(normalized) { 249 | var parts = normalized.split('.'); 250 | if (parts.length > 1) { 251 | var extensions = ["js", "jsx", "ts", "tsx", "json"]; 252 | if (extensions.indexOf(parts[parts.length - 2]) >= 0) { 253 | return parts.slice(0, -1).join('.'); 254 | } 255 | } 256 | return normalized; 257 | } 258 | function hasError(diags) { 259 | return diags.some(function (diag) { return (diag.category === typescript_1["default"].DiagnosticCategory.Error); }); 260 | } 261 | function transpile(sourceName, options, host) { 262 | logger$3.debug("transpiling " + sourceName); 263 | var file = host.getSourceFile(sourceName); 264 | if (!file) 265 | throw new Error("file [" + sourceName + "] has not been added"); 266 | if (!file.output) { 267 | var transpileOptions = getTranspileOptions(options); 268 | var program = typescript_1["default"].createProgram([sourceName], transpileOptions, host); 269 | var jstext_1 = undefined; 270 | var maptext_1 = undefined; 271 | var emitResult = program.emit(undefined, function (outputName, output) { 272 | if (isJavaScript(outputName) || isJSX(outputName)) 273 | jstext_1 = output.slice(0, output.lastIndexOf("//#")); 274 | else if (isSourceMap(outputName)) 275 | maptext_1 = output; 276 | else 277 | throw new Error("unexpected ouput file " + outputName); 278 | }); 279 | var diagnostics = emitResult.diagnostics 280 | .concat(program.getOptionsDiagnostics()) 281 | .concat(program.getSyntacticDiagnostics()); 282 | file.output = { 283 | failure: hasError(diagnostics), 284 | diags: diagnostics, 285 | js: jstext_1, 286 | sourceMap: maptext_1 287 | }; 288 | } 289 | return file.output; 290 | } 291 | function getTranspileOptions(options) { 292 | var result = typescript_1["default"].clone(options); 293 | result.isolatedModules = true; 294 | if (result.sourceMap === undefined) 295 | result.sourceMap = result.inlineSourceMap; 296 | if (result.sourceMap === undefined) 297 | result.sourceMap = true; 298 | result.inlineSourceMap = false; 299 | result.declaration = false; 300 | result.noEmitOnError = false; 301 | result.out = undefined; 302 | result.outFile = undefined; 303 | result.noLib = true; 304 | result.lib = undefined; 305 | result.types = []; 306 | result.suppressOutputPathCheck = true; 307 | result.noEmit = false; 308 | return result; 309 | } 310 | function getHost() { 311 | var __global = typeof (self) !== 'undefined' ? self : global; 312 | __global.tsHost = __global.tsHost || new CompilerHost(); 313 | return __global.tsHost; 314 | } 315 | function translate(load) { 316 | return __awaiter(this, void 0, void 0, function () { 317 | var loader, options, result; 318 | return __generator(this, function (_a) { 319 | switch (_a.label) { 320 | case 0: 321 | loader = this; 322 | logger.debug("systemjs translating " + load.address); 323 | if (isJson(load.address)) 324 | return [2, load.source]; 325 | return [4, resolveOptions(SystemJS.typescriptOptions, load.metadata.typescriptOptions, load.address, _fetchJson)]; 326 | case 1: 327 | options = _a.sent(); 328 | host.addFile(load.address, load.source, options.target); 329 | if (isTypescriptDeclaration(load.address)) { 330 | load.source = ''; 331 | } 332 | else { 333 | result = transpile(load.address, options, host); 334 | load.metadata.tserrors = convertErrors(result.diags); 335 | outputErrors(load.metadata.tserrors, logger); 336 | if (result.failure) 337 | throw new Error('TypeScript transpilation failed'); 338 | load.source = result.js; 339 | if (isTypescript(load.address)) { 340 | if (options.module === typescript_1["default"].ModuleKind.System) 341 | load.metadata.format = 'register'; 342 | else if (options.module === typescript_1["default"].ModuleKind.ES2015) 343 | load.metadata.format = 'esm'; 344 | else if (options.module === typescript_1["default"].ModuleKind.CommonJS) 345 | load.metadata.format = 'cjs'; 346 | else if (options.module === typescript_1["default"].ModuleKind.AMD) 347 | load.metadata.format = 'amd'; 348 | } 349 | if (result.sourceMap) 350 | load.metadata.sourceMap = JSON.parse(result.sourceMap); 351 | } 352 | return [2, load.source]; 353 | } 354 | }); 355 | }); 356 | } 357 | exports_1("translate", translate); 358 | function instantiate(load, origInstantiate) { 359 | logger.debug("systemjs instantiating " + load.address); 360 | return isJson(load.address) ? JSON.parse(load.source) : origInstantiate(load); 361 | } 362 | exports_1("instantiate", instantiate); 363 | function _fetchJson(fileName, parentAddress) { 364 | return __awaiter(this, void 0, void 0, function () { 365 | var address, json; 366 | return __generator(this, function (_a) { 367 | switch (_a.label) { 368 | case 0: return [4, SystemJS.normalize(fileName, parentAddress)]; 369 | case 1: 370 | address = _a.sent(); 371 | return [4, SystemJS["import"](stripDoubleExtension(address) + '!' + __moduleName, parentAddress)]; 372 | case 2: 373 | json = _a.sent(); 374 | logger.debug("fetched " + fileName); 375 | return [2, JSON.stringify(json)]; 376 | } 377 | }); 378 | }); 379 | } 380 | var typescript_1, __assign, Logger, logger$1, CompilerHost, logger$2, typescriptRegex, javascriptRegex, jsxRegex, mapRegex, declarationRegex, jsonRegex, logger$3, logger, host; 381 | return { 382 | setters: [ 383 | function (typescript_1_1) { 384 | typescript_1 = typescript_1_1; 385 | } 386 | ], 387 | execute: function () { 388 | __assign = Object.assign || function __assign(t) { 389 | for (var s, i = 1, n = arguments.length; i < n; i++) { 390 | s = arguments[i]; 391 | for (var p in s) 392 | if (Object.prototype.hasOwnProperty.call(s, p)) 393 | t[p] = s[p]; 394 | } 395 | return t; 396 | }; 397 | Logger = (function () { 398 | function Logger(options) { 399 | this.options = options; 400 | this.options = options || {}; 401 | } 402 | Logger.prototype.log = function (msg) { 403 | console.log("TypeScript", "[Info]", msg); 404 | }; 405 | Logger.prototype.error = function (msg) { 406 | console.error("TypeScript", "[Error]", msg); 407 | }; 408 | Logger.prototype.warn = function (msg) { 409 | console.warn("TypeScript", "[Warning]", msg); 410 | }; 411 | Logger.prototype.debug = function (msg) { 412 | if (this.options.debug) { 413 | console.log("TypeScript", msg); 414 | } 415 | }; 416 | return Logger; 417 | }()); 418 | logger$1 = new Logger({ debug: false }); 419 | CompilerHost = (function () { 420 | function CompilerHost() { 421 | this._files = {}; 422 | } 423 | CompilerHost.prototype.getDefaultLibFileName = function (options) { 424 | return this.getDefaultLibFilePaths(options)[0]; 425 | }; 426 | CompilerHost.prototype.getDefaultLibFilePaths = function (options) { 427 | return options.lib ? options.lib.map(function (libName) { return "typescript/lib/lib." + libName + ".d.ts"; }) : ['typescript/lib/lib.d.ts']; 428 | }; 429 | CompilerHost.prototype.useCaseSensitiveFileNames = function () { 430 | return false; 431 | }; 432 | CompilerHost.prototype.getCanonicalFileName = function (fileName) { 433 | return typescript_1["default"].normalizePath(fileName); 434 | }; 435 | CompilerHost.prototype.getCurrentDirectory = function () { 436 | return ""; 437 | }; 438 | CompilerHost.prototype.getNewLine = function () { 439 | return "\n"; 440 | }; 441 | CompilerHost.prototype.readFile = function (fileName) { 442 | throw new Error("Not implemented"); 443 | }; 444 | CompilerHost.prototype.writeFile = function (name, text, writeByteOrderMark) { 445 | throw new Error("Not implemented"); 446 | }; 447 | CompilerHost.prototype.getSourceFile = function (fileName) { 448 | fileName = this.getCanonicalFileName(fileName); 449 | return this._files[fileName]; 450 | }; 451 | CompilerHost.prototype.getAllFiles = function () { 452 | var _this = this; 453 | return Object.keys(this._files).map(function (key) { return _this._files[key]; }); 454 | }; 455 | CompilerHost.prototype.fileExists = function (fileName) { 456 | return !!this.getSourceFile(fileName); 457 | }; 458 | CompilerHost.prototype.getDirectories = function () { 459 | throw new Error("Not implemented"); 460 | }; 461 | CompilerHost.prototype.addFile = function (fileName, text, target) { 462 | fileName = this.getCanonicalFileName(fileName); 463 | var file = this._files[fileName]; 464 | if (!file) { 465 | this._files[fileName] = typescript_1["default"].createSourceFile(fileName, text, target); 466 | logger$1.debug("added " + fileName); 467 | } 468 | else if (file.text != text) { 469 | this._files[fileName] = typescript_1["default"].createSourceFile(fileName, text, target); 470 | logger$1.debug("updated " + fileName); 471 | } 472 | return this._files[fileName]; 473 | }; 474 | return CompilerHost; 475 | }()); 476 | logger$2 = new Logger({ debug: false }); 477 | typescriptRegex = /\.tsx?$/i; 478 | javascriptRegex = /\.js$/i; 479 | jsxRegex = /\.jsx$/i; 480 | mapRegex = /\.map$/i; 481 | declarationRegex = /\.d\.tsx?$/i; 482 | jsonRegex = /\.json$/i; 483 | logger$3 = new Logger({ debug: false }); 484 | logger = new Logger({ debug: false }); 485 | host = getHost(); 486 | } 487 | }; 488 | }); 489 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "plugin-typescript", 3 | "version": "9.0.0", 4 | "description": "TypeScript loader for SystemJS", 5 | "main": "lib/plugin.js", 6 | "homepage": "https://github.com/frankwallis/plugin-typescript", 7 | "authors": [ 8 | "Frank Wallis" 9 | ], 10 | "keywords": [ 11 | "systemjs", 12 | "jspm", 13 | "es6", 14 | "typescript", 15 | "ts", 16 | "tsx", 17 | "angular2", 18 | "react", 19 | "bundle", 20 | "plugin", 21 | "loader" 22 | ], 23 | "repository": { 24 | "type": "git", 25 | "url": "https://github.com/frankwallis/plugin-typescript.git" 26 | }, 27 | "peerDependencies": { 28 | "typescript": "^2.4.0" 29 | }, 30 | "devDependencies": { 31 | "@types/chai": "^4.0.3", 32 | "@types/chai-as-promised": "0.0.31", 33 | "@types/mocha": "^2.2.39", 34 | "@types/node": "^8.0.20", 35 | "@types/sinon": "^2.3.3", 36 | "@types/systemjs": "^0.20.6", 37 | "chai": "^4.1.1", 38 | "chai-as-promised": "^7.1.1", 39 | "chokidar-socket-emitter": "^0.6.0", 40 | "http-server": "^0.10.0", 41 | "jspm": "^0.17.0-beta.42", 42 | "mocha": "^3.0.2", 43 | "open": "^0.0.5", 44 | "rollup": "^0.46.1", 45 | "rollup-plugin-includepaths": "^0.2.1", 46 | "sinon": "^3.2.0", 47 | "ts-node": "^3.0.0", 48 | "tslib": "^1.4.0", 49 | "typescript": "^2.6.1" 50 | }, 51 | "scripts": { 52 | "bundle": "tsc && rollup -c && tsc ./tmp/plugin.js -m system -lib es6 -allowJs -allowUnreachableCode -removeComments -outDir ./lib", 53 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", 54 | "test": "mocha --require ./test/environment --timeout 10000 ./test/*.ts" 55 | }, 56 | "files": [ 57 | "lib/plugin.js" 58 | ], 59 | "bin": {}, 60 | "license": "MIT", 61 | "jspm": { 62 | "format": "register", 63 | "main": "plugin", 64 | "registry": "github", 65 | "name": "frankwallis/plugin-typescript", 66 | "peerDependencies": { 67 | "typescript": "npm:typescript@^2.4.0" 68 | }, 69 | "directories": { 70 | "lib": "lib", 71 | "dist": "lib" 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import includePaths from 'rollup-plugin-includepaths' 2 | 3 | let includePathOptions = { 4 | include: { 5 | 'tslib': './node_modules/tslib/tslib.es6.js' 6 | }, 7 | paths: [], 8 | external: ['typescript'], 9 | extensions: ['.js'], 10 | } 11 | 12 | export default { 13 | entry: './tmp/es6/plugin.js', 14 | format: 'es', 15 | dest: 'tmp/plugin.js', 16 | plugins: [includePaths(includePathOptions)], 17 | } 18 | -------------------------------------------------------------------------------- /src/compiler-host.ts: -------------------------------------------------------------------------------- 1 | /* */ 2 | import ts from 'typescript' 3 | import Logger from './logger' 4 | 5 | const logger = new Logger({ debug: false }) 6 | 7 | export type TranspileResult = { 8 | failure: boolean 9 | diags: Array 10 | js: string 11 | sourceMap: string 12 | } 13 | 14 | export interface SourceFile extends ts.SourceFile { 15 | output?: TranspileResult 16 | } 17 | 18 | export class CompilerHost implements ts.CompilerHost { 19 | private _files: { [s: string]: SourceFile } 20 | 21 | constructor() { 22 | this._files = {} 23 | } 24 | 25 | public getDefaultLibFileName(options: ts.CompilerOptions): string { 26 | return this.getDefaultLibFilePaths(options)[0] 27 | } 28 | 29 | public getDefaultLibFilePaths(options: ts.CompilerOptions): string[] { 30 | return options.lib ? options.lib.map(libName => `typescript/lib/lib.${libName}.d.ts`) : ['typescript/lib/lib.d.ts']; 31 | } 32 | 33 | public useCaseSensitiveFileNames(): boolean { 34 | return false 35 | } 36 | 37 | public getCanonicalFileName(fileName: string): string { 38 | return (ts as any).normalizePath(fileName) 39 | } 40 | 41 | public getCurrentDirectory(): string { 42 | return "" 43 | } 44 | 45 | public getNewLine(): string { 46 | return "\n" 47 | } 48 | 49 | public readFile(fileName: string): string { 50 | throw new Error("Not implemented") 51 | } 52 | 53 | public writeFile(name: string, text: string, writeByteOrderMark: boolean) { 54 | throw new Error("Not implemented") 55 | } 56 | 57 | public getSourceFile(fileName: string): SourceFile { 58 | fileName = this.getCanonicalFileName(fileName) 59 | return this._files[fileName] 60 | } 61 | 62 | public getAllFiles(): SourceFile[] { 63 | return Object.keys(this._files).map(key => this._files[key]) 64 | } 65 | 66 | public fileExists(fileName: string): boolean { 67 | return !!this.getSourceFile(fileName) 68 | } 69 | 70 | public getDirectories(): string[] { 71 | throw new Error("Not implemented") 72 | } 73 | 74 | public addFile(fileName: string, text: string, target: ts.ScriptTarget): SourceFile { 75 | fileName = this.getCanonicalFileName(fileName) 76 | const file = this._files[fileName] 77 | 78 | if (!file) { 79 | this._files[fileName] = ts.createSourceFile(fileName, text, target) 80 | logger.debug(`added ${fileName}`) 81 | } 82 | else if (file.text != text) { 83 | // create a new one 84 | this._files[fileName] = ts.createSourceFile(fileName, text, target) 85 | logger.debug(`updated ${fileName}`) 86 | } 87 | 88 | return this._files[fileName] 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/format-errors.ts: -------------------------------------------------------------------------------- 1 | /* */ 2 | import ts from 'typescript' 3 | import Logger from './logger' 4 | 5 | /* 6 | * Convert the diagnostics into structured errors 7 | */ 8 | export function convertErrors(diags: ts.Diagnostic[]): StructuredError[] { 9 | return diags.reduce((result, diag) => { 10 | let locationText = undefined 11 | 12 | if (diag.file) { 13 | // feature: print the compiler output over 2 lines! file then message 14 | const position = diag.file.getLineAndCharacterOfPosition(diag.start) 15 | const filename = diag.file.fileName 16 | 17 | // feature: output in format address:line:position to enable direct linking to error location in chrome dev tools 18 | locationText = `${filename}:${position.line + 1}:${position.character + 1}` 19 | } 20 | 21 | let messageText = ts.flattenDiagnosticMessageText(diag.messageText, "\n") 22 | messageText = `${messageText} (TS${diag.code})` 23 | 24 | result.push({ 25 | messageText, 26 | locationText, 27 | category: diag.category, 28 | errorCode: diag.code 29 | }) 30 | 31 | return result 32 | }, []) 33 | } 34 | 35 | /** 36 | * Write the compiler errors to console 37 | */ 38 | export function outputErrors(errors: StructuredError[], logger: Logger) { 39 | // feature: don't spam the console, only display the first 10 errors 40 | errors.slice(0, 10).forEach(error => { 41 | const write = (error.category === ts.DiagnosticCategory.Error) ? logger.error : logger.warn 42 | 43 | if (error.locationText) 44 | write(error.locationText) 45 | 46 | write(error.messageText) 47 | }) 48 | } 49 | 50 | /** 51 | * Format the diagnostics and write to the console 52 | */ 53 | export function formatErrors(diags: ts.Diagnostic[], logger: Logger) { 54 | const errors = convertErrors(diags) 55 | outputErrors(errors, logger) 56 | } 57 | -------------------------------------------------------------------------------- /src/logger.ts: -------------------------------------------------------------------------------- 1 | /* */ 2 | type LoggerOptions = { 3 | debug?: boolean 4 | } 5 | 6 | class Logger { 7 | constructor(private options: LoggerOptions) { 8 | this.options = options || {} 9 | } 10 | 11 | public log(msg: string) { 12 | console.log("TypeScript", "[Info]", msg) 13 | } 14 | 15 | public error(msg: string) { 16 | console.error("TypeScript", "[Error]", msg) 17 | } 18 | 19 | public warn(msg: string) { 20 | console.warn("TypeScript", "[Warning]", msg) 21 | } 22 | 23 | public debug(msg: string) { 24 | if (this.options.debug) { 25 | console.log("TypeScript", msg) 26 | } 27 | } 28 | } 29 | 30 | export default Logger 31 | -------------------------------------------------------------------------------- /src/plugin.ts: -------------------------------------------------------------------------------- 1 | /* */ 2 | import ts from 'typescript' 3 | import Logger from './logger' 4 | import { convertErrors, outputErrors } from './format-errors' 5 | import { CompilerHost } from './compiler-host' 6 | import { resolveOptions } from './resolve-options' 7 | import { transpile } from './transpiler' 8 | import { isTypescript, isTypescriptDeclaration, isJson, stripDoubleExtension } from './utils' 9 | 10 | const logger = new Logger({ debug: false }) 11 | const host = getHost() 12 | 13 | /* 14 | * persist CompilerHost instance between instantiations of the plugin and expose it to the world 15 | */ 16 | function getHost(): CompilerHost { 17 | const __global: any = typeof (self) !== 'undefined' ? self : global 18 | __global.tsHost = __global.tsHost || new CompilerHost() 19 | return __global.tsHost 20 | } 21 | 22 | /* 23 | * SystemJS translate hook 24 | * load.name 25 | * load.address 26 | * load.metadata 27 | * load.source: the fetched source 28 | */ 29 | export async function translate(load: Module): Promise { 30 | const loader = this 31 | logger.debug(`systemjs translating ${load.address}`) 32 | 33 | /* No need to translate tsconfig.json files */ 34 | if (isJson(load.address)) return load.source 35 | 36 | /* resolve the typescript options for this file, this may involve loading tsconfig.json */ 37 | const options = await resolveOptions( 38 | SystemJS.typescriptOptions, 39 | load.metadata.typescriptOptions, 40 | load.address, 41 | _fetchJson) 42 | 43 | /* create/update the source file in typescript */ 44 | host.addFile(load.address, load.source, options.target) 45 | 46 | /* typescript declaration files have no executable source */ 47 | if (isTypescriptDeclaration(load.address)) { 48 | load.source = '' 49 | } 50 | else { 51 | /* transpile the source */ 52 | const result = transpile(load.address, options, host) 53 | 54 | load.metadata.tserrors = convertErrors(result.diags) 55 | outputErrors(load.metadata.tserrors, logger) 56 | 57 | if (result.failure) 58 | throw new Error('TypeScript transpilation failed') 59 | 60 | load.source = result.js 61 | 62 | if (isTypescript(load.address)) { 63 | if (options.module === ts.ModuleKind.System) 64 | load.metadata.format = 'register' 65 | else if (options.module === ts.ModuleKind.ES2015) 66 | load.metadata.format = 'esm' 67 | else if (options.module === ts.ModuleKind.CommonJS) 68 | load.metadata.format = 'cjs' 69 | else if (options.module === ts.ModuleKind.AMD) 70 | load.metadata.format = 'amd' 71 | } 72 | 73 | if (result.sourceMap) 74 | load.metadata.sourceMap = JSON.parse(result.sourceMap) 75 | } 76 | 77 | return load.source 78 | } 79 | 80 | /* 81 | * SystemJS instantiate hook 82 | * load.name 83 | * load.address 84 | * load.metadata 85 | * load.source: the fetched source 86 | */ 87 | export function instantiate(load: Module, origInstantiate: any) { 88 | logger.debug(`systemjs instantiating ${load.address}`) 89 | return isJson(load.address) ? JSON.parse(load.source) : origInstantiate(load) 90 | } 91 | 92 | /* 93 | * called by resolveOptions when it needs to fetch tsconfig.json 94 | */ 95 | async function _fetchJson(fileName: string, parentAddress: string): Promise { 96 | const address = await SystemJS.normalize(fileName, parentAddress); 97 | const json = await SystemJS.import(stripDoubleExtension(address) + '!' + __moduleName, parentAddress) 98 | logger.debug(`fetched ${fileName}`) 99 | return JSON.stringify(json) 100 | } 101 | -------------------------------------------------------------------------------- /src/resolve-options.ts: -------------------------------------------------------------------------------- 1 | import ts from 'typescript' 2 | import Logger from './logger' 3 | import { formatErrors } from './format-errors' 4 | 5 | const logger = new Logger({ debug: false }) 6 | export type CombinedOptions = PluginOptions & ts.CompilerOptions 7 | 8 | export async function resolveOptions( 9 | globalOptions: any, 10 | fileOptions: any, 11 | fileAddress: string, 12 | fetchJson: FetchFunction): Promise { 13 | 14 | const globalTsconfigOptions = await loadTsconfigOptions(globalOptions, '', fetchJson) 15 | const fileTsconfigOptions = await loadTsconfigOptions(fileOptions, fileAddress, fetchJson) 16 | const mergedOptions = { 17 | ...globalTsconfigOptions, 18 | ...globalOptions, 19 | ...fileTsconfigOptions, 20 | ...fileOptions 21 | } 22 | 23 | const finalOptions = parseOptions(mergedOptions) 24 | validateOptions(finalOptions) 25 | 26 | return finalOptions 27 | } 28 | 29 | async function loadTsconfigOptions( 30 | options: CombinedOptions, 31 | parentAddress: string, 32 | fetchJson: FetchFunction): Promise { 33 | 34 | let tsconfigName = options && options.tsconfig 35 | if (tsconfigName === true) tsconfigName = 'tsconfig.json' 36 | 37 | if (tsconfigName) { 38 | return loadTsconfigFile(tsconfigName, parentAddress, fetchJson); 39 | } 40 | else { 41 | return undefined; 42 | } 43 | } 44 | 45 | async function loadTsconfigFile( 46 | filename: string, 47 | parentAddress: string, 48 | fetchJson: FetchFunction): Promise { 49 | 50 | const tsconfigText = await fetchJson(filename, parentAddress) 51 | const result = ts.parseConfigFileTextToJson(filename, tsconfigText) 52 | 53 | if (result.error) { 54 | formatErrors([result.error], logger) 55 | throw new Error(`failed to load tsconfig from ${filename}`) 56 | } 57 | else { 58 | const extendedTsconfig = result.config.extends 59 | ? await loadTsconfigFile(result.config.extends, filename, fetchJson) 60 | : undefined 61 | return { 62 | ...extendedTsconfig, 63 | ...result.config.compilerOptions 64 | } 65 | } 66 | } 67 | 68 | export function parseOptions(options: any): CombinedOptions { 69 | const result = options || {} 70 | result.module = getEnum(result.module, ts.ModuleKind, ts.ModuleKind.System) 71 | result.target = getEnum(result.target, ts.ScriptTarget, ts.ScriptTarget.ES5) 72 | result.jsx = getEnum(result.jsx, ts.JsxEmit, ts.JsxEmit.None) 73 | result.allowNonTsExtensions = (result.allowNonTsExtensions !== false) 74 | result.skipDefaultLibCheck = (result.skipDefaultLibCheck !== false) 75 | result.noResolve = true 76 | result.allowSyntheticDefaultImports = (result.allowSyntheticDefaultImports !== false) 77 | 78 | // Force module resolution into 'classic' mode, to prevent node module resolution from kicking in 79 | result.moduleResolution = ts.ModuleResolutionKind.Classic 80 | 81 | // When bundling automatically output es6 modules instead of system to enable rollup support 82 | // if (builder) { 83 | // if (result.module === ts.ModuleKind.System) { 84 | // logger.log('switching output from system.register -> es modules to support rollup') 85 | // result.module = ts.ModuleKind.ES6 86 | // } 87 | // } 88 | 89 | return result 90 | } 91 | 92 | function getEnum(enumValue: any, enumType: any, defaultValue: number): number { 93 | if (enumValue == undefined) return defaultValue 94 | 95 | for (var enumProp in enumType) { 96 | if (enumProp.toLowerCase() === enumValue.toString().toLowerCase()) { 97 | if (typeof enumType[enumProp] === "string") 98 | return enumType[enumType[enumProp]] 99 | else 100 | return enumType[enumProp] 101 | } 102 | } 103 | 104 | throw new Error(`Unrecognised value [${enumValue}]`) 105 | } 106 | 107 | function validateOptions(options: CombinedOptions) { 108 | /* The only time you don't want to output in 'm format is when you are using rollup or babel 109 | downstream to compile es6 output (e.g. for async/await support) */ 110 | if ((options.module !== ts.ModuleKind.System) && (options.module !== ts.ModuleKind.ES2015) && (options.module !== ts.ModuleKind.ESNext)) { 111 | logger.warn(`transpiling to ${ts.ModuleKind[options.module]}, consider setting module: "system" in typescriptOptions to transpile directly to System.register format`) 112 | } 113 | 114 | if (options['supportHtmlImports']) { 115 | logger.warn("The 'supportHtmlImports' option is no longer supported") 116 | } 117 | 118 | if (options['resolveAmbientRefs']) { 119 | logger.warn("The 'resolveAmbientRefs' option is no longer supported") 120 | } 121 | 122 | if (options['targetLib']) { 123 | logger.warn("The 'targetLib' option is no longer supported") 124 | } 125 | 126 | if (options['typeCheck']) { 127 | logger.error("The 'typeCheck' option is no longer supported") 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/transpiler.ts: -------------------------------------------------------------------------------- 1 | import ts from 'typescript' 2 | import { CompilerHost, TranspileResult } from './compiler-host' 3 | import { isJavaScript, isJSX, isSourceMap, hasError } from './utils' 4 | import Logger from './logger' 5 | 6 | const logger = new Logger({ debug: false }) 7 | 8 | export function transpile( 9 | sourceName: string, 10 | options: ts.CompilerOptions, 11 | host: CompilerHost): TranspileResult { 12 | 13 | logger.debug(`transpiling ${sourceName}`) 14 | 15 | const file = host.getSourceFile(sourceName) 16 | if (!file) throw new Error(`file [${sourceName}] has not been added`) 17 | 18 | if (!file.output) { 19 | const transpileOptions = getTranspileOptions(options) 20 | const program = ts.createProgram([sourceName], transpileOptions, host) 21 | 22 | let jstext: string = undefined 23 | let maptext: string = undefined 24 | 25 | // Emit 26 | const emitResult = program.emit(undefined, (outputName, output) => { 27 | if (isJavaScript(outputName) || isJSX(outputName)) 28 | jstext = output.slice(0, output.lastIndexOf("//#")) // remove sourceMappingURL 29 | else if (isSourceMap(outputName)) 30 | maptext = output 31 | else 32 | throw new Error(`unexpected ouput file ${outputName}`) 33 | }) 34 | 35 | const diagnostics = emitResult.diagnostics 36 | .concat(program.getOptionsDiagnostics()) 37 | .concat(program.getSyntacticDiagnostics()) 38 | 39 | file.output = { 40 | failure: hasError(diagnostics), 41 | diags: diagnostics, 42 | js: jstext, 43 | sourceMap: maptext 44 | } 45 | } 46 | 47 | return file.output 48 | } 49 | 50 | function getTranspileOptions(options: ts.CompilerOptions): ts.CompilerOptions { 51 | const result = (ts).clone(options) as ts.CompilerOptions; 52 | 53 | result.isolatedModules = true 54 | 55 | /* arrange for an external source map */ 56 | if (result.sourceMap === undefined) 57 | result.sourceMap = result.inlineSourceMap 58 | 59 | if (result.sourceMap === undefined) 60 | result.sourceMap = true 61 | 62 | result.inlineSourceMap = false 63 | 64 | /* these options are incompatible with isolatedModules */ 65 | result.declaration = false 66 | result.noEmitOnError = false 67 | result.out = undefined 68 | result.outFile = undefined 69 | 70 | /* without this we get a 'lib.d.ts not found' error */ 71 | result.noLib = true 72 | result.lib = undefined // incompatible with noLib 73 | 74 | /* without this we get a 'cannot find type-reference' error */ 75 | result.types = [] 76 | 77 | /* without this we get 'cannot overwrite existing file' when transpiling js files */ 78 | result.suppressOutputPathCheck = true 79 | 80 | /* with this we don't get any files */ 81 | result.noEmit = false 82 | 83 | return result 84 | } 85 | -------------------------------------------------------------------------------- /src/types.d.ts: -------------------------------------------------------------------------------- 1 | interface Module { 2 | name: string 3 | address: string 4 | source?: string 5 | metadata?: any 6 | } 7 | 8 | type FetchFunction = (fileName: string, parentAddress: string) => Promise 9 | 10 | interface PluginOptions { 11 | tsconfig?: boolean | string 12 | } 13 | 14 | interface StructuredError { 15 | messageText: string 16 | locationText: string 17 | errorCode: number 18 | category: number 19 | } 20 | 21 | declare module "jspm" { 22 | export const Builder: any 23 | } 24 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | /* */ 2 | import ts from 'typescript' 3 | 4 | export function isAbsolute(filename: string) { 5 | return (filename[0] === '/') 6 | } 7 | 8 | export function isRelative(filename: string) { 9 | return (filename[0] === '.') 10 | } 11 | 12 | export function isAmbientImport(filename: string) { 13 | return (isAmbient(filename) && !isTypescriptDeclaration(filename)) 14 | } 15 | 16 | export function isAmbientReference(filename: string) { 17 | return (isAmbient(filename) && isTypescriptDeclaration(filename)) 18 | } 19 | 20 | export function isAmbient(filename: string) { 21 | return (!isRelative(filename) && !isAbsolute(filename)) 22 | } 23 | 24 | const typescriptRegex = /\.tsx?$/i 25 | export function isTypescript(filename: string) { 26 | return typescriptRegex.test(filename) 27 | } 28 | 29 | const javascriptRegex = /\.js$/i 30 | export function isJavaScript(filename: string) { 31 | return javascriptRegex.test(filename) 32 | } 33 | 34 | const jsxRegex = /\.jsx$/i 35 | export function isJSX(filename: string) { 36 | return jsxRegex.test(filename) 37 | } 38 | 39 | const mapRegex = /\.map$/i 40 | export function isSourceMap(filename: string) { 41 | return mapRegex.test(filename) 42 | } 43 | 44 | const declarationRegex = /\.d\.tsx?$/i 45 | export function isTypescriptDeclaration(filename: string) { 46 | return declarationRegex.test(filename) 47 | } 48 | 49 | const jsonRegex = /\.json$/i 50 | export function isJson(filename: string) { 51 | return jsonRegex.test(filename) 52 | } 53 | 54 | export function tsToJs(tsFile: string) { 55 | return tsFile.replace(typescriptRegex, '.js') 56 | } 57 | 58 | export function tsToJsMap(tsFile: string) { 59 | return tsFile.replace(typescriptRegex, '.js.map') 60 | } 61 | 62 | const convertRegex = /\.[^\.]+$/ 63 | export function convertToDts(anyFile: string) { 64 | return anyFile.replace(convertRegex, '.d.ts') 65 | } 66 | 67 | export function getExtension(normalized: string) { 68 | const baseName = (ts as any).getBaseFileName(normalized) 69 | const parts = baseName.split('.') 70 | return parts.length > 1 ? parts.pop() : undefined 71 | } 72 | 73 | export function stripDoubleExtension(normalized: string) { 74 | const parts = normalized.split('.') 75 | 76 | if (parts.length > 1) { 77 | const extensions = ["js", "jsx", "ts", "tsx", "json"] 78 | 79 | if (extensions.indexOf(parts[parts.length - 2]) >= 0) { 80 | return parts.slice(0, -1).join('.') 81 | } 82 | } 83 | return normalized 84 | } 85 | 86 | export function hasError(diags: Array): boolean { 87 | return diags.some(diag => (diag.category === ts.DiagnosticCategory.Error)) 88 | } 89 | -------------------------------------------------------------------------------- /test/builder-spec.ts: -------------------------------------------------------------------------------- 1 | import chai = require('chai') 2 | import chaiAsPromised = require('chai-as-promised') 3 | import ts from 'typescript' 4 | import { Builder } from 'jspm' 5 | import { Config } from 'systemjs' 6 | 7 | chai.use(chaiAsPromised) 8 | const should = chai.should() 9 | 10 | describe('Builder', () => { 11 | interface Builder { 12 | builderStatic(build: string, options?: object): Promise<{source: string}> 13 | reset(): void 14 | bundle(bundleSpec: string, options?: object): Promise<{source: string}> 15 | buildStatic(bundleSpec: string, options?: object): Promise<{source: string}> 16 | config(config?: T): void 17 | } 18 | 19 | let builder: Builder = null 20 | 21 | beforeEach(() => { 22 | global['tsHost'] = undefined 23 | builder = new Builder('./') 24 | builder.reset() 25 | }) 26 | 27 | function defaultConfig() { 28 | return { 29 | baseUrl: "../", 30 | transpiler: "plugin", 31 | rollup: false, 32 | typescriptOptions: { 33 | "module": "system", 34 | "target": "es5", 35 | "jsx": "react", 36 | "tsconfig": false 37 | }, 38 | packages: { 39 | "testsrc": { 40 | "main": "index", 41 | "defaultExtension": "ts", 42 | "meta": {} 43 | }, 44 | "lib": { 45 | "main": "plugin.js" 46 | }, 47 | "typescript": { 48 | "main": "typescript.js", 49 | "meta": { 50 | "typescript.js": { 51 | "exports": "ts" 52 | } 53 | } 54 | } 55 | }, 56 | map: { 57 | "testsrc": "test/fixtures-es6/plugin/elisions", 58 | "plugin": "lib", 59 | "typescript": "node_modules/typescript/lib", 60 | "extend1": "test/fixtures-es6/plugin/tsconfig/extend1", 61 | "extend2": "test/fixtures-es6/plugin/tsconfig/extend2" 62 | } 63 | } 64 | } 65 | 66 | describe('tsconfig', () => { 67 | it('does not load tsconfig when not configured', async () => { 68 | const config = defaultConfig() as any 69 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 70 | config.packages["testsrc"].main = "good" 71 | builder.config(config) 72 | await builder.bundle('testsrc') 73 | .should.be.fulfilled 74 | 75 | const config2 = defaultConfig() as any 76 | config2.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 77 | builder.config(config2) 78 | await builder.bundle('testsrc') 79 | .should.be.rejectedWith(/Octal literals are not allowed in strict mode/) 80 | }) 81 | 82 | xit('supports tsconfig config option true', async () => { 83 | const config = defaultConfig() as any 84 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 85 | config.typescriptOptions.tsconfig = true; 86 | builder.config(config) 87 | await builder.bundle('testsrc').should.be.fulfilled 88 | }) 89 | 90 | it('tsconfig file "extends" supports relative path', async () => { 91 | const config = defaultConfig() as any 92 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 93 | config.typescriptOptions.tsconfig = "test/fixtures-es6/plugin/tsconfig/extends-relative.json" 94 | builder.config(config) 95 | await builder.bundle('testsrc').should.be.fulfilled 96 | }) 97 | 98 | it('tsconfig file "extends" supports package path', async () => { 99 | const config = defaultConfig() as any 100 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 101 | config.typescriptOptions.tsconfig = "test/fixtures-es6/plugin/tsconfig/extends-package.json" 102 | builder.config(config) 103 | 104 | await builder.bundle('testsrc').should.be.fulfilled 105 | }) 106 | 107 | it('tsconfig file extends supports transitive package path', async () => { 108 | const config = defaultConfig() as any 109 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 110 | config.typescriptOptions.tsconfig = "test/fixtures-es6/plugin/tsconfig/extends-transitive.json" 111 | builder.config(config) 112 | 113 | await builder.bundle('testsrc').should.be.fulfilled 114 | }) 115 | 116 | it('supports file meta tsconfig config option', async () => { 117 | const config = defaultConfig() as any 118 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 119 | 120 | const meta = { 121 | "*.ts": { 122 | "typescriptOptions": { 123 | "tsconfig": "testsrc/tsconfig.json" 124 | } 125 | } 126 | } 127 | config.packages.testsrc.meta = meta 128 | builder.config(config) 129 | await builder.bundle('testsrc').should.be.fulfilled 130 | }) 131 | 132 | it('file meta option overrides global tsconfig option', async () => { 133 | const config = defaultConfig() as any 134 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 135 | config.typescriptOptions.noImplicitUseStrict = false; 136 | 137 | const meta = { 138 | "*.ts": { 139 | "typescriptOptions": { 140 | "noImplicitUseStrict": true 141 | } 142 | } 143 | } 144 | config.packages.testsrc.meta = meta 145 | builder.config(config) 146 | await builder.bundle('testsrc').should.be.fulfilled 147 | }) 148 | }) 149 | 150 | xdescribe('commonjs', () => { 151 | it('supports module.id when outputting commonjs', () => { 152 | const config = defaultConfig() 153 | config.map["testsrc"] = "test/fixtures-es6/plugin/commonjs" 154 | config.typescriptOptions.module = "commonjs" 155 | builder.config(config) 156 | return builder.bundle('testsrc') 157 | .should.be.fulfilled 158 | }) 159 | 160 | it('compiles js files when default transpiler', () => { 161 | const config = defaultConfig() 162 | config.map["testsrc"] = "test/fixtures-es6/plugin/es6" 163 | config.packages["testsrc"].main = "index.js" 164 | config.packages["testsrc"].defaultExtension = "js" 165 | config.typescriptOptions.module = "commonjs" 166 | builder.config(config) 167 | return builder.bundle('testsrc') 168 | .should.be.fulfilled 169 | }) 170 | }) 171 | 172 | describe('rollup', () => { 173 | it('strips out reference files when rolled up', async () => { 174 | const config = defaultConfig() 175 | config.map["testsrc"] = "test/fixtures-es6/plugin/reference" 176 | config.typescriptOptions.module = "es2015" 177 | builder.config(config) 178 | const result = await builder.buildStatic('testsrc', { rollup: true, globalName: 'testsrc' }) 179 | .should.be.fulfilled 180 | //console.log(result.source) 181 | result.source.length.should.equal(476) 182 | result.source.indexOf('(function (global, factory').should.equal(0) 183 | }) 184 | 185 | xit('bundles without rollup when outputting commonjs', async () => { 186 | const config = defaultConfig() 187 | config.map["testsrc"] = "test/fixtures-es6/plugin/reference" 188 | config.typescriptOptions.module = "commonjs" 189 | builder.config(config) 190 | const result = await builder.buildStatic('testsrc', { rollup: true, globalName: 'testsrc' }) 191 | .should.be.fulfilled 192 | //console.log(result.source) 193 | result.source.length.should.equal(4401) 194 | result.source.indexOf('(function (global, factory').should.not.equal(0) 195 | }) 196 | 197 | it('does not use rollup when bundling', async () => { 198 | const config = defaultConfig() 199 | config.map["testsrc"] = "test/fixtures-es6/plugin/reference" 200 | config.typescriptOptions.module = "system" 201 | builder.config(config) 202 | const result = await builder.bundle('testsrc', { rollup: false }) 203 | .should.be.fulfilled 204 | //console.log(result.source) 205 | result.source.length.should.equal(420) 206 | result.source.indexOf('(function (global, factory').should.not.equal(0) 207 | }) 208 | 209 | xit('automatically changes module from system -> es6 when building', async () => { 210 | const config = defaultConfig() 211 | config.map["testsrc"] = "test/fixtures-es6/plugin/reference" 212 | config.typescriptOptions.module = "system" 213 | config.typescriptOptions.target = "es2015" 214 | builder.config(config) 215 | const result = await builder.buildStatic('testsrc', { rollup: true, globalName: 'testsrc' }) 216 | .should.be.fulfilled 217 | //console.log(result.source) 218 | result.source.should.contain('const aconstant = 1234') 219 | result.source.length.should.equal(482) 220 | }) 221 | 222 | it('supports es6 modules with target es5', async () => { 223 | const config = defaultConfig() 224 | config.map["testsrc"] = "test/fixtures-es6/plugin/reference" 225 | config.typescriptOptions.module = "es2015" 226 | config.typescriptOptions.target = "es5" 227 | builder.config(config) 228 | const result = await builder.buildStatic('testsrc', { rollup: true, globalName: 'testsrc' }) 229 | .should.be.fulfilled 230 | //console.log(result.source) 231 | result.source.should.contain('var aconstant = 1234') 232 | result.source.length.should.equal(476) 233 | result.source.indexOf('(function (global, factory').should.equal(0) 234 | }) 235 | 236 | it('supports syntheticDefaultImports when outputting es2015 modules', async () => { 237 | const config = defaultConfig() 238 | config.map["testsrc"] = "test/fixtures-es6/plugin/synthetic" 239 | config.map["somelib"] = "test/fixtures-es6/plugin/js/somelib.js" 240 | config.typescriptOptions.module = "es2015" 241 | config.typescriptOptions.target = "es5" 242 | 243 | builder.config(config) 244 | const result = await builder.buildStatic('testsrc', { rollup: true, globalName: 'testsrc' }) 245 | .should.be.fulfilled 246 | //console.log(result.source) 247 | result.source.should.contain('module.exports = 42') 248 | }) 249 | 250 | it('strips out elided modules when rolled up', async () => { 251 | const config = defaultConfig() 252 | config.map["testsrc"] = "test/fixtures-es6/plugin/execute" 253 | config.typescriptOptions.module = "es2015" 254 | config.typescriptOptions.target = "es5" 255 | builder.config(config) 256 | const result = await builder.buildStatic('testsrc', { rollup: true, globalName: 'testsrc' }) 257 | .should.be.fulfilled 258 | //console.log(result.source) 259 | result.source.indexOf('counter.imported += 1').should.be.above(-1); 260 | result.source.indexOf('counter.elided += 1').should.be.equal(-1); 261 | }) 262 | }) 263 | 264 | it('supports dynamic import when bundling to esnext modules', async () => { 265 | const config = defaultConfig() 266 | config.map["testsrc"] = "test/fixtures-es6/plugin/dynamic" 267 | config.typescriptOptions.module = "esnext" 268 | config.typescriptOptions.target = "es5" 269 | builder.config(config) 270 | const result = await builder.bundle('testsrc', {}) 271 | //console.log(result.source) 272 | result.source.should.contain('_context.import(\'') 273 | }) 274 | 275 | it('supports dynamic import when building to esnext modules', async () => { 276 | const config = defaultConfig() 277 | config.map["testsrc"] = "test/fixtures-es6/plugin/dynamic" 278 | config.typescriptOptions.module = "esnext" 279 | config.typescriptOptions.target = "es5" 280 | builder.config(config) 281 | const result = await builder.buildStatic('testsrc', {}) 282 | //console.log(result.source) 283 | result.source.should.contain('_context.import(\'') 284 | }) 285 | }) 286 | -------------------------------------------------------------------------------- /test/compiler-host-spec.ts: -------------------------------------------------------------------------------- 1 | import chai = require('chai') 2 | import ts from 'typescript' 3 | import { CompilerHost } from '../src/compiler-host' 4 | 5 | const should = chai.should() 6 | 7 | describe('Host', () => { 8 | 9 | let host 10 | beforeEach(function () { 11 | host = new CompilerHost() 12 | }) 13 | 14 | describe('addFile', () => { 15 | it('adds files', () => { 16 | const filename = 'filea.ts' 17 | const sourceFile = host.addFile(filename, 'sometext') 18 | const sourceFile1 = host.getSourceFile(filename) 19 | sourceFile.should.be.equal(sourceFile1) 20 | }) 21 | 22 | it('keeps same file if it has not changed', () => { 23 | const filename = 'filea.ts' 24 | const sourceFile1 = host.addFile(filename, 'sometext') 25 | const sourceFile2 = host.addFile(filename, 'sometext') 26 | sourceFile1.should.be.equal(sourceFile2) 27 | }) 28 | 29 | it('overwrites file if it has changed', () => { 30 | const filename = 'filea.ts' 31 | const sourceFile1 = host.addFile(filename, 'sometext') 32 | const sourceFile2 = host.addFile(filename, 'differenttext') 33 | sourceFile1.should.not.be.equal(sourceFile2) 34 | const sourceFile3 = host.getSourceFile(filename) 35 | sourceFile2.should.be.equal(sourceFile3) 36 | }) 37 | }) 38 | }) 39 | -------------------------------------------------------------------------------- /test/environment.js: -------------------------------------------------------------------------------- 1 | // manually provide the synthetic default exports when running in nodejs 2 | var typescript = require('typescript') 3 | typescript.default = typescript 4 | 5 | require('ts-node').register({ 6 | project: __dirname, 7 | ignoreWarnings: [2341], // access private members 8 | disableWarnings: false 9 | }) 10 | 11 | -------------------------------------------------------------------------------- /test/fixtures-es6/_references.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare var require: (string) => void; 4 | 5 | interface IDataType { 6 | key: string; 7 | value: any; 8 | } 9 | 10 | declare module decisions { 11 | const enum Either { 12 | Yes = 1, No = 2 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/ambient-consumer.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | export class Enigma implements IAmbient { 4 | hum() { 5 | console.log("aahooohaaahh") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/ambient-import-js.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import angular from "angular"; 4 | export default angular; 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/ambient-nested.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import a from "ambient2"; 4 | export {a}; -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/ambient-reference-disabled.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | class Enya implements IAmbient { 4 | hum() { 5 | console.log("mmmMmmmMMmm") 6 | } 7 | } 8 | 9 | class AmbientRoom { 10 | private acts: Array = []; 11 | 12 | constructor() { 13 | this.acts.push(new Enya()); 14 | } 15 | } 16 | 17 | export default AmbientRoom; 18 | -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/ambient-requires.d.ts: -------------------------------------------------------------------------------- 1 | 2 | // As generated by dts-bundle 3 | 4 | declare module 'exposed-ambient' { 5 | import {someInternalNumber} from "internal-ambient"; 6 | export default someInternalNumber; 7 | } 8 | 9 | declare module 'internal-ambient' { 10 | export var someInternalNumber: number; 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/ambient-requires.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import a from "exposed-ambient"; 4 | 5 | if (a == 42) 6 | console.log("correct!"); 7 | 8 | var b: number = a;; 9 | export default b; 10 | -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/ambient-resolve.ts: -------------------------------------------------------------------------------- 1 | import {music} from "ambient/ambient"; 2 | console.log(music.hum()); 3 | export default music; 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/backslash-reference.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import a from "ambient2"; 4 | export {a}; -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/resolved/ambient/ambient.d.ts: -------------------------------------------------------------------------------- 1 | interface IAmbient { 2 | hum(); 3 | } 4 | 5 | declare module 'ambient' { 6 | export var music: IAmbient; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/resolved/ambient/ambient.js: -------------------------------------------------------------------------------- 1 | class Jarre { 2 | hum() { 3 | console.log("mmmMmmmMMmm") 4 | } 5 | } 6 | 7 | export var music = new Jarre(); 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/resolved/ambient/ambient.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class Jarre implements IAmbient { 3 | hum() { 4 | console.log("mmmMmmmMMmm") 5 | } 6 | } 7 | 8 | export var music = new Jarre(); 9 | -------------------------------------------------------------------------------- /test/fixtures-es6/ambients/resolved/ambient/ambient2.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module "ambient2" { 4 | var a: IAmbient; 5 | export default a; 6 | } -------------------------------------------------------------------------------- /test/fixtures-es6/attypes/index.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | 3 | export class MyComponent extends React.Component { 4 | render() { 5 | return
Hello World!
; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/attypes/resolved/@types/react/index.d.ts: -------------------------------------------------------------------------------- 1 | export = React; 2 | export as namespace React; 3 | 4 | declare namespace React { 5 | export class Component { 6 | constructor(props: any); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures-es6/augmentation/ambient-aug.d.ts: -------------------------------------------------------------------------------- 1 | declare module "somelib" { 2 | export interface SomeLibStatic { 3 | method1(); 4 | } 5 | 6 | var __SomeLibStatic: SomeLibStatic; 7 | export default __SomeLibStatic; 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures-es6/augmentation/ambient-global-aug.d.ts: -------------------------------------------------------------------------------- 1 | declare module "somelib" { 2 | global { 3 | interface Object { 4 | sayHello(); 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/augmentation/ambient-global.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import "somelib" 4 | var a = {}; 5 | a.sayHello(); 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/augmentation/ambient.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module "somelib" { 4 | interface SomeLibStatic { 5 | method2(); 6 | } 7 | } 8 | 9 | import a from "somelib"; 10 | a.method1(); 11 | a.method2(); 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/fixtures-es6/augmentation/external.ts: -------------------------------------------------------------------------------- 1 | declare module "somelib" { 2 | interface SomeLibStatic { 3 | method2(); 4 | } 5 | } 6 | 7 | import a from "somelib"; 8 | a.method1(); 9 | a.method2(); 10 | -------------------------------------------------------------------------------- /test/fixtures-es6/augmentation/global-aug.d.ts: -------------------------------------------------------------------------------- 1 | 2 | interface Object { 3 | sayGoodbye(); 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/augmentation/global.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var a = {}; 4 | a.sayGoodbye(); 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/augmentation/resolved/somelib/somelib.d.ts: -------------------------------------------------------------------------------- 1 | export interface SomeLibStatic { 2 | method1(); 3 | } 4 | 5 | declare var __SomeLibStatic: SomeLibStatic; 6 | export default __SomeLibStatic; 7 | -------------------------------------------------------------------------------- /test/fixtures-es6/circular/circular.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | class Sun implements circular1.Sun { 4 | eclipse(deg) { 5 | console.log('woof!'); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/circular/circular1.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module circular1 { 4 | interface Sun extends circular2.Star { 5 | eclipse(deg: number); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/circular/circular2.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module circular2 { 4 | interface Star {} 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/css/import-css.ts: -------------------------------------------------------------------------------- 1 | import './some-css.css'; 2 | export var style = undefined; -------------------------------------------------------------------------------- /test/fixtures-es6/css/some-css.css: -------------------------------------------------------------------------------- 1 | button { 2 | text-transform: uppercase 3 | } -------------------------------------------------------------------------------- /test/fixtures-es6/es3/trailing-comma.ts: -------------------------------------------------------------------------------- 1 | var obj = { 2 | "one": "edna", 3 | "two": "dve", 4 | "three": "tree", 5 | }; 6 | 7 | export = obj; -------------------------------------------------------------------------------- /test/fixtures-es6/external.d.ts: -------------------------------------------------------------------------------- 1 | interface INgStatic { 2 | bootstrap(name: string, deps: any); 3 | } 4 | 5 | declare module "angular" { 6 | var angular: INgStatic; 7 | export default angular; 8 | } -------------------------------------------------------------------------------- /test/fixtures-es6/external/dependency.ts: -------------------------------------------------------------------------------- 1 | export var num = 37; 2 | //module.exports = 37; 3 | -------------------------------------------------------------------------------- /test/fixtures-es6/external/entry.ts: -------------------------------------------------------------------------------- 1 | import {num} from "./other"; 2 | import {num as dep} from "./dependency"; 3 | 4 | if (num > dep) 5 | alert('aaarrgghh!'); 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/external/other.ts: -------------------------------------------------------------------------------- 1 | //export import dep = require("./dependency"); 2 | export {num} from "./dependency"; 3 | -------------------------------------------------------------------------------- /test/fixtures-es6/html/html-cjs.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.html" { 2 | var __a__: string; 3 | export = __a__; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/html/html-es6.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.html" { 2 | var __a__: string; 3 | export default __a__; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/html/import-html-cjs.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import commonjsHtml = require("./some-html.html"); 4 | 5 | function sanitizeHtml(html: string) { 6 | return html.toLowerCase(); 7 | } 8 | 9 | export default sanitizeHtml(commonjsHtml); 10 | -------------------------------------------------------------------------------- /test/fixtures-es6/html/import-html.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import es6Html from "./some-html.html"; 4 | 5 | function sanitizeHtml(html: string) { 6 | return html.toLowerCase(); 7 | } 8 | 9 | export default sanitizeHtml(es6Html); 10 | -------------------------------------------------------------------------------- /test/fixtures-es6/html/some-html.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin-text.js: -------------------------------------------------------------------------------- 1 | exports.translate = function (load) { 2 | if (this.builder && this.transpiler) { 3 | load.metadata.format = 'esm'; 4 | return 'exp' + 'ort var __useDefault = true; exp' + 'ort default ' + JSON.stringify(load.source) + ';'; 5 | } 6 | 7 | load.metadata.format = 'amd'; 8 | return 'def' + 'ine(function() {\nreturn ' + JSON.stringify(load.source) + ';\n});'; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/ambient/index.ts: -------------------------------------------------------------------------------- 1 | import {a1} from 'external'; 2 | 3 | if (!a1) console.log(a1); 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/attypes/@types/reacty/index.d.ts: -------------------------------------------------------------------------------- 1 | export = Reacty; 2 | export as namespace Reacty; 3 | 4 | declare namespace Reacty { 5 | export class Component { 6 | constructor(props: any); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/attypes/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'reacty'; 2 | 3 | export class MyComponent extends React.Component { 4 | render() { 5 | return
Hello World!
; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/attypes/reacty/index.js: -------------------------------------------------------------------------------- 1 | export function Component() { 2 | Component.prototype.render = function render() { 3 | 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/commonjs/index.js: -------------------------------------------------------------------------------- 1 | module.exports.name = 42; 2 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/commonjs/index.ts: -------------------------------------------------------------------------------- 1 | declare var module: any; 2 | console.log(module.id); 3 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/dynamic/dynamic-dependency.ts: -------------------------------------------------------------------------------- 1 | export default 1 2 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/dynamic/index.ts: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return import('./dynamic-dependency') 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/elisions-exports/index.ts: -------------------------------------------------------------------------------- 1 | import {Result} from './types' 2 | 3 | export function getResult(): Result { 4 | return '!' 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/elisions-exports/types.ts: -------------------------------------------------------------------------------- 1 | export type Result = string; 2 | 3 | export enum Fruit { 4 | Apple, Banana, Cherry 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/elisions/bad/index.ts: -------------------------------------------------------------------------------- 1 | import {Result} from './types' 2 | 3 | export function getResult(): Result { 4 | return '!' 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/elisions/bad/types.ts: -------------------------------------------------------------------------------- 1 | export type Result = number; 2 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/elisions/index.ts: -------------------------------------------------------------------------------- 1 | import {Result} from './types' 2 | 3 | export function getResult(): Result { 4 | return '!' 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/elisions/types.ts: -------------------------------------------------------------------------------- 1 | export type Result = string; 2 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/es6/index.js: -------------------------------------------------------------------------------- 1 | import {a} from './second'; 2 | console.log(a); 3 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/es6/promise.ts: -------------------------------------------------------------------------------- 1 | const p: Promise = null; 2 | if(p !== null) p.then((x) => 1); 3 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/es6/second.js: -------------------------------------------------------------------------------- 1 | export var a = 34; 2 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/execute/counter.ts: -------------------------------------------------------------------------------- 1 | export const counter = { 2 | index: 0, 3 | elided: 0, 4 | imported: 0 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/execute/elided.ts: -------------------------------------------------------------------------------- 1 | import {counter} from './counter'; 2 | 3 | export interface ICounter { 4 | index: number; 5 | elided: number; 6 | } 7 | 8 | counter.elided += 1; 9 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/execute/imported.ts: -------------------------------------------------------------------------------- 1 | import {counter} from './counter'; 2 | 3 | counter.imported += 1; 4 | 5 | export function doit(): string { 6 | return 'answer' 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/execute/index.ts: -------------------------------------------------------------------------------- 1 | import { counter } from './counter' 2 | import { ICounter } from './elided' 3 | import { doit } from './imported' 4 | doit(); 5 | (counter as ICounter).index += 1; 6 | export { counter } 7 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/external/external.d.ts: -------------------------------------------------------------------------------- 1 | 2 | declare module "./second" { 3 | interface A { 4 | first(); 5 | } 6 | } 7 | 8 | export var a1: number; 9 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/external/external.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frankwallis/plugin-typescript/32b8c86c514595f60ec75c0cdffd12d9bea6a94b/test/fixtures-es6/plugin/external/external.js -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/external/second.d.ts: -------------------------------------------------------------------------------- 1 | export interface A { 2 | second(); 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/html/index.ts: -------------------------------------------------------------------------------- 1 | import template from './template.html' 2 | export default template; -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/html/template.html: -------------------------------------------------------------------------------- 1 |
hello
2 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/js/somelib.js: -------------------------------------------------------------------------------- 1 | module.exports = 42; 2 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/mixture/index.ts: -------------------------------------------------------------------------------- 1 | declare module 'testsrc/commonjs' { 2 | export function double(num: number): number; 3 | } 4 | 5 | declare module 'testsrc/esm' { 6 | export function triple(num: number): number; 7 | } 8 | 9 | declare module 'testsrc/amd' { 10 | export function quadruple(num: number): number; 11 | } 12 | 13 | import {double} from 'testsrc/commonjs'; 14 | import {triple} from 'testsrc/esm'; 15 | import {quadruple} from 'testsrc/amd'; 16 | 17 | export var total = double(triple(quadruple(2))); 18 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/reference/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | const aconstant = 1234; 3 | export default { a, aconstant }; 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/reference/types.d.ts: -------------------------------------------------------------------------------- 1 | declare var a: number; 2 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/strict/fail.ts: -------------------------------------------------------------------------------- 1 | export function sum(a: number, b: number) : string { 2 | return a + b; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/strict/missing.ts: -------------------------------------------------------------------------------- 1 | import a from './notthere'; 2 | if (a) console.log(a); 3 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/syntax/index.js: -------------------------------------------------------------------------------- 1 | val a = 10; 2 | export default a; 3 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/syntax/index.ts: -------------------------------------------------------------------------------- 1 | val a = 10; 2 | export default a; -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/synthetic/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import a from 'somelib'; 4 | export default a; -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/synthetic/somelib.d.ts: -------------------------------------------------------------------------------- 1 | declare module "somelib" { 2 | var a: number; 3 | export = a; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/tsconfig/extend1/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "extend2/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/tsconfig/extend2/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitUseStrict": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/tsconfig/extends-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "extend2/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/tsconfig/extends-relative.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./extend2/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/tsconfig/extends-transitive.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "extend1/tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/tsconfig/good.ts: -------------------------------------------------------------------------------- 1 | // Should not fail with noImplicitUseStrict: false or undefined 2 | export function add(a: number, b: number): number { 3 | return a + b; 4 | } 5 | 6 | console.log(add(1, 2)); 7 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/tsconfig/index.ts: -------------------------------------------------------------------------------- 1 | // Should fail with noImplicitUseStrict: false or undefined 2 | export var x = 010; 3 | export function add(a, b) { 4 | return a + b; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/plugin/tsconfig/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitUseStrict": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/program1/const-enums.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | function decide() { 4 | var today = new Date(); 5 | 6 | if (today.getDate() % 2 == 0) 7 | return decisions.Either.Yes; 8 | else 9 | return decisions.Either.No; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures-es6/program1/jsx-preserve.tsx: -------------------------------------------------------------------------------- 1 | declare module 'react'; 2 | 3 | import * as React from 'react' 4 | 5 | export class MyComponent extends React.Component { 6 | render () { 7 | return
hello
; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures-es6/program1/missing-import.ts: -------------------------------------------------------------------------------- 1 | import missing = require("./m_i_s_s_i_n_g"); 2 | export default !!missing; -------------------------------------------------------------------------------- /test/fixtures-es6/program1/nested-type-error.ts: -------------------------------------------------------------------------------- 1 | import a from "./one-import"; 2 | if (a.toUpperCase() == "I AM A NUMBER") 3 | throw new Error(); 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/program1/no-imports.ts: -------------------------------------------------------------------------------- 1 | export var a = 1; 2 | var b = new Promise(function (resolve, reject) { 3 | resolve(2); 4 | }); 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/program1/one-import.ts: -------------------------------------------------------------------------------- 1 | import {a} from "./no-imports"; 2 | var x; 3 | export default a; 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/program1/ref-import.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | export var a: IDataType = { 4 | key: "prop", 5 | value: 42 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures-es6/program1/ref-syntax-error.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var parser = syntax.Parser; 4 | export default parser; 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/program1/symbol.ts: -------------------------------------------------------------------------------- 1 | var sym = Symbol("foo"); 2 | export var obj = {[sym]: 1}; -------------------------------------------------------------------------------- /test/fixtures-es6/program1/syntax-error.d.ts: -------------------------------------------------------------------------------- 1 | declare module syntax { 2 | var Parser: string; 3 | var Lexer: AThingWhichIsNotDefined; 4 | } 5 | 6 | kjhdsfkj;;s,.,d.fmdlkj's/m 7 | -------------------------------------------------------------------------------- /test/fixtures-es6/program1/syntax-error.ts: -------------------------------------------------------------------------------- 1 | 2 | class MyClass { 3 | constructor () { 4 | val 4 = 9; 5 | } 6 | } -------------------------------------------------------------------------------- /test/fixtures-es6/program1/type-error.ts: -------------------------------------------------------------------------------- 1 | 2 | class MyClass { 3 | constructor () { 4 | } 5 | 6 | public getAge(): number { 7 | return "salmon"; 8 | } 9 | } -------------------------------------------------------------------------------- /test/fixtures-es6/tsconfig/alternate.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": false 4 | }, 5 | "files": [ 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/tsconfig/declaration.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": false 4 | }, 5 | "files": [ 6 | "./theirmodule.d.ts", 7 | "./module.ts" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures-es6/tsconfig/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": true 4 | }, 5 | "files": [ 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/tsconfig/theirmodule.d.ts: -------------------------------------------------------------------------------- 1 | declare module "theirmodule" { 2 | export var theirvariable: number; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/angular2-typings.ts: -------------------------------------------------------------------------------- 1 | import {angular2, nested} from "@angular2/core"; 2 | console.log(JSON.stringify(angular2)); 3 | console.log(JSON.stringify(nested)); 4 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/css-typings.ts: -------------------------------------------------------------------------------- 1 | import mystyles from 'cssmodules/mystyles.css' 2 | console.log(mystyles.rule1); 3 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/missing-package.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as missing from "missing_package"; 4 | console.log(JSON.stringify(missing)); 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/missing-typings.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as missing from "missing"; 4 | console.log(JSON.stringify(missing)); 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/missing.d.ts: -------------------------------------------------------------------------------- 1 | declare module "missing" { 2 | export var missing: string; 3 | } 4 | 5 | declare module "missing_package" { 6 | export var missing: string; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/@angular2/core/core.d.ts: -------------------------------------------------------------------------------- 1 | export * from './nested'; 2 | export var angular2: string; 3 | import "./shims.d.ts"; 4 | 5 | export function buildDelorean(): TimeMachine; 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/@angular2/core/core.js: -------------------------------------------------------------------------------- 1 | export * from "angular2/angular2.js"; 2 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/@angular2/core/nested.d.ts: -------------------------------------------------------------------------------- 1 | export var nested; -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/@angular2/core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular2", 3 | "version": "2.0.0-alpha.45", 4 | "description": "Angular 2 - a web framework for modern web apps", 5 | "homepage": "https://github.com/angular/angular", 6 | "bugs": "https://github.com/angular/angular/issues", 7 | "contributors": ["Alex Eagle ","Chirayu Krishnappa ","Jeff Cross ","Matias Niemela ","Misko Hevery ","Rado Kirov ","Tobias Bosch ","Victor Savkin ","Yegor Jbanov ","Jeremy Elbourn "], 8 | "license": "Apache-2.0", 9 | "repository": {"type":"git","url":"https://github.com/angular/angular.git"}, 10 | "dependencies": { 11 | "reflect-metadata": "0.1.2", 12 | "@reactivex/rxjs": "5.0.0-alpha.4", 13 | "zone.js": "0.5.8" 14 | }, 15 | "devDependencies": {}, 16 | "typings": "./angular2.d.ts" 17 | } 18 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/@angular2/core/shims.d.ts: -------------------------------------------------------------------------------- 1 | declare class TimeMachine { 2 | constructor (yearsHence: number); 3 | public go(); 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/cssmodules/mystyles.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/frankwallis/plugin-typescript/32b8c86c514595f60ec75c0cdffd12d9bea6a94b/test/fixtures-es6/typings/resolved/cssmodules/mystyles.css -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/cssmodules/mystyles.d.ts: -------------------------------------------------------------------------------- 1 | export var rule1: any; 2 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/missing/missing.js: -------------------------------------------------------------------------------- 1 | export * from "missing/missing.js"; -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/missing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular2", 3 | "version": "2.0.0-alpha.45", 4 | "description": "Angular 2 - a web framework for modern web apps", 5 | "homepage": "https://github.com/angular/angular", 6 | "bugs": "https://github.com/angular/angular/issues", 7 | "contributors": ["Alex Eagle ","Chirayu Krishnappa ","Jeff Cross ","Matias Niemela ","Misko Hevery ","Rado Kirov ","Tobias Bosch ","Victor Savkin ","Yegor Jbanov ","Jeremy Elbourn "], 8 | "license": "Apache-2.0", 9 | "repository": {"type":"git","url":"https://github.com/angular/angular.git"}, 10 | "dependencies": { 11 | "reflect-metadata": "0.1.2", 12 | "@reactivex/rxjs": "5.0.0-alpha.4", 13 | "zone.js": "0.5.8" 14 | }, 15 | "devDependencies": {} 16 | } 17 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/rxjs/Rx.d.ts: -------------------------------------------------------------------------------- 1 | export class Observable {} 2 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/rxjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rxjs", 3 | "main": "Rx.js", 4 | "typings": "Rx.d.ts" 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures-es6/typings/resolved/rxjs/rxjs.js: -------------------------------------------------------------------------------- 1 | export * from "rxjs/rxjs.js"; -------------------------------------------------------------------------------- /test/fixtures-es6/typings/rxjs-typings.ts: -------------------------------------------------------------------------------- 1 | import {Observable} from 'rxjs'; 2 | export default Observable; -------------------------------------------------------------------------------- /test/plugin-spec.ts: -------------------------------------------------------------------------------- 1 | import os = require('os') 2 | import chai = require('chai') 3 | import chaiAsPromised = require('chai-as-promised') 4 | import * as ts from 'typescript' 5 | import SystemJS = require('systemjs') 6 | 7 | chai.use(chaiAsPromised) 8 | const should = chai.should() 9 | 10 | describe('Plugin', () => { 11 | let System = null 12 | 13 | beforeEach(() => { 14 | global['tsHost'] = undefined 15 | var constructor = SystemJS['constructor'] as any 16 | System = new constructor() 17 | }) 18 | 19 | function defaultConfig() { 20 | return { 21 | baseUrl: "../", 22 | transpiler: "plugin", 23 | typescriptOptions: { 24 | "module": "system", 25 | "jsx": "react", 26 | "tsconfig": false 27 | } as any, 28 | packages: { 29 | "testsrc": { 30 | "main": "index", 31 | "defaultExtension": "ts", 32 | "meta": { 33 | "*.html": { 34 | "loader": "plugin-text" 35 | } 36 | } 37 | }, 38 | "lib": { 39 | "main": "plugin.js" 40 | }, 41 | "plugin-text": { 42 | "main": "plugin-text.js" 43 | }, 44 | "typescript": { 45 | "main": "typescript.js", 46 | "meta": { 47 | "typescript.js": { 48 | "exports": "ts" 49 | } 50 | } 51 | } 52 | }, 53 | map: { 54 | "testsrc": "test/fixtures-es6/plugin/elisions", 55 | "plugin": "lib", 56 | "plugin-text": "test/fixtures-es6", 57 | "typescript": "node_modules/typescript/lib", 58 | "extend1": "test/fixtures-es6/plugin/tsconfig/extend1", 59 | "extend2": "test/fixtures-es6/plugin/tsconfig/extend2" 60 | } 61 | } 62 | } 63 | 64 | describe('transpiler', () => { 65 | it('transpiles when configured as transpiler', async () => { 66 | const config = defaultConfig() as any 67 | config.map["testsrc"] = "test/fixtures-es6/plugin/execute" 68 | System.config(config) 69 | const mod = await System.import('testsrc') 70 | .should.be.fulfilled 71 | mod.counter.should.deep.equal({ index: 1, elided: 0, imported: 1 }) 72 | }) 73 | 74 | it('transpiles when configured via metadata', async () => { 75 | const config = defaultConfig() as any 76 | config.map["testsrc"] = "test/fixtures-es6/plugin/execute" 77 | 78 | const meta = { 79 | "*.ts": { 80 | "loader": "plugin" 81 | }, 82 | "*.tsx": { 83 | "loader": "plugin" 84 | } 85 | } 86 | config.transpiler = undefined 87 | config.packages["testsrc"].meta = meta 88 | System.config(config) 89 | const mod = await System.import('testsrc') 90 | .should.be.fulfilled 91 | mod.counter.should.deep.equal({ index: 1, elided: 0, imported: 1 }) 92 | }) 93 | 94 | it('fails build on syntax errors in ts files', async () => { 95 | const config = defaultConfig() as any 96 | config.map["testsrc"] = "test/fixtures-es6/plugin/syntax" 97 | System.config(config) 98 | return System.import('testsrc') 99 | .should.be.rejectedWith(/transpilation failed/) 100 | }) 101 | 102 | it('fails build on syntax errors in js files', async () => { 103 | const config = defaultConfig() as any 104 | config.map["testsrc"] = "test/fixtures-es6/plugin/syntax" 105 | config.packages["testsrc"].defaultExtension = 'js' 106 | System.config(config) 107 | return System.import('testsrc') 108 | .should.be.rejectedWith(/transpilation failed/) 109 | }) 110 | 111 | it('supports loading html files', async () => { 112 | const config = defaultConfig() as any 113 | config.map["testsrc"] = "test/fixtures-es6/plugin/html" 114 | System.config(config) 115 | const mod = await System.import('testsrc') 116 | .should.be.fulfilled 117 | mod.default.should.equal('
hello
' + os.EOL) 118 | }) 119 | 120 | it('compiles js commonjs files', async () => { 121 | const config = defaultConfig() 122 | config.map["testsrc"] = "test/fixtures-es6/plugin/commonjs" 123 | config.packages["testsrc"].defaultExtension = "js" 124 | System.config(config) 125 | const mod = await System.import('testsrc') 126 | .should.be.fulfilled 127 | mod.name.should.equal(42) 128 | }) 129 | }) 130 | 131 | describe('tsconfig', () => { 132 | it('does not load tsconfig when not configured', async () => { 133 | const config = defaultConfig() as any 134 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 135 | config.packages["testsrc"].main = "good" 136 | System.config(config) 137 | await System.import('testsrc') 138 | .should.be.fulfilled 139 | 140 | const config2 = defaultConfig() as any 141 | config2.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 142 | System.config(config2) 143 | await System.import('testsrc') 144 | .should.be.rejectedWith(/Octal literals are not allowed in strict mode/) 145 | }) 146 | 147 | xit('supports tsconfig config option true', async () => { 148 | const config = defaultConfig() as any 149 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 150 | config.typescriptOptions.tsconfig = true; 151 | System.config(config) 152 | await System.import('testsrc').should.be.fulfilled 153 | }) 154 | 155 | it('tsconfig file "extends" supports relative path', async () => { 156 | const config = defaultConfig() as any 157 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 158 | config.typescriptOptions.tsconfig = "test/fixtures-es6/plugin/tsconfig/extends-relative.json" 159 | System.config(config) 160 | await System.import('testsrc').should.be.fulfilled 161 | }) 162 | 163 | it('tsconfig file "extends" supports package path', async () => { 164 | const config = defaultConfig() as any 165 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 166 | config.typescriptOptions.tsconfig = "test/fixtures-es6/plugin/tsconfig/extends-package.json" 167 | System.config(config) 168 | 169 | await System.import('testsrc').should.be.fulfilled 170 | }) 171 | 172 | it('tsconfig file extends supports transitive package path', async () => { 173 | const config = defaultConfig() as any 174 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 175 | config.typescriptOptions.tsconfig = "test/fixtures-es6/plugin/tsconfig/extends-transitive.json" 176 | System.config(config) 177 | 178 | await System.import('testsrc').should.be.fulfilled 179 | }) 180 | 181 | it('supports file meta tsconfig config option', async () => { 182 | const config = defaultConfig() as any 183 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 184 | 185 | const meta = { 186 | "*.ts": { 187 | "typescriptOptions": { 188 | "tsconfig": "testsrc/tsconfig.json" 189 | } 190 | } 191 | } 192 | config.packages.testsrc.meta = meta 193 | System.config(config) 194 | await System.import('testsrc').should.be.fulfilled 195 | }) 196 | 197 | it('file meta option overrides global tsconfig option', async () => { 198 | const config = defaultConfig() as any 199 | config.map["testsrc"] = "test/fixtures-es6/plugin/tsconfig" 200 | config.typescriptOptions.noImplicitUseStrict = false; 201 | 202 | const meta = { 203 | "*.ts": { 204 | "typescriptOptions": { 205 | "noImplicitUseStrict": true 206 | } 207 | } 208 | } 209 | config.packages.testsrc.meta = meta 210 | System.config(config) 211 | await System.import('testsrc').should.be.fulfilled 212 | }) 213 | }) 214 | 215 | xdescribe('commonjs', () => { 216 | it('supports module.id when outputting commonjs', () => { 217 | const config = defaultConfig() 218 | config.map["testsrc"] = "test/fixtures-es6/plugin/commonjs" 219 | config.typescriptOptions.module = "commonjs" 220 | 221 | System.config(config) 222 | return System.import('testsrc') 223 | .should.be.fulfilled 224 | }) 225 | }) 226 | }) 227 | -------------------------------------------------------------------------------- /test/resolve-options-spec.ts: -------------------------------------------------------------------------------- 1 | import chai = require('chai') 2 | import sinon = require('sinon') 3 | import ts from 'typescript' 4 | import { parseOptions, resolveOptions } from '../src/resolve-options' 5 | 6 | const should = chai.should() 7 | 8 | function fetchJson(fileName: string, parentAddress: string): Promise { 9 | return Promise.resolve(JSON.stringify({ compilerOptions: { target: 'es2016' } })) 10 | } 11 | 12 | describe('Options', () => { 13 | 14 | describe('resolveOptions', () => { 15 | it('handles undefined configuration', async () => { 16 | const fileOptions = undefined 17 | const finalOptions = await resolveOptions(undefined, undefined, 'file1.ts', null) 18 | finalOptions.target.should.equal(ts.ScriptTarget.ES5) 19 | }) 20 | 21 | it('file metadata configuration takes precedence over global configuration', async () => { 22 | const globalConfig = { target: 'es2015' } 23 | const fileConfig = { target: 'es2017' } 24 | const finalOptions = await resolveOptions(globalConfig, fileConfig, 'file1.ts', null) 25 | finalOptions.target.should.equal(ts.ScriptTarget.ES2017) 26 | }) 27 | 28 | it('handles global tsconfig = true', async () => { 29 | const globalConfig = { tsconfig: true } 30 | const fetchSpy = sinon.spy(fetchJson) 31 | const finalOptions = await resolveOptions(globalConfig, undefined, 'file1.ts', fetchSpy) 32 | fetchSpy.calledOnce.should.be.true 33 | fetchSpy.firstCall.args[0].should.equal('tsconfig.json') 34 | fetchSpy.firstCall.args[1].should.equal('') 35 | }) 36 | 37 | it('handles file tsconfig = true', async () => { 38 | const fileConfig = { tsconfig: true } 39 | const fetchSpy = sinon.spy(fetchJson) 40 | const finalOptions = await resolveOptions(undefined, fileConfig, 'file1.ts', fetchSpy) 41 | fetchSpy.calledOnce.should.be.true 42 | fetchSpy.firstCall.args[0].should.equal('tsconfig.json') 43 | fetchSpy.firstCall.args[1].should.equal('file1.ts') 44 | }) 45 | 46 | it('loads the compiler options from tsconfig', async () => { 47 | const globalConfig = { tsconfig: true } 48 | const finalOptions = await resolveOptions(globalConfig, undefined, 'file1.ts', fetchJson) 49 | finalOptions.target.should.equal(ts.ScriptTarget.ES2016) 50 | }) 51 | 52 | it('handles tsconfig = ', async () => { 53 | const globalConfig = { tsconfig: 'anothertsconfig.json' } 54 | const fetchSpy = sinon.spy(fetchJson) 55 | const finalOptions = await resolveOptions(globalConfig, undefined, 'file1.ts', fetchSpy) 56 | fetchSpy.calledOnce.should.be.true 57 | fetchSpy.firstCall.args[0].should.equal('anothertsconfig.json') 58 | fetchSpy.firstCall.args[1].should.equal('') 59 | }) 60 | 61 | it('fileConfig handles extends, fetching transitively', async () => { 62 | const fileConfig = { tsconfig: true } 63 | 64 | const fetchJson = (fileName, parentAddress) => 65 | parentAddress !== 'tsconfig.extended.json' 66 | ? Promise.resolve(JSON.stringify({ 67 | extends: 'tsconfig.extended.json', 68 | compilerOptions: { 69 | target: 'es2017' 70 | } 71 | })) 72 | : Promise.resolve(JSON.stringify({ 73 | compilerOptions: { 74 | downlevelIteration: true 75 | } 76 | })) 77 | 78 | const finalOptions = await resolveOptions(undefined, fileConfig, 'file1.ts', fetchJson) 79 | finalOptions.downlevelIteration.should.be.true 80 | finalOptions.target.should.equal(ts.ScriptTarget.ES2017) 81 | }) 82 | 83 | it('fileConfig handles extends, traversing multiple files', async () => { 84 | const fileConfig = { tsconfig: true } 85 | 86 | const fetchJson = (fileName, parentAddress) => 87 | parentAddress === 'tsconfig.extended.json' 88 | ? Promise.resolve(JSON.stringify({ 89 | extends: 'tsconfig.another-extended.json', 90 | compilerOptions: { 91 | target: 'es2017' 92 | } 93 | })) 94 | : parentAddress === 'tsconfig.another-extended.json' 95 | ? Promise.resolve(JSON.stringify({ 96 | compilerOptions: { 97 | downlevelIteration: true 98 | } 99 | })) 100 | : Promise.resolve(JSON.stringify({ 101 | extends: 'tsconfig.extended.json', 102 | compilerOptions: { 103 | module: 'esnext' 104 | } 105 | })) 106 | 107 | const finalOptions = await resolveOptions(undefined, fileConfig, 'file1.ts', fetchJson) 108 | finalOptions.downlevelIteration.should.be.true 109 | finalOptions.target.should.equal(ts.ScriptTarget.ES2017) 110 | finalOptions.module.should.equal(ts.ModuleKind.ESNext) 111 | }) 112 | 113 | it('fileConfig handles extends, giving precedence to extending file', async () => { 114 | const fileConfig = { tsconfig: true } 115 | 116 | const fetchJson = (fileName, parentAddress) => 117 | parentAddress !== 'tsconfig.extended.json' 118 | ? Promise.resolve(JSON.stringify({ 119 | extends: 'tsconfig.extended.json', 120 | compilerOptions: { 121 | target: 'es2017' 122 | } 123 | })) 124 | : Promise.resolve(JSON.stringify({ 125 | compilerOptions: { 126 | target: 'es5' 127 | } 128 | })) 129 | 130 | const finalOptions = await resolveOptions(undefined, fileConfig, 'file1.ts', fetchJson) 131 | finalOptions.target.should.equal(ts.ScriptTarget.ES2017) 132 | }) 133 | 134 | it('globalConfig handles extends, fetching transitively', async () => { 135 | const globalConfig = { tsconfig: true } 136 | 137 | const fetchJson = (fileName, parentAddress) => 138 | parentAddress !== 'tsconfig.extended.json' 139 | ? Promise.resolve(JSON.stringify({ 140 | extends: 'tsconfig.extended.json', 141 | compilerOptions: { 142 | target: 'es2017' 143 | } 144 | })) 145 | : Promise.resolve(JSON.stringify({ 146 | compilerOptions: { 147 | downlevelIteration: true 148 | } 149 | })) 150 | 151 | const finalOptions = await resolveOptions(globalConfig, undefined, 'file1.ts', fetchJson) 152 | finalOptions.downlevelIteration.should.be.true 153 | finalOptions.target.should.equal(ts.ScriptTarget.ES2017) 154 | }) 155 | 156 | it('globalConfig handles tsconfig.extends, traversing multiple files', async () => { 157 | const globalConfig = { tsconfig: true } 158 | 159 | const fetchJson = (fileName, parentAddress) => 160 | parentAddress === 'tsconfig.extended.json' 161 | ? Promise.resolve(JSON.stringify({ 162 | extends: 'tsconfig.another-extended.json', 163 | compilerOptions: { 164 | target: 'es2017' 165 | } 166 | })) 167 | : parentAddress === 'tsconfig.another-extended.json' 168 | ? Promise.resolve(JSON.stringify({ 169 | compilerOptions: { 170 | downlevelIteration: true 171 | } 172 | })) 173 | : Promise.resolve(JSON.stringify({ 174 | extends: 'tsconfig.extended.json', 175 | compilerOptions: { 176 | module: 'esnext' 177 | } 178 | })) 179 | 180 | const finalOptions = await resolveOptions(globalConfig, undefined, 'file1.ts', fetchJson) 181 | finalOptions.downlevelIteration.should.be.true 182 | finalOptions.target.should.equal(ts.ScriptTarget.ES2017) 183 | finalOptions.module.should.equal(ts.ModuleKind.ESNext) 184 | }) 185 | 186 | it('globalConfig handles extends, giving precedence to extending file', async () => { 187 | const globalConfig = { tsconfig: true } 188 | 189 | const fetchJson = (fileName, parentAddress) => 190 | parentAddress !== 'tsconfig.extended.json' 191 | ? Promise.resolve(JSON.stringify({ 192 | extends: 'tsconfig.extended.json', 193 | compilerOptions: { 194 | target: 'es2017' 195 | } 196 | })) 197 | : Promise.resolve(JSON.stringify({ 198 | compilerOptions: { 199 | target: 'es5' 200 | } 201 | })) 202 | 203 | const finalOptions = await resolveOptions(globalConfig, undefined, 'file1.ts', fetchJson) 204 | finalOptions.target.should.equal(ts.ScriptTarget.ES2017) 205 | }) 206 | 207 | it('specified configuration takes precedence over tsconfig configuration', async () => { 208 | const globalConfig = { tsconfig: true, target: 'es2017' } 209 | const finalOptions = await resolveOptions(globalConfig, undefined, 'file1.ts', fetchJson) 210 | finalOptions.target.should.equal(ts.ScriptTarget.ES2017) 211 | }) 212 | }) 213 | 214 | describe('parseOptions', () => { 215 | it('defaults the config', () => { 216 | const options = parseOptions({}) 217 | options.module.should.be.equal(ts.ModuleKind.System) 218 | options.target.should.be.equal(ts.ScriptTarget.ES5) 219 | options.jsx.should.be.equal(ts.JsxEmit.None) 220 | options.allowNonTsExtensions.should.be.true 221 | options.should.not.have.property("noImplicitAny") 222 | }) 223 | 224 | it('uses the config passed in', () => { 225 | const options = parseOptions({ 226 | noImplicitAny: true 227 | }) 228 | options.module.should.be.equal(ts.ModuleKind.System) 229 | options.target.should.be.equal(ts.ScriptTarget.ES5) 230 | options.allowNonTsExtensions.should.be.true 231 | options.noImplicitAny.should.be.true 232 | }) 233 | 234 | it('handles the target option', () => { 235 | let options = parseOptions({ 236 | target: "eS3" 237 | }) 238 | options.target.should.be.equal(ts.ScriptTarget.ES3) 239 | options = parseOptions({ 240 | target: ts.ScriptTarget.ES3 241 | }) 242 | options.target.should.be.equal(ts.ScriptTarget.ES3) 243 | options = parseOptions({ 244 | target: "Es5" 245 | }) 246 | options.target.should.be.equal(ts.ScriptTarget.ES5) 247 | }) 248 | 249 | it('handles the jsx option', () => { 250 | const options = parseOptions({ 251 | jsx: "reAct" 252 | }) 253 | options.jsx.should.be.equal(ts.JsxEmit.React) 254 | }) 255 | 256 | it('forces moduleResolution to classic', () => { 257 | const options = parseOptions({ 258 | moduleResolution: ts.ModuleResolutionKind.NodeJs 259 | }) 260 | options.moduleResolution.should.be.equal(ts.ModuleResolutionKind.Classic) 261 | }) 262 | 263 | it('handles the lib option', () => { 264 | const options = parseOptions({ 265 | lib: ["es5", "es2015.promise"] 266 | }) 267 | options.lib.should.deep.equal(["es5", "es2015.promise"]) 268 | }) 269 | }) 270 | }) 271 | -------------------------------------------------------------------------------- /test/transpiler-spec.ts: -------------------------------------------------------------------------------- 1 | import ts from 'typescript' 2 | import fs = require('fs') 3 | import path = require('path') 4 | import chai = require('chai') 5 | import { CompilerHost } from '../src/compiler-host' 6 | import { transpile } from '../src/transpiler' 7 | import { formatErrors } from '../src/format-errors' 8 | import { parseOptions } from '../src/resolve-options' 9 | 10 | const should = chai.should() 11 | const defaultOptions = parseOptions({}) 12 | 13 | const oneImport = fs.readFileSync(require.resolve('./fixtures-es6/program1/one-import.ts'), 'utf8') 14 | const jsxPreserve = fs.readFileSync(require.resolve('./fixtures-es6/program1/jsx-preserve.tsx'), 'utf8') 15 | const es6Symbol = fs.readFileSync(require.resolve('./fixtures-es6/program1/symbol.ts'), 'utf8') 16 | const syntaxError = fs.readFileSync(require.resolve('./fixtures-es6/program1/syntax-error.ts'), 'utf8') 17 | const constEnums = fs.readFileSync(require.resolve('./fixtures-es6/program1/const-enums.ts'), 'utf8') 18 | const trailingComma = fs.readFileSync(require.resolve('./fixtures-es6/es3/trailing-comma.ts'), 'utf8') 19 | 20 | describe('Transpiler', () => { 21 | 22 | function doTranspile(sourceName: string, source: string, options: ts.CompilerOptions = defaultOptions) { 23 | const host = new CompilerHost() 24 | host.addFile(sourceName, source, options.target) 25 | return transpile(sourceName, parseOptions(options), host) 26 | } 27 | 28 | it('transpiles typescript successfully', () => { 29 | const output = doTranspile('one-import.ts', oneImport) 30 | formatErrors(output.diags, console as any) 31 | output.should.have.property('failure', false) 32 | output.should.have.property('diags').with.lengthOf(0) 33 | output.should.have.property('js').with.lengthOf(407) 34 | }) 35 | 36 | it('transpiles javascript successfully', () => { 37 | const output = doTranspile('no-import.js', "var a = 10; export default a") 38 | formatErrors(output.diags, console as any) 39 | output.should.have.property('failure', false) 40 | output.should.have.property('diags').with.lengthOf(0) 41 | output.should.have.property('js').with.lengthOf(276) 42 | }) 43 | 44 | it('supports jsx preserve', () => { 45 | const options = parseOptions({ 46 | jsx: 'preserve' 47 | }) 48 | const output = doTranspile('jsx-preserve.tsx', jsxPreserve, options) 49 | formatErrors(output.diags, console as any) 50 | output.should.have.property('failure', false) 51 | output.should.have.property('diags').with.lengthOf(0) 52 | output.js.should.contain('
hello
') 53 | }) 54 | 55 | it('supports jsx react', () => { 56 | const options = parseOptions({ 57 | jsx: 'react' 58 | }) 59 | const output = doTranspile('jsx-preserve.tsx', jsxPreserve, options) 60 | formatErrors(output.diags, console as any) 61 | output.should.have.property('failure', false) 62 | output.should.have.property('diags').with.lengthOf(0) 63 | output.js.should.not.contain('
hello
') 64 | output.js.should.contain('React.createElement') 65 | }) 66 | 67 | it('removes SourceMappingURL', () => { 68 | const output = doTranspile('one-import.ts', oneImport) 69 | output.js.should.not.contain("SourceMappingURL") 70 | }) 71 | 72 | it('removes SourceMappingURL from jsx output', () => { 73 | const options = parseOptions({ 74 | jsx: 'preserve' 75 | }) 76 | const output = doTranspile('jsx-preserve.tsx', jsxPreserve, options) 77 | output.js.should.not.contain("SourceMappingURL") 78 | }) 79 | 80 | it('returns sourceMap', () => { 81 | const output = doTranspile('one-import.ts', oneImport) 82 | output.should.have.property('sourceMap').with.lengthOf(137) 83 | }) 84 | 85 | it('catches syntax errors', () => { 86 | const output = doTranspile('syntax-error.ts', syntaxError) 87 | //formatErrors(output.diags, console as any) 88 | output.should.have.property('failure', true) 89 | output.should.have.property('diags').with.lengthOf(1) 90 | }) 91 | 92 | it('catches configuation errors', () => { 93 | const options = parseOptions({ 94 | emitDecoratorMetadata: true, 95 | experimentalDecorators: false 96 | }) 97 | const output = doTranspile('one-import.ts', oneImport, options) 98 | //formatErrors(output.diags, console as any) 99 | output.should.have.property('failure', true) 100 | output.should.have.property('diags').with.lengthOf(1) 101 | output.diags[0].code.should.be.equal(5052) 102 | }) 103 | 104 | it('overrides invalid config options', () => { 105 | const options = parseOptions({ 106 | noEmitOnError: true, 107 | out: "somefile.js", 108 | declaration: true, 109 | noLib: false, 110 | noEmit: true 111 | }) 112 | const output = doTranspile('one-import.ts', oneImport, options) 113 | formatErrors(output.diags, console as any) 114 | output.should.have.property('failure', false) 115 | output.should.have.property('diags').with.lengthOf(0) 116 | output.js.length.should.be.greaterThan(0) 117 | }) 118 | 119 | xit('errors on const enums', () => { 120 | const output = doTranspile('const-enums.ts', constEnums) 121 | //formatErrors(output.diags, console as any) 122 | output.should.have.property('failure', true) 123 | output.should.have.property('diags').with.lengthOf(1) 124 | }) 125 | 126 | it('uses sourceMap option', () => { 127 | const options = parseOptions({ 128 | sourceMap: false 129 | }) 130 | const output = doTranspile('symbol.ts', es6Symbol, options) 131 | should.not.exist(output.sourceMap) 132 | }) 133 | 134 | it('uses target option', () => { 135 | let options = parseOptions({ 136 | target: "es3" 137 | }) 138 | const es3output = doTranspile('trailing-comma.ts', trailingComma, options) 139 | 140 | options = parseOptions({ 141 | target: "es5" 142 | }) 143 | const es5output = doTranspile('trailing-comma.ts', trailingComma, options) 144 | es3output.should.not.be.equal(es5output) 145 | }) 146 | }) 147 | -------------------------------------------------------------------------------- /test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "types": [ 6 | "node", 7 | "mocha", 8 | "chai", 9 | "chai-as-promised", 10 | "systemjs" 11 | ], 12 | "moduleResolution": "node", 13 | "allowSyntheticDefaultImports": true 14 | }, 15 | "include": ["./*.ts", "../src/types.d.ts"] 16 | } 17 | -------------------------------------------------------------------------------- /test/utils-spec.ts: -------------------------------------------------------------------------------- 1 | import chai = require('chai') 2 | import { 3 | isRelative, 4 | isAbsolute, 5 | isAmbientImport, 6 | isTypescript, 7 | isTypescriptDeclaration, 8 | isJavaScript, 9 | isJSX, 10 | isSourceMap, 11 | tsToJs, 12 | tsToJsMap, 13 | convertToDts, 14 | isJson, 15 | stripDoubleExtension 16 | } from '../src/utils' 17 | 18 | const should = chai.should() 19 | 20 | describe('Utils', () => { 21 | 22 | describe('isRelative', () => { 23 | it('does not match absolute paths', () => { 24 | isRelative("/a/b.c").should.be.false 25 | isRelative("/a/b").should.be.false 26 | }) 27 | 28 | it('matches relative paths', () => { 29 | isRelative("../a/b").should.be.true 30 | isRelative("./a/b").should.be.true 31 | }) 32 | 33 | it('does not match external paths', () => { 34 | isRelative("b").should.be.false 35 | isRelative("a/b.c").should.be.false 36 | }) 37 | }) 38 | 39 | describe('isAbsolute', () => { 40 | it('matches absolute paths', () => { 41 | isAbsolute("/a/b.c").should.be.true 42 | isAbsolute("/a/b").should.be.true 43 | }) 44 | 45 | it('does not match relative paths', () => { 46 | isAbsolute("../a/b").should.be.false 47 | isAbsolute("./a/b").should.be.false 48 | }) 49 | 50 | it('does not match external paths', () => { 51 | isAbsolute("b").should.be.false 52 | isAbsolute("a/b.c").should.be.false 53 | }) 54 | }) 55 | 56 | describe('isAmbientImport', () => { 57 | it('does not match absolute paths', () => { 58 | isAmbientImport("/a/b.c").should.be.false 59 | isAmbientImport("/a/b").should.be.false 60 | }) 61 | 62 | it('does not match relative paths', () => { 63 | isAmbientImport("../a/b").should.be.false 64 | isAmbientImport("./a/b").should.be.false 65 | }) 66 | 67 | it('matches external paths', () => { 68 | isAmbientImport("b").should.be.true 69 | isAmbientImport("a/b.c").should.be.true 70 | }) 71 | }) 72 | 73 | describe('tsToJs', () => { 74 | it('changes the file extension', () => { 75 | tsToJs('a.ts').should.be.equal('a.js') 76 | tsToJs('a.ts.ts').should.be.equal('a.ts.js') 77 | }) 78 | 79 | it('ignores files with wrong extension', () => { 80 | tsToJs('a.jts').should.be.equal('a.jts') 81 | }) 82 | }) 83 | 84 | describe('tsToJsMap', () => { 85 | it('changes the file extension', () => { 86 | tsToJsMap('a.ts').should.be.equal('a.js.map') 87 | tsToJsMap('a.ts.ts').should.be.equal('a.ts.js.map') 88 | }) 89 | 90 | it('ignores files with wrong extension', () => { 91 | tsToJsMap('a.jts').should.be.equal('a.jts') 92 | }) 93 | }) 94 | 95 | describe('convertToDts', () => { 96 | it('changes the file extension', () => { 97 | convertToDts('a.js').should.be.equal('a.d.ts') 98 | convertToDts('a.js.js').should.be.equal('a.js.d.ts') 99 | convertToDts('a.json').should.be.equal('a.d.ts') 100 | convertToDts('a.css').should.be.equal('a.d.ts') 101 | convertToDts('a.scss').should.be.equal('a.d.ts') 102 | }) 103 | }) 104 | 105 | describe('isTypescript', () => { 106 | it('detects source files', () => { 107 | isTypescript('a.ts').should.be.true 108 | isTypescript('a.js').should.be.false 109 | isTypescript('a.ts.js').should.be.false 110 | isTypescript('a.ts.ats').should.be.false 111 | }) 112 | 113 | it('detects declaration files', () => { 114 | isTypescript('a.d.ts').should.be.true 115 | }) 116 | 117 | it('detects tsx files', () => { 118 | isTypescript('a.d.tsx').should.be.true 119 | isTypescript('a.tsx').should.be.true 120 | }) 121 | }) 122 | 123 | describe('isJavaScript', () => { 124 | it('detects javascript source files', () => { 125 | isJavaScript('a.ts').should.be.false 126 | isJavaScript('a.js').should.be.true 127 | isJavaScript('a.ts.js').should.be.true 128 | isJavaScript('a.ts.ajs').should.be.false 129 | }) 130 | }) 131 | 132 | describe('isJSX', () => { 133 | it('detects jsx source files', () => { 134 | isJSX('a.tsx').should.be.false 135 | isJSX('a.jsx').should.be.true 136 | isJSX('a.ts.jsx').should.be.true 137 | isJSX('a.ts.ajsx').should.be.false 138 | }) 139 | }) 140 | 141 | describe('isSourceMap', () => { 142 | it('detects source map files', () => { 143 | isSourceMap('a.map').should.be.true 144 | isSourceMap('a.jmap').should.be.false 145 | isSourceMap('a.mapj').should.be.false 146 | }) 147 | }) 148 | 149 | describe('isJson', () => { 150 | it('detects json files', () => { 151 | isJson('a.json').should.be.true 152 | isJson('a.json.js').should.be.false 153 | isJson('fixjson').should.be.false 154 | }) 155 | }) 156 | 157 | describe('isTypescriptDeclaration', () => { 158 | it('detects declaration files', () => { 159 | isTypescriptDeclaration('a.d.ts').should.be.true 160 | isTypescriptDeclaration('a.js').should.be.false 161 | isTypescriptDeclaration('a.d.ts.js').should.be.false 162 | isTypescriptDeclaration('a.ts.ats').should.be.false 163 | }) 164 | 165 | it('detects tsx declaration files', () => { 166 | isTypescriptDeclaration('a.d.tsx').should.be.true 167 | }) 168 | 169 | it('ignores source files', () => { 170 | isTypescriptDeclaration('a.ts').should.be.false 171 | isTypescriptDeclaration('a.tsx').should.be.false 172 | }) 173 | }) 174 | 175 | describe('stripDoubleExtension', () => { 176 | it('strips double extension', () => { 177 | const filename = stripDoubleExtension("a.js.ts") 178 | filename.should.equal("a.js") 179 | }) 180 | 181 | it('ignores non-extension', () => { 182 | const filename = stripDoubleExtension("amodule.core.ts") 183 | filename.should.equal("amodule.core.ts") 184 | }) 185 | 186 | it('handles normal names', () => { 187 | const filename = stripDoubleExtension("amodule.ts") 188 | filename.should.equal("amodule.ts") 189 | }) 190 | }) 191 | }) 192 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "tmp/es6", 4 | "lib": ["es5", "es2015.promise", "es2015.collection", "dom"], 5 | "target": "es5", 6 | "module": "es2015", 7 | "removeComments": true, 8 | "moduleResolution": "node", 9 | "importHelpers": true, 10 | "inlineSourceMap": false, 11 | "rootDir": "./src", 12 | "allowSyntheticDefaultImports": true, 13 | "noImplicitReturns": true, 14 | "noImplicitThis": false, 15 | "noFallthroughCasesInSwitch": true 16 | }, 17 | "include": ["./src"] 18 | } 19 | --------------------------------------------------------------------------------