Skip to content

Commit

Permalink
Use source-map-sharp
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro committed Dec 29, 2020
1 parent 8441abe commit 145f656
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Fable.Cli/Fable.Cli.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Fable.Transforms\Fable.Transforms.fsproj" />
<ProjectReference Include="..\..\..\source-map-sharp\source-map-sharp.fsproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="../../lib/fcs/FSharp.Core.dll" />
Expand Down
12 changes: 9 additions & 3 deletions src/Fable.Cli/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,15 @@ module private Util =
|> FableTransforms.transformFile com
|> Fable2Babel.Compiler.transformFile com

// TODO: Dummy interface until we have a dotnet port of SourceMapGenerator
// https://github.com/mozilla/source-map#with-sourcemapgenerator-low-level-api
let mapGenerator = SourceMapSharp.SourceMapGenerator(None, None, None)
let map = { new BabelPrinter.SourceMapGenerator with
member _.AddMapping(_,_,_,_,_) = () }
member _.AddMapping(orLine, orCol, genLine, genCol, name) =
let generated: SourceMapSharp.Util.MappingIndex =
{line = genLine; column = genCol}
let original: SourceMapSharp.Util.MappingIndex =
{line = orLine; column = orCol}

mapGenerator.AddMapping(generated, Some original, Some com.CurrentFile, name) }

let outPath = getOutJsPath cliArgs dedupTargetDir com.CurrentFile

Expand All @@ -176,6 +181,7 @@ module private Util =
do! BabelPrinter.run writer map babel

Log.always("Compiled " + File.getRelativePathFromCwd com.CurrentFile)
printfn "%s" (mapGenerator.toString())

return Ok {| File = com.CurrentFile
Logs = com.Logs
Expand Down

0 comments on commit 145f656

Please sign in to comment.