Skip to content

Commit bd824c7

Browse files
Fix #4780: Don't mutate the options object when compiling and transpiling, so that options are correct on subsequent iterations (#4785)
1 parent cbc695b commit bd824c7

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/coffeescript/coffeescript.js

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/coffeescript.coffee

+5-3
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,14 @@ exports.compile = compile = withPrettyErrors (code, options = {}) ->
140140
transpiler = options.transpile.transpile
141141
delete options.transpile.transpile
142142

143+
transpilerOptions = Object.assign {}, options.transpile
144+
143145
# See https://github.com/babel/babel/issues/827#issuecomment-77573107:
144146
# Babel can take a v3 source map object as input in `inputSourceMap`
145147
# and it will return an *updated* v3 source map object in its output.
146-
if v3SourceMap and not options.transpile.inputSourceMap?
147-
options.transpile.inputSourceMap = v3SourceMap
148-
transpilerOutput = transpiler js, options.transpile
148+
if v3SourceMap and not transpilerOptions.inputSourceMap?
149+
transpilerOptions.inputSourceMap = v3SourceMap
150+
transpilerOutput = transpiler js, transpilerOptions
149151
js = transpilerOutput.code
150152
if v3SourceMap and transpilerOutput.map
151153
v3SourceMap = transpilerOutput.map

0 commit comments

Comments
 (0)