Currently, the Lines object created by recast.parse(source, options) knows the name of the source file that was parsed only if options.sourceFileName is explicitly provided.
When the parsed code contains a //#sourceURL= or //#sourceMappingURL= comment, we can use that information to inform the Lines object where it came from, even if no options.sourceFileName is provided.
When the recast.parsed AST is reprinted by recast.print, we should be able to aggregate all that source mapping information into recast.print(ast).map, even if there are fragments from multiple source files mixed together in the final AST.
If we get this right, you'll be able to mix and match ASTs to your heart's content without ever thinking about source maps.
Currently, the
Lines
object created byrecast.parse(source, options)
knows the name of the source file that was parsed only ifoptions.sourceFileName
is explicitly provided.When the parsed code contains a
//#sourceURL=
or//#sourceMappingURL=
comment, we can use that information to inform theLines
object where it came from, even if nooptions.sourceFileName
is provided.When the
recast.parse
d AST is reprinted byrecast.print
, we should be able to aggregate all that source mapping information intorecast.print(ast).map
, even if there are fragments from multiple source files mixed together in the final AST.If we get this right, you'll be able to mix and match ASTs to your heart's content without ever thinking about source maps.