From dc564da15a65b09d7bd6c7c1c66e186f21cd6746 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 4 Nov 2015 17:52:01 -0500 Subject: [PATCH] alternative fix for #270 --- src/Module.js | 2 +- src/Statement.js | 3 +++ test/function/export-from-no-local-binding-var/_config.js | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Module.js b/src/Module.js index 1ee1320..3bbf32e 100644 --- a/src/Module.js +++ b/src/Module.js @@ -344,7 +344,7 @@ export default class Module { if ( declaration ) { declaration.addReference( reference ); - } else if ( statement.node.type !== 'ExportNamedDeclaration' || !this.reexports[ reference.name ] ) { + } else { // TODO handle globals this.bundle.assumedGlobals[ reference.name ] = true; } diff --git a/src/Statement.js b/src/Statement.js index d5ec856..f6d086a 100644 --- a/src/Statement.js +++ b/src/Statement.js @@ -100,6 +100,9 @@ export default class Statement { module.bundle.onwarn( `Use of \`eval\` (in ${module.id}) is discouraged, as it may cause issues with minification. See https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval for more details` ); } + // skip re-export declarations + if ( node.type === 'ExportNamedDeclaration' && node.source ) return this.skip(); + if ( node.type === 'TemplateElement' ) stringLiteralRanges.push([ node.start, node.end ]); if ( node.type === 'Literal' && typeof node.value === 'string' && /\n/.test( node.raw ) ) { stringLiteralRanges.push([ node.start + 1, node.end - 1 ]); diff --git a/test/function/export-from-no-local-binding-var/_config.js b/test/function/export-from-no-local-binding-var/_config.js index 3b1a85e..e0b2e42 100644 --- a/test/function/export-from-no-local-binding-var/_config.js +++ b/test/function/export-from-no-local-binding-var/_config.js @@ -1,5 +1,8 @@ var assert = require( 'assert' ); module.exports = { - description: 'export from does not create a local binding' + description: 'export from does not create a local binding', + runtimeError: function ( err ) { + assert.ok( /foo is not defined/.test( err.message ) ); + } };