From 23ee7c2a5ff806aac605a2bca95ac48310ef9a11 Mon Sep 17 00:00:00 2001 From: Fathy Boundjadj Date: Sun, 8 Jul 2018 08:33:49 +0200 Subject: [PATCH] Fix import deep wildcards with tree-shaking (#1681) --- src/scope-hoisting/concat.js | 2 +- .../scope-hoisting/es6/import-multiple-wildcards/a.js | 4 ++++ test/scope-hoisting.js | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/integration/scope-hoisting/es6/import-multiple-wildcards/a.js diff --git a/src/scope-hoisting/concat.js b/src/scope-hoisting/concat.js index d0f3b6c0360..673fa3b0991 100644 --- a/src/scope-hoisting/concat.js +++ b/src/scope-hoisting/concat.js @@ -56,7 +56,7 @@ module.exports = (packager, ast) => { // If this module exports wildcards, resolve the original module. // Default exports are excluded from wildcard exports. let wildcards = module && module.cacheData.wildcards; - if (wildcards && name !== 'default') { + if (wildcards && name !== 'default' && name !== '*') { for (let source of wildcards) { let m = findExportModule(resolveModule(id, source).id, name); if (m.identifier) { diff --git a/test/integration/scope-hoisting/es6/import-multiple-wildcards/a.js b/test/integration/scope-hoisting/es6/import-multiple-wildcards/a.js new file mode 100644 index 00000000000..de80d3ddb91 --- /dev/null +++ b/test/integration/scope-hoisting/es6/import-multiple-wildcards/a.js @@ -0,0 +1,4 @@ +import * as all from '../re-export-all-multiple/b' + +// Don't do the the sum here to prevent treeshaking optimizations +output = all diff --git a/test/scope-hoisting.js b/test/scope-hoisting.js index 2b691ee610b..89beb526adc 100644 --- a/test/scope-hoisting.js +++ b/test/scope-hoisting.js @@ -112,6 +112,16 @@ describe('scope hoisting', function() { assert.equal(output, 15); }); + it('supports importing all exports re-exported from multiple modules deep', async function() { + let b = await bundle( + __dirname + + '/integration/scope-hoisting/es6/import-multiple-wildcards/a.js' + ); + + let {foo, bar, baz, a, b: bb} = await run(b); + assert.equal(foo + bar + baz + a + bb, 15); + }); + it('supports re-exporting all exports from multiple modules deep', async function() { let b = await bundle( __dirname + '/integration/scope-hoisting/es6/re-export-multiple/a.js'