ES6 export with wildcard, Babel 6.x bug

Dec 8, 2015  

ES6 comes with a handy export * from '...'; statement which can be used to export everything that is exported by a given module. I was trying to get this to work with Babel 6.x:

export * from './all.js';

I don’t know what’s inside all.js, so exporting with a wildcard makes perfect sense, as I cannot enumerate the symbols I’d like to get exported from the import.

However, with the version of Babel 6.x I am using, I consistently get this error message:

Invariant Violation: To get a node path the parent needs to exist

There is an issue on Babel’s bug tracker and also a PR for an upcoming release of Babel.

In the meantime, the cleanest workaround I have come up with is to first import everything, then export with the wildcard:

import * as all from './all.js';
export * from './all.js';