Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for typescript 1.5 --inlineSourceMap and --inlineSources #75

Closed
wants to merge 3 commits into from
Closed

Conversation

erichillah
Copy link

This PR add support for ts params inlineSources and inlineSourceMap and also fixes issue #74 .

When using the -debug option in browserify we now have two differents sourceMap outputs :

  1. --inlineSources is undefined or false => sourceMap output will preserve the folder hierarchy
    image2
  2. --inlineSources is true => sourceMap output will not preserve the folder hierarchy
    image1

@smrq
Copy link
Member

smrq commented Sep 15, 2015

Thanks for the PR!

Can you explain to me the utility of --inlineSourceMap when using Browserify? Is the only difference the apparent1 folder structure change? Ultimately, Browserify always inlines sourcemaps, and expects plugins and transforms to always inline them as well. (The sourcemap-related code in getCompiledFile() was inlining it manually because, well, I'm not sure that flag existed at the time of writing.)

1 I say "apparent" because what's actually going on there is that the TypeScript compiler is (erroneously) using backslashes in its output on Windows. Paths in sourcemaps are expected to work like URLs, so Chrome's dev tools (and possibly others) don't parse backslashes as a folder delimiter. This causes the apparent flattening of the directory structure. It's a bug, not a feature-- especially because you'll only see that behavior on Windows.

@erichillah
Copy link
Author

Hi,
On the "apparent folder structure" happy to know it's a bug (im a windows user and that seemed really weird the first time i saw it...).
The first goal of the PR is to add support for --inlineSourceMap for tsc not to crash with tsify, because tsify always set --sourceMap to true which was incompatible when --inlineSourceMap is setted in tsconfig.json.
Typescript 1.5 added support for --inlineSourceMap --inlineSources to allow emitting a single file with source maps. This will allow the emitted js file to be directly used by tool like browserify, jspm... See microsoft/TypeScript#2484.

The utility of --inlineSourceMap with Browserify :
Used togeteher --inlineSourceMap --inlineSources tsify should no longer need to re-inline the source maps in the output file (in getCompiledFile()). But since ts is using backslashes windows users will still have the flatenned paths.

Another alternative would be to ignore ts -inlineSource and --inlineSourceMap to prevent Tsc to crash.

@smrq
Copy link
Member

smrq commented Sep 15, 2015

Awesome, sounds like we're pretty much on the same page then. I'll get this merged in. I think I'll just cut out some of the branches, since I don't see any real reason for the option to ever be disabled.

@smrq
Copy link
Member

smrq commented Sep 15, 2015

Merged as part of 0.11.14

@smrq smrq closed this Sep 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants