Closed yacinehmito closed 1 year ago
I think deno_emit should follow the behavior of tsc. By default this will also match deno bundle as deno bundle never emits source maps and tsc doesn't when no options are provided.
@dsherret What do you think? I have already written the tests to ensure this. Waiting for a go to implement.
I implemented it, as it was pretty straightforward.
I say that the defaults are actually set in deno_ast
, meaning that there were three possible places to perform the required validation:
deno_ast
deno_emit
deno_emit
I did it in the TS wrapper because it was very easy, but let me know if another place is better.
I'll submit a PR once #97 is merged.
I did it in the TS wrapper because it was very easy, but let me know if another place is better.
I just looked at the code and that seems good to do. The emit defaults in deno_ast are set for transpiling, so we should probably leave those as-is.
In TypeScript, there are three compiler options that relate to source maps:
sourceMap
, which controls whether external source maps should be emittedinlineSourceMap
, which controls whether inline source maps should be emittedinlineSources
, which controls whether the original source code should be embedded in the source mapsThere are interplay and incompatibilities between these options. Those are not properly taken into account in
deno_emit
.I first encountered this when working on #98, which is meant to solve a few source map issues. I found that
deno_emit
setsinlineSourceMap
totrue
by default and pretty much ignores everything else until it is manually set tofalse
.I suggested that
deno_emit
stop emitting inline source maps by default; @dsherret told me that, if it changes, then it is preferable for the default behavior to be consistent withdeno bundle
, until it is properly sunset.I ran a program that automatically runs
deno bundle
,tsc
anddeno_emit
on the same module for all combinations of the aforementioned options and looked at the output. The results are reported in the table below.My proposal: I think
deno_emit
should follow the behavior oftsc
. By default this will also matchdeno bundle
asdeno bundle
never emits source maps andtsc
doesn't when no options are provided.Legend:
sourceMap
inlineSourceMap
inlineSources
deno bundle
tsc
deno_emit
¹true
false
true
false
true
true
true
false
false
true
false
false
true
false
true
true
true
false
false
true
false
false
true
true
true
false
false
true
false
false
true
true
true
true
true
false
true
false
true
true
false
false
false
true
true
false
true
false
false
false
true
false
false
false
¹ The output of
bundle()
indeno_emit
; this is assuming that the compiler options are properly forwarded, per #98, as the current version always emit inline source maps.² error TS5053: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.
³ error TS5051: Option 'inlineSources can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.