Skip to content

Commit

Permalink
handle multiple export * from external declarations (#1252)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jan 14, 2017
1 parent 4bbf9fd commit 457be9c
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Module.js
Expand Up @@ -410,6 +410,12 @@ export default class Module {
}

traceExport ( name ) {
// export * from 'external'
if ( name[0] === '*' ) {
const module = this.bundle.moduleById.get( name.slice( 1 ) );
return module.traceExport( '*' );
}

// export { foo } from './other.js'
const reexportDeclaration = this.reexports[ name ];
if ( reexportDeclaration ) {
Expand Down
8 changes: 8 additions & 0 deletions test/form/export-all-multiple/_config.js
@@ -0,0 +1,8 @@
module.exports = {
description: 'correctly handles multiple export * declarations (#1252)',
options: {
external: [ 'foo', 'bar', 'baz' ],
globals: { foo: 'foo', bar: 'bar', baz: 'baz' },
moduleName: 'myBundle'
}
};
11 changes: 11 additions & 0 deletions test/form/export-all-multiple/_expected/amd.js
@@ -0,0 +1,11 @@
define(['exports', 'foo', 'bar', 'baz'], function (exports, foo, bar, baz) { 'use strict';



Object.keys(foo).forEach(function (key) { exports[key] = foo[key]; });
Object.keys(bar).forEach(function (key) { exports[key] = bar[key]; });
Object.keys(baz).forEach(function (key) { exports[key] = baz[key]; });

Object.defineProperty(exports, '__esModule', { value: true });

});
13 changes: 13 additions & 0 deletions test/form/export-all-multiple/_expected/cjs.js
@@ -0,0 +1,13 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var foo = require('foo');
var bar = require('bar');
var baz = require('baz');



Object.keys(foo).forEach(function (key) { exports[key] = foo[key]; });
Object.keys(bar).forEach(function (key) { exports[key] = bar[key]; });
Object.keys(baz).forEach(function (key) { exports[key] = baz[key]; });
3 changes: 3 additions & 0 deletions test/form/export-all-multiple/_expected/es.js
@@ -0,0 +1,3 @@
export * from 'foo';
export * from 'bar';
export * from 'baz';
10 changes: 10 additions & 0 deletions test/form/export-all-multiple/_expected/iife.js
@@ -0,0 +1,10 @@
(function (exports,foo,bar,baz) {
'use strict';



Object.keys(foo).forEach(function (key) { exports[key] = foo[key]; });
Object.keys(bar).forEach(function (key) { exports[key] = bar[key]; });
Object.keys(baz).forEach(function (key) { exports[key] = baz[key]; });

}((this.myBundle = this.myBundle || {}),foo,bar,baz));
13 changes: 13 additions & 0 deletions test/form/export-all-multiple/_expected/umd.js
@@ -0,0 +1,13 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('foo'), require('bar'), require('baz')) :
typeof define === 'function' && define.amd ? define(['exports', 'foo', 'bar', 'baz'], factory) :
(factory((global.myBundle = global.myBundle || {}),global.foo,global.bar,global.baz));
}(this, (function (exports,foo,bar,baz) { 'use strict';

Object.keys(foo).forEach(function (key) { exports[key] = foo[key]; });
Object.keys(bar).forEach(function (key) { exports[key] = bar[key]; });
Object.keys(baz).forEach(function (key) { exports[key] = baz[key]; });

Object.defineProperty(exports, '__esModule', { value: true });

})));
3 changes: 3 additions & 0 deletions test/form/export-all-multiple/main.js
@@ -0,0 +1,3 @@
export * from 'foo';
export * from 'bar';
export * from 'baz';

0 comments on commit 457be9c

Please sign in to comment.