From 1d7c853ce6fabec207401a53d8210ea25f08d72e Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 29 Aug 2016 16:20:40 -0400 Subject: [PATCH] prevent leaky state, always clone magic-string --- src/Module.js | 2 +- test/test.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Module.js b/src/Module.js index 11abeca..d015182 100644 --- a/src/Module.js +++ b/src/Module.js @@ -448,7 +448,7 @@ export default class Module { } render ( es ) { - const magicString = this.magicString; + const magicString = this.magicString.clone(); this.statements.forEach( statement => { if ( !statement.isIncluded ) { diff --git a/test/test.js b/test/test.js index 4eb73a6..92a88f0 100644 --- a/test/test.js +++ b/test/test.js @@ -290,10 +290,12 @@ describe( 'rollup', function () { } }, config.options ); - ( config.skip ? describe.skip : config.solo ? describe.only : describe)( dir, () => { + ( config.skip ? describe.skip : config.solo ? describe.only : describe )( dir, () => { + const promise = rollup.rollup( options ); + PROFILES.forEach( profile => { it( 'generates ' + profile.format, () => { - return rollup.rollup( options ).then( bundle => { + return promise.then( bundle => { const options = extend( {}, config.options, { dest: FORM + '/' + dir + '/_actual/' + profile.format + '.js', format: profile.format