Conflicting ESM star re-exports should yield a SyntaxError

Bug report

What is the current behavior?

If a file has conflicting star exports, the first export takes precedence, and no error is raised. In the inline example below, "foo1" is logged.

If the current behavior is a bug, please provide the steps to reproduce.

Repo with reproduction steps: https://github.com/rtsao/webpack-esm-bug-repro

Inline example for convenience:

// index.mjs
import {foo} from "./foo.mjs";
console.log(foo);
// foo.mjs
export * from "./foo1.mjs";
export * from "./foo2.mjs";
// foo1.mjs
export const foo = "foo1";
// foo2.mjs
export const foo = "foo2";

What is the expected behavior?

If there is conflicting re-exports for foo, then a SyntaxError should be thrown (preferably at build-time).

This happens in:

Node 8:

SyntaxError: The requested module contains conflicting star exports for name ‘foo’

Chrome 67

Uncaught SyntaxError: The requested module ‘./foo.mjs’ contains conflicting star exports for name ‘foo’

Safari 11

SyntaxError: Importing binding name ‘foo’ cannot be resolved due to ambiguous multiple bindings.

Other relevant information:
webpack version: 4.12.0
Node.js version: 8.11.2
Operating System: Mac OS X 10.13
Additional tools:

Author: Fantashit

1 thought on “Conflicting ESM star re-exports should yield a SyntaxError

Comments are closed.