Skip to content

Commit 860a748

Browse files
committed
Fix default only exports
1 parent 781b7ec commit 860a748

5 files changed

Lines changed: 38 additions & 383 deletions

File tree

ā€Žsrc/visitors/dependencies.jsā€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ module.exports = {
2323
addDependency(asset, node.source);
2424
},
2525

26+
ExportDefaultDeclaration(node, asset) {
27+
asset.isES6Module = true;
28+
},
29+
2630
CallExpression(node, asset) {
2731
let {callee, arguments: args} = node;
2832

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const a = 1;
2+
const b = 2;
3+
4+
export default () => a + b;

ā€Žtest/integration/es6-default-only/local.jsā€Ž

Whitespace-only changes.

ā€Žtest/javascript.jsā€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ describe('javascript', function () {
2626
assert.equal(output.default(), 3);
2727
});
2828

29+
it('should produce a JS bundle with default exorts and no imports', async function () {
30+
let b = await bundle(__dirname + '/integration/es6-default-only/index.js');
31+
32+
assert.equal(b.assets.size, 1);
33+
assert.equal(b.childBundles.size, 0);
34+
35+
let output = run(b);
36+
assert.equal(typeof output, 'object');
37+
assert.equal(typeof output.default, 'function');
38+
assert.equal(output.default(), 3);
39+
});
40+
2941
it('should split bundles when a dynamic import is used', async function () {
3042
let b = await bundle(__dirname + '/integration/dynamic/index.js');
3143

0 commit comments

Comments
Ā (0)
⚔