escodegen icon indicating copy to clipboard operation
escodegen copied to clipboard

Source map & sourcesContent

Open sprat opened this issue 9 years ago • 2 comments

I am trying to transform a javascript file which is (roughly) the result of the concatenation of many source files, with an associated source map that have all the sources inlined in the sourcesContent list. The transform is performed by parsing the (combined) source file with esprima, transforming the AST with estraverse, then generating the target file from the modified AST with escodegen. This transformation is actually implemented in AMDclean.

I would like to generate a target source map having all the input files inlined in the sourcesContent, like the input source map. However, it seems that escodegen does not actually offer the possibility to set more than one sourceContent and does not allow the user to customize the source map before generation, so I am stuck.

It would be cool if we could do that in escodegen. For example, we could:

  • add an option to inline the input sources given a path to the sources root
  • add an option to pass an input source map from which escodegen would copy the file, sourceRoot and sourcesContent?
  • add a sourcesContent option accepting a mapping object
  • add a way to modify the map before generating the source map as a string

What do you think about my problem and the proposed solutions? Are there other options? Is there someone willing to implement a fix? Should I implement it? Are there other tools that can inline source files in a source map?

sprat avatar Nov 18 '15 21:11 sprat

Anyone?

sprat avatar Dec 07 '15 20:12 sprat

Also interested in this. I can use sourceMap: true, but I need multiple files for the source content. Passing sourceContent a map would be great.

chrisranderson avatar Feb 22 '16 23:02 chrisranderson