Skip to content

[Fable 5] Source maps generation is broken #3980

@MangelMaxime

Description

@MangelMaxime

Description

It seems like we are missing information about the original file file and the source., which cause Fable 5 to break if --sourceMaps is provided.

To me it looks like the last blocking bug we need to fix to release Fable 5. Other things like full support for F# 9 feature can be done over time.

./../quicktest/QuickTest.fs(1,1): error EXCEPTION: Invalid mapping: { generated = { line = 54
                column = 85 }
  name = None
  original = Some { line = 0
                    column = 0 }
  source = Some "unknown" }
   at SourceMapSharp.SourceMapGenerator.ValidateMapping(MappingIndex generated, FSharpOption`1 original, FSharpOption`1 source, FSharpOption`1 name)
   at SourceMapSharp.SourceMapGenerator.AddMapping(MappingIndex generated, FSharpOption`1 original, FSharpOption`1 source, FSharpOption`1 name)
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1231
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArrowFunctionExpression(Printer printer, Parameter[] parameters, BlockStatement body, FSharpOption`1 returnType, TypeParameter[] typeParameters, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1041
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintCommaSeparatedArray@229-10.Invoke(Printer p, Expression x) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArray[a](Printer printer, a[] items, FSharpFunc`2 print, FSharpFunc`2 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 135
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCommaSeparatedArray(Printer printer, Expression[] items) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1235
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintCommaSeparatedArray@229-10.Invoke(Printer p, Expression x) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArray[a](Printer printer, a[] items, FSharpFunc`2 print, FSharpFunc`2 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 135
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCommaSeparatedArray(Printer printer, Expression[] items) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1235
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArrowFunctionExpression(Printer printer, Parameter[] parameters, BlockStatement body, FSharpOption`1 returnType, TypeParameter[] typeParameters, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1041
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintCommaSeparatedArray@229-10.Invoke(Printer p, Expression x) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArray[a](Printer printer, a[] items, FSharpFunc`2 print, FSharpFunc`2 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 135
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCommaSeparatedArray(Printer printer, Expression[] items) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1235
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintCommaSeparatedArray@229-10.Invoke(Printer p, Expression x) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArray[a](Printer printer, a[] items, FSharpFunc`2 print, FSharpFunc`2 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 135
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCommaSeparatedArray(Printer printer, Expression[] items) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1235
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintProductiveStatement(Printer printer, Statement s, FSharpOption`1 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 78
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintBlock@88.Invoke(Printer p, Statement s) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 88
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintBlock[a](Printer printer, a[] nodes, FSharpFunc`2 printNode, FSharpFunc`2 printSeparator, FSharpOption`1 skipNewLineAtEnd) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 61
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArrowFunctionExpression(Printer printer, Parameter[] parameters, BlockStatement body, FSharpOption`1 returnType, TypeParameter[] typeParameters, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1041
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintCommaSeparatedArray@229-10.Invoke(Printer p, Expression x) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArray[a](Printer printer, a[] items, FSharpFunc`2 print, FSharpFunc`2 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 135
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCommaSeparatedArray(Printer printer, Expression[] items) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1235
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintProductiveStatement(Printer printer, Statement s, FSharpOption`1 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 78
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintBlock@88.Invoke(Printer p, Statement s) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 88
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintBlock[a](Printer printer, a[] nodes, FSharpFunc`2 printNode, FSharpFunc`2 printSeparator, FSharpOption`1 skipNewLineAtEnd) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 61
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintDeclaration(Printer printer, Declaration decl) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 664
   at Fable.Transforms.BabelPrinter.printDeclWithExtraLine@1558-1.Invoke(Printer printer, ModuleDeclaration decl) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1558
   at Fable.Transforms.BabelPrinter.run@1584-9.Invoke(ModuleDeclaration decl) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1585
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in /home/dev/Projects/fsharp/src/FSharp.Core/async.fs:line 510
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in /home/dev/Projects/fsharp/src/FSharp.Core/async.fs:line 112

Repro code

Add |> CmdLine.appendRaw "--sourceMaps" to src/Fable.Build/Quicktest/Core.fs and run ./build.sh quicktest javascript

Expected and actual results

Should compile

Related information

  • Fable version: 5.0.0-alpha.2
  • Operating system: OSX

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions