Fix #4780: Don't mutate the options object when compiling and transpiling, so that options are correct on subsequent iterations (#4785)
This commit is contained in:
parent
cbc695b831
commit
bd824c73dd
|
@ -85,7 +85,7 @@
|
|||
// object, where sourceMap is a sourcemap.coffee#SourceMap object, handy for
|
||||
// doing programmatic lookups.
|
||||
exports.compile = compile = withPrettyErrors(function(code, options = {}) {
|
||||
var currentColumn, currentLine, encoded, filename, fragment, fragments, generateSourceMap, header, i, j, js, len, len1, map, newLines, ref, ref1, sourceMapDataURI, sourceURL, token, tokens, transpiler, transpilerOutput, v3SourceMap;
|
||||
var currentColumn, currentLine, encoded, filename, fragment, fragments, generateSourceMap, header, i, j, js, len, len1, map, newLines, ref, ref1, sourceMapDataURI, sourceURL, token, tokens, transpiler, transpilerOptions, transpilerOutput, v3SourceMap;
|
||||
// Clone `options`, to avoid mutating the `options` object passed in.
|
||||
options = Object.assign({}, options);
|
||||
// Always generate a source map if no filename is passed in, since without a
|
||||
|
@ -177,13 +177,14 @@
|
|||
// is run via the CLI or Node API.
|
||||
transpiler = options.transpile.transpile;
|
||||
delete options.transpile.transpile;
|
||||
transpilerOptions = Object.assign({}, options.transpile);
|
||||
// See https://github.com/babel/babel/issues/827#issuecomment-77573107:
|
||||
// Babel can take a v3 source map object as input in `inputSourceMap`
|
||||
// and it will return an *updated* v3 source map object in its output.
|
||||
if (v3SourceMap && (options.transpile.inputSourceMap == null)) {
|
||||
options.transpile.inputSourceMap = v3SourceMap;
|
||||
if (v3SourceMap && (transpilerOptions.inputSourceMap == null)) {
|
||||
transpilerOptions.inputSourceMap = v3SourceMap;
|
||||
}
|
||||
transpilerOutput = transpiler(js, options.transpile);
|
||||
transpilerOutput = transpiler(js, transpilerOptions);
|
||||
js = transpilerOutput.code;
|
||||
if (v3SourceMap && transpilerOutput.map) {
|
||||
v3SourceMap = transpilerOutput.map;
|
||||
|
|
|
@ -140,12 +140,14 @@ exports.compile = compile = withPrettyErrors (code, options = {}) ->
|
|||
transpiler = options.transpile.transpile
|
||||
delete options.transpile.transpile
|
||||
|
||||
transpilerOptions = Object.assign {}, options.transpile
|
||||
|
||||
# See https://github.com/babel/babel/issues/827#issuecomment-77573107:
|
||||
# Babel can take a v3 source map object as input in `inputSourceMap`
|
||||
# and it will return an *updated* v3 source map object in its output.
|
||||
if v3SourceMap and not options.transpile.inputSourceMap?
|
||||
options.transpile.inputSourceMap = v3SourceMap
|
||||
transpilerOutput = transpiler js, options.transpile
|
||||
if v3SourceMap and not transpilerOptions.inputSourceMap?
|
||||
transpilerOptions.inputSourceMap = v3SourceMap
|
||||
transpilerOutput = transpiler js, transpilerOptions
|
||||
js = transpilerOutput.code
|
||||
if v3SourceMap and transpilerOutput.map
|
||||
v3SourceMap = transpilerOutput.map
|
||||
|
|
Loading…
Reference in New Issue