@@ -32,16 +32,17 @@ const NAME = 'rollup-plugin-prettier';
3232
3333module . exports = ( options ) => {
3434 let sourcemap = null ;
35+ let newOptions = options ;
3536
3637 if ( options && hasSourceMap ( options ) ) {
3738 sourcemap = isSourceMapEnabled ( options ) ;
3839
3940 // Delete custom option.
40- deleteSourceMap ( options ) ;
41+ newOptions = deleteSourceMap ( options ) ;
4142
4243 // Do not send an empty option object.
43- if ( Object . keys ( options ) . length === 0 ) {
44- options = undefined ;
44+ if ( Object . keys ( newOptions ) . length === 0 ) {
45+ newOptions = undefined ;
4546 }
4647 }
4748
@@ -83,7 +84,7 @@ module.exports = (options) => {
8384 * @return {Object } The result containing a `code` property and, if a enabled, a `map` property.
8485 */
8586 transformBundle ( source , outputOptions ) {
86- const output = prettier . format ( source , options ) ;
87+ const output = prettier . format ( source , newOptions ) ;
8788 const outputOptionsSourcemap = isNil ( outputOptions ) ? null : isSourceMapEnabled ( outputOptions ) ;
8889
8990 // Should we generate sourcemap?
@@ -165,9 +166,18 @@ function isSourceMapEnabled(opts) {
165166 * Delete sourcemap option on object.
166167 *
167168 * @param {Object } opts The object.
169+ * @return {Object } Option object without `sourcemap` entry.
168170 */
169171function deleteSourceMap ( opts ) {
170- SOURCE_MAPS_OPTS . forEach ( ( p ) => delete opts [ p ] ) ;
172+ const newOptions = { } ;
173+
174+ Object . keys ( opts ) . forEach ( ( k ) => {
175+ if ( SOURCE_MAPS_OPTS . indexOf ( k ) < 0 ) {
176+ newOptions [ k ] = opts [ k ] ;
177+ }
178+ } ) ;
179+
180+ return newOptions ;
171181}
172182
173183/**
0 commit comments