[Pkg-javascript-commits] [node-rollup-plugin-commonjs] 01/05: New upstream version 8.2.1

Julien Puydt julien.puydt at laposte.net
Tue Sep 19 12:57:58 UTC 2017


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-rollup-plugin-commonjs.

commit 0fa9a61a39ec73b62b99d1ec3eab308e4c3944f7
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Tue Sep 19 14:45:40 2017 +0200

    New upstream version 8.2.1
---
 CHANGELOG.md     |  4 ++++
 package.json     |  2 +-
 src/transform.js | 10 +++++-----
 test/test.js     | 17 ++++++++---------
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 49fbf47..973555c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # rollup-plugin-commonjs changelog
 
+## 8.2.1
+
+* Fix magic-string deprecation warning
+
 ## 8.2.0
 
 * Avoid using `index` as a variable name ([#208](https://github.com/rollup/rollup-plugin-commonjs/pull/208))
diff --git a/package.json b/package.json
index 408f5f2..29db2f4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "rollup-plugin-commonjs",
-  "version": "8.2.0",
+  "version": "8.2.1",
   "description": "Convert CommonJS modules to ES2015",
   "main": "dist/rollup-plugin-commonjs.cjs.js",
   "module": "dist/rollup-plugin-commonjs.es.js",
diff --git a/src/transform.js b/src/transform.js
index 76cccd3..ed9d17c 100644
--- a/src/transform.js
+++ b/src/transform.js
@@ -141,7 +141,7 @@ export default function transformCommonjs ( code, id, isEntry, ignoreGlobal, ign
 			// rewrite `this` as `commonjsHelpers.commonjsGlobal`
 			if ( node.type === 'ThisExpression' && lexicalDepth === 0 ) {
 				uses.global = true;
-				if ( !ignoreGlobal ) magicString.overwrite( node.start, node.end, `${HELPERS_NAME}.commonjsGlobal`, true );
+				if ( !ignoreGlobal ) magicString.overwrite( node.start, node.end, `${HELPERS_NAME}.commonjsGlobal`, { storeName: true } );
 				return;
 			}
 
@@ -153,7 +153,7 @@ export default function transformCommonjs ( code, id, isEntry, ignoreGlobal, ign
 				if ( scope.contains( flattened.name ) ) return;
 
 				if ( flattened.keypath === 'module.exports' || flattened.keypath === 'module' || flattened.keypath === 'exports' ) {
-					magicString.overwrite( node.start, node.end, `'object'`, false );
+					magicString.overwrite( node.start, node.end, `'object'`, { storeName: false } );
 				}
 			}
 
@@ -164,12 +164,12 @@ export default function transformCommonjs ( code, id, isEntry, ignoreGlobal, ign
 					if ( node.name in uses ) {
 						if ( node.name === 'require' ) {
 							if ( allowDynamicRequire ) return;
-							magicString.overwrite( node.start, node.end, `${HELPERS_NAME}.commonjsRequire`, true );
+							magicString.overwrite( node.start, node.end, `${HELPERS_NAME}.commonjsRequire`, { storeName: true } );
 						}
 
 						uses[ node.name ] = true;
 						if ( node.name === 'global' && !ignoreGlobal ) {
-							magicString.overwrite( node.start, node.end, `${HELPERS_NAME}.commonjsGlobal`, true );
+							magicString.overwrite( node.start, node.end, `${HELPERS_NAME}.commonjsGlobal`, { storeName: true } );
 						}
 
 						// if module or exports are used outside the context of an assignment
@@ -180,7 +180,7 @@ export default function transformCommonjs ( code, id, isEntry, ignoreGlobal, ign
 					}
 
 					if ( node.name === 'define' ) {
-						magicString.overwrite( node.start, node.end, 'undefined', true );
+						magicString.overwrite( node.start, node.end, 'undefined', { storeName: true } );
 					}
 
 					globals.add( node.name );
diff --git a/test/test.js b/test/test.js
index e0291f9..074c357 100644
--- a/test/test.js
+++ b/test/test.js
@@ -408,18 +408,17 @@ describe( 'rollup-plugin-commonjs', () => {
 			assert.equal( exports, 'HELLO' );
 		});
 
-		it( 'prefers to set name using directory for index files', () => {
-			return rollup({
+		it( 'prefers to set name using directory for index files', async () => {
+			const bundle = await rollup({
 				entry: 'samples/rename-index/main.js',
 				plugins: [ commonjs() ]
-			})
-			.then( async bundle => {
-				const { code } = await bundle.generate({ format: 'cjs' });
-				assert.equal( code.indexOf( 'var index' ), -1 );
-				assert.notEqual( code.indexOf( 'var invalidVar' ), -1 );
-				assert.notEqual( code.indexOf( 'var validVar' ), -1 );
-				assert.notEqual( code.indexOf( 'var nonIndex' ), -1 );
 			});
+
+			const { code } = await bundle.generate({ format: 'cjs' });
+			assert.equal( code.indexOf( 'var index' ), -1 );
+			assert.notEqual( code.indexOf( 'var invalidVar' ), -1 );
+			assert.notEqual( code.indexOf( 'var validVar' ), -1 );
+			assert.notEqual( code.indexOf( 'var nonIndex' ), -1 );
 		});
 	});
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-rollup-plugin-commonjs.git



More information about the Pkg-javascript-commits mailing list