Skip to content

Commit

Permalink
Fix default only exports
Browse files Browse the repository at this point in the history
  • Loading branch information
RichieAHB committed Dec 6, 2017
1 parent 781b7ec commit 860a748
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 383 deletions.
4 changes: 4 additions & 0 deletions src/visitors/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ module.exports = {
addDependency(asset, node.source);
},

ExportDefaultDeclaration(node, asset) {
asset.isES6Module = true;
},

CallExpression(node, asset) {
let {callee, arguments: args} = node;

Expand Down
4 changes: 4 additions & 0 deletions test/integration/es6-default-only/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const a = 1;
const b = 2;

export default () => a + b;
Empty file.
12 changes: 12 additions & 0 deletions test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ describe('javascript', function () {
assert.equal(output.default(), 3);
});

it('should produce a JS bundle with default exorts and no imports', async function () {
let b = await bundle(__dirname + '/integration/es6-default-only/index.js');

assert.equal(b.assets.size, 1);
assert.equal(b.childBundles.size, 0);

let output = run(b);
assert.equal(typeof output, 'object');
assert.equal(typeof output.default, 'function');
assert.equal(output.default(), 3);
});

it('should split bundles when a dynamic import is used', async function () {
let b = await bundle(__dirname + '/integration/dynamic/index.js');

Expand Down
Loading

0 comments on commit 860a748

Please sign in to comment.