From 9687b2db3d64e88ae629017d4d44846bb59a3991 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 5 Dec 2015 13:04:32 -0500 Subject: [PATCH] reinstate named exports from object literals test --- .../samples/named-exports-from-object-literal/a.js | 1 + .../named-exports-from-object-literal/main.js | 5 +++++ .../named-exports-from-object-literal/other.js | 9 +++++++++ test/test.js | 14 ++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 test/samples/named-exports-from-object-literal/a.js create mode 100644 test/samples/named-exports-from-object-literal/main.js create mode 100644 test/samples/named-exports-from-object-literal/other.js diff --git a/test/samples/named-exports-from-object-literal/a.js b/test/samples/named-exports-from-object-literal/a.js new file mode 100644 index 0000000..bd816ea --- /dev/null +++ b/test/samples/named-exports-from-object-literal/a.js @@ -0,0 +1 @@ +module.exports = 1; diff --git a/test/samples/named-exports-from-object-literal/main.js b/test/samples/named-exports-from-object-literal/main.js new file mode 100644 index 0000000..063779d --- /dev/null +++ b/test/samples/named-exports-from-object-literal/main.js @@ -0,0 +1,5 @@ +import { a, b, c } from './other.js'; + +assert.equal( a, 1 ); +assert.equal( b, 2 ); +assert.equal( c, 3 ); diff --git a/test/samples/named-exports-from-object-literal/other.js b/test/samples/named-exports-from-object-literal/other.js new file mode 100644 index 0000000..09a5b66 --- /dev/null +++ b/test/samples/named-exports-from-object-literal/other.js @@ -0,0 +1,9 @@ +var a = require( './a.js' ); +var b = 2; + +module.exports = { + a: a, + b: b, + c: a + b, + 2: 1 + 1 +}; diff --git a/test/test.js b/test/test.js index f09e218..231dd7c 100644 --- a/test/test.js +++ b/test/test.js @@ -172,6 +172,20 @@ describe( 'rollup-plugin-commonjs', function () { }); }); + it( 'identifies named exports from object literals', function () { + return rollup.rollup({ + entry: 'samples/named-exports-from-object-literal/main.js', + plugins: [ commonjs() ] + }).then( function ( bundle ) { + var generated = bundle.generate({ + format: 'cjs' + }); + + var fn = new Function ( 'module', 'assert', generated.code ); + fn( {}, assert ); + }); + }); + it( 'handles references to `global`', function () { return rollup.rollup({ entry: 'samples/global/main.js',