Skip to content

when setting optimization.providedExports to false, outputModule wouldn't generate export statement #18056

@alexander-akait

Description

@alexander-akait

Discussed in #17902

Originally posted by hardfist December 28, 2023
I'm not sure whether it's by design or bug, it seems outputModule relys on setting optimization.providedExports to true, otherwise it wouldn't generate the export statement
you can reproduce here https://github.com/web-infra-dev/rspack-repro/tree/esm-output

  • optimization.providedExports=true
const external_react_namespaceObject = x({ ["default"]: () => __WEBPACK_EXTERNAL_MODULE_react__["default"] });
;// CONCATENATED MODULE: ./src/index.js

console.log({React: external_react_namespaceObject["default"]});

var __webpack_exports__React = __webpack_exports__._;
export { __webpack_exports__React as React };
  • optimization.providedExports = false
var __webpack_exports__ = {};

;// CONCATENATED MODULE: external "react"
var x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
var y = x => () => x
const external_react_namespaceObject = x({ ["default"]: () => __WEBPACK_EXTERNAL_MODULE_react__["default"] });
;// CONCATENATED MODULE: ./src/index.js

console.log({React: external_react_namespaceObject["default"]});
// missing the export statement


```</div>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions