Browse Source

handle multiple export * from external declarations (#1252)

master
Rich-Harris 8 years ago
parent
commit
457be9c961
  1. 6
      src/Module.js
  2. 8
      test/form/export-all-multiple/_config.js
  3. 11
      test/form/export-all-multiple/_expected/amd.js
  4. 13
      test/form/export-all-multiple/_expected/cjs.js
  5. 3
      test/form/export-all-multiple/_expected/es.js
  6. 10
      test/form/export-all-multiple/_expected/iife.js
  7. 13
      test/form/export-all-multiple/_expected/umd.js
  8. 3
      test/form/export-all-multiple/main.js

6
src/Module.js

@ -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 ) {

8
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
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
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
test/form/export-all-multiple/_expected/es.js

@ -0,0 +1,3 @@
export * from 'foo';
export * from 'bar';
export * from 'baz';

10
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
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
test/form/export-all-multiple/main.js

@ -0,0 +1,3 @@
export * from 'foo';
export * from 'bar';
export * from 'baz';
Loading…
Cancel
Save