This PR fixes source map generation to resolve one of the debugging issues described in meteor/meteor#8611.
The source maps that are generated by compile are wrong if at least one Babel plugin is included in the options object (see https://github.com/meteor/meteor/issues/8611#issuecomment-313872380). I'm not really sure why the current implementation doesn't work but it looks like it's a problem with Babel's inputSourceMap option. Instead of using an intermediate source map, I think it's fine to transform the AST twice and let Babel generate the source map from the final AST only. Another benefit is that compile doesn't have to generate code twice (once for each pass) anymore.
I have tested this change with a few combinations of Babel plugins and presets and compile always created a correct source map.
This PR fixes source map generation to resolve one of the debugging issues described in meteor/meteor#8611.
The source maps that are generated by
compile
are wrong if at least one Babel plugin is included in theoptions
object (see https://github.com/meteor/meteor/issues/8611#issuecomment-313872380). I'm not really sure why the current implementation doesn't work but it looks like it's a problem with Babel'sinputSourceMap
option. Instead of using an intermediate source map, I think it's fine to transform the AST twice and let Babel generate the source map from the final AST only. Another benefit is thatcompile
doesn't have to generate code twice (once for each pass) anymore.I have tested this change with a few combinations of Babel plugins and presets and
compile
always created a correct source map.