From 6dfe06cbc92d447296456302fb3ef083e100f779 Mon Sep 17 00:00:00 2001 From: dy Date: Fri, 11 Jan 2019 13:15:15 -0500 Subject: [PATCH 1/4] Add multiple exports test case --- test/funny-exports/funny.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/funny-exports/funny.js b/test/funny-exports/funny.js index e03a2a7..a3f20b5 100644 --- a/test/funny-exports/funny.js +++ b/test/funny-exports/funny.js @@ -5,4 +5,4 @@ console.log(exports.a = 'hello world') function a() {} exports.b = function () { return a }, console.log(a) var c = (0, exports.c = 'beep boop') -exports.d = exports.e = null +exports.d = exports.e = exports.f = exports.g = null From 41bfe6d6de92cadc0fc80f51a835bc593d51e62b Mon Sep 17 00:00:00 2001 From: dy Date: Fri, 11 Jan 2019 15:27:02 -0500 Subject: [PATCH 2/4] Revert funny test --- test/funny-exports/funny.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/funny-exports/funny.js b/test/funny-exports/funny.js index a3f20b5..e03a2a7 100644 --- a/test/funny-exports/funny.js +++ b/test/funny-exports/funny.js @@ -5,4 +5,4 @@ console.log(exports.a = 'hello world') function a() {} exports.b = function () { return a }, console.log(a) var c = (0, exports.c = 'beep boop') -exports.d = exports.e = exports.f = exports.g = null +exports.d = exports.e = null From dab7f84878c1bb0c0c99dff95bb334ddd4cf030e Mon Sep 17 00:00:00 2001 From: dy Date: Fri, 11 Jan 2019 15:32:34 -0500 Subject: [PATCH 3/4] Fix funny expectation --- test/funny-exports/expected.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/funny-exports/expected.js b/test/funny-exports/expected.js index a309ec3..1c3f9e4 100644 --- a/test/funny-exports/expected.js +++ b/test/funny-exports/expected.js @@ -11,6 +11,6 @@ console.log(/* common-shake removed: exports.a = */ 'hello world') function a() {} /* common-shake removed: exports.b = */ void 0, function () { return a }, console.log(a) var c = (0, /* common-shake removed: exports.c = */ 'beep boop') -/* common-shake removed: exports.d = */ void 0, exports.e = null +/* common-shake removed: exports.d = */ exports.e = null },{}]},{},[1]); From 5034364b50d772f04463aaacb70806691446820b Mon Sep 17 00:00:00 2001 From: dy Date: Fri, 11 Jan 2019 15:33:06 -0500 Subject: [PATCH 4/4] Extend multiple assign case --- index.js | 9 ++++++++- test/multiple-assign/a.js | 2 +- test/multiple-assign/expected.js | 2 +- test/test.js | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index fa4c305..d54642d 100644 --- a/index.js +++ b/index.js @@ -186,7 +186,14 @@ function createStream (opts) { node.right.type === 'AssignmentExpression' || // Don't output a statement containing only `void () => {}` node.right.type === 'ArrowFunctionExpression') { - prefix += 'void 0, ' + // ignore alias assignment expression `exports.a = exports.b = exports.c` + if (!( + node.right.type === 'AssignmentExpression' && + node.right.left.type === 'MemberExpression' && + node.right.left.object.name === 'exports' + )) { + prefix += 'void 0, ' + } } // Make sure we can't accidentally continue a previous statement. // eg in `exports.a = [0]` the `[0]` could continue a previous statement if that diff --git a/test/multiple-assign/a.js b/test/multiple-assign/a.js index a92933e..c7967bd 100644 --- a/test/multiple-assign/a.js +++ b/test/multiple-assign/a.js @@ -1,5 +1,5 @@ // This is roughly what Babel's ESM→CommonJS module transform does. -exports.a = exports.b = null +exports.a = exports.b = exports.c = exports.d = null exports.a = 'a' exports.b = 'b' diff --git a/test/multiple-assign/expected.js b/test/multiple-assign/expected.js index 20875ca..bb260b4 100644 --- a/test/multiple-assign/expected.js +++ b/test/multiple-assign/expected.js @@ -1,6 +1,6 @@ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i