Skip to content

Commit

Permalink
fix for bundle-loader when using ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
itsMapleLeaf committed Dec 7, 2017
1 parent 4cc343b commit 7d1f384
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/builtins/bundle-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ function loadCSSBundle(bundle) {

function requireModule(id) {
let res = require(id);
if (res.__esModule) {
return res.default;
}

return res;
}

Expand Down
7 changes: 7 additions & 0 deletions test/integration/dynamic-esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var local = import('./local');

export default function () {
return local.then(function (l) {
return l.a + l.b;
});
};
2 changes: 2 additions & 0 deletions test/integration/dynamic-esm/local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const a = 1;
export const b = 2;
17 changes: 17 additions & 0 deletions test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ describe('javascript', function () {
assert.equal(await output(), 3);
});

it('should return all exports as an object when using ES modules', async function () {
let b = await bundle(__dirname + '/integration/dynamic-esm/index.js');

assertBundleTree(b, {
name: 'index.js',
assets: ['index.js', 'bundle-loader.js', 'bundle-url.js'],
childBundles: [{
assets: ['local.js'],
childBundles: []
}]
});

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

it('should hoist common dependencies into a parent bundle', async function () {
let b = await bundle(__dirname + '/integration/dynamic-hoist/index.js');

Expand Down

0 comments on commit 7d1f384

Please sign in to comment.