This repo is a minimal reproducible example of a bug in webpack that happens when combining ESM library output with runtimeChunk: single.

See webpack/webpack#2933 (comment)

  • Build the project with yarn build
  • Terser will complain about an export appearing in a location that's not the toplevel of a module.

The generated code that Terser chokes on looks like this:

(__webpack_require__) => {
  var __webpack_exec__ = (moduleId) =>
    __webpack_require__((__webpack_require__.s = moduleId));
  var __webpack_exports__ = __webpack_exec__(533);
  var __webpack_exports__default = __webpack_exports__.Z;
  export { __webpack_exports__default as default };
};