diff --git a/src/Module.js b/src/Module.js index 746a96d..41e444c 100644 --- a/src/Module.js +++ b/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 ) { diff --git a/test/form/export-all-multiple/_config.js b/test/form/export-all-multiple/_config.js new file mode 100644 index 0000000..4199beb --- /dev/null +++ b/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' + } +}; diff --git a/test/form/export-all-multiple/_expected/amd.js b/test/form/export-all-multiple/_expected/amd.js new file mode 100644 index 0000000..37ed509 --- /dev/null +++ b/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 }); + +}); diff --git a/test/form/export-all-multiple/_expected/cjs.js b/test/form/export-all-multiple/_expected/cjs.js new file mode 100644 index 0000000..e3af62c --- /dev/null +++ b/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]; }); diff --git a/test/form/export-all-multiple/_expected/es.js b/test/form/export-all-multiple/_expected/es.js new file mode 100644 index 0000000..03c82c7 --- /dev/null +++ b/test/form/export-all-multiple/_expected/es.js @@ -0,0 +1,3 @@ +export * from 'foo'; +export * from 'bar'; +export * from 'baz'; diff --git a/test/form/export-all-multiple/_expected/iife.js b/test/form/export-all-multiple/_expected/iife.js new file mode 100644 index 0000000..85551a5 --- /dev/null +++ b/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)); diff --git a/test/form/export-all-multiple/_expected/umd.js b/test/form/export-all-multiple/_expected/umd.js new file mode 100644 index 0000000..0acef0d --- /dev/null +++ b/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 }); + +}))); diff --git a/test/form/export-all-multiple/main.js b/test/form/export-all-multiple/main.js new file mode 100644 index 0000000..03c82c7 --- /dev/null +++ b/test/form/export-all-multiple/main.js @@ -0,0 +1,3 @@ +export * from 'foo'; +export * from 'bar'; +export * from 'baz';