I ran across a fun Webpack bug…at least I think it’s a bug.

I have an isomorphic app - much of it is written in ES6 syntax (ReactJS). A small slice of the app runs only on the server-side to power a local API. There is a small amount of shared code between these two sections of the app - these are written as CommonJS modules to work directly in NodeJS without transpiling. Webpack imports this just fine along side ES6 style modules and imports.

However…I found a fun issue. I had a small module which had a default export of an asynchronous function. Let’s pretend it was something like this:

const async function doAsync() {
	let result;
	try {
		result = await Promise.resolve(true);
	} catch(e) {
		result = false;
	return result;

module.exports = doAsync;

Now over in ES6 Webpack land - this completely fails to import - with strange errors about defaults and export not being defined.

I need to create a test project demonstrating this. I have yet to find any explicit documentation about this particular issue…but boy is it definitely an edge case.