alexjoverm / typescript-library-starter

Starter kit with zero-config for building a library in TypeScript, featuring RollupJS, Jest, Prettier, TSLint, Semantic Release, and more!
MIT License
4.37k stars 492 forks source link

Generated umd.js.map and es5.js.map files do not point to the .ts source files #61

Closed alexandru closed 7 years ago

alexandru commented 7 years ago

This starter is great, except for one thing. The generated files in dist point to files in compiled/, which:

  1. are not the Typescript source files in src
  2. do not get distributed in the final bundle anyway

Sample from a fresh build:

{"version":3,"file":"hello.umd.js","sources":["../compiled/hello.js"],"sourcesContent":["// Import here Polyfills if needed. Recommended core-js (npm i -D core-js)\n// import \"core-js/fn/array.find\"\n// ...\nvar DummyClass = (function () {\n    function DummyClass() {\n    }\n    return DummyClass;\n}());\nexport default DummyClass;\n//# sourceMappingURL=hello.js.map"],"names":[],"mappings":";;;;;;AAAA;;;AAGA,IAAI,UAAU,IAAI,YAAY;IAC1B,SAAS,UAAU,GAAG;KACrB;IACD,OAAO,UAAU,CAAC;CACrB,EAAE,CAAC,CAAC,AACL,AAA0B,AAC1B;;;;"}

Unless I'm missing something, these source maps don't work for their intended purpose.

For now I ended up relying on rollup-plugin-typescript2, which seems to preserve maps to the original Typescript source files, but I don't know if I can trust it.

Cheers,

alexjoverm commented 7 years ago

Thanks for reporting it @alexandru, seems like this was broken when migrated to Rollup and was not reported yet. Fixed it already.

I prefer to redirect to the original sourcemaps files (that's what was missing), but if you wanna use rollup-plugin-typescript2 that's fine. I didn't use if for the starter because it touches TypeScript internals, and I prefer to have fresh and full control over it.

alexandru commented 7 years ago

@alexjoverm thanks for the fix, I might use your setup too.