From a42dfeba6f79175028a7227c920b18d21271066a Mon Sep 17 00:00:00 2001 From: Fathy Boundjadj Date: Sun, 8 Jul 2018 09:19:50 +0200 Subject: [PATCH] Fix tree-shaking named import on wrapped module (#1683) --- src/scope-hoisting/hoist.js | 1 + test/integration/scope-hoisting/es6/import-wrapped/a.js | 3 +++ test/integration/scope-hoisting/es6/import-wrapped/b.js | 1 + test/scope-hoisting.js | 9 +++++++++ 4 files changed, 14 insertions(+) create mode 100644 test/integration/scope-hoisting/es6/import-wrapped/a.js create mode 100644 test/integration/scope-hoisting/es6/import-wrapped/b.js diff --git a/src/scope-hoisting/hoist.js b/src/scope-hoisting/hoist.js index 96b1c6e1852..3a0412eb6bf 100644 --- a/src/scope-hoisting/hoist.js +++ b/src/scope-hoisting/hoist.js @@ -110,6 +110,7 @@ module.exports = { ]) ); + asset.cacheData.exports = {}; asset.cacheData.isCommonJS = true; asset.cacheData.isES6Module = false; } else { diff --git a/test/integration/scope-hoisting/es6/import-wrapped/a.js b/test/integration/scope-hoisting/es6/import-wrapped/a.js new file mode 100644 index 00000000000..68f0aa37cde --- /dev/null +++ b/test/integration/scope-hoisting/es6/import-wrapped/a.js @@ -0,0 +1,3 @@ +import {foo} from './b' + +output = foo diff --git a/test/integration/scope-hoisting/es6/import-wrapped/b.js b/test/integration/scope-hoisting/es6/import-wrapped/b.js new file mode 100644 index 00000000000..ce3be7c3cfb --- /dev/null +++ b/test/integration/scope-hoisting/es6/import-wrapped/b.js @@ -0,0 +1 @@ +export const foo = eval("'bar'") diff --git a/test/scope-hoisting.js b/test/scope-hoisting.js index 89beb526adc..7be90a74e64 100644 --- a/test/scope-hoisting.js +++ b/test/scope-hoisting.js @@ -311,6 +311,15 @@ describe('scope hoisting', function() { let output = await run(b); assert.deepEqual(output, 'foo'); }); + + it('should support named imports on wrapped modules', async function() { + let b = await bundle( + __dirname + '/integration/scope-hoisting/es6/import-wrapped/a.js' + ); + + let output = await run(b); + assert.deepEqual(output, 'bar'); + }); }); describe('commonjs', function() {