-
-
Notifications
You must be signed in to change notification settings - Fork 613
Closed
Labels
Description
- Rollup Plugin Name: @rollup/plugin-commonjs
- Rollup Plugin Version: 18.1.0
- Rollup Version: 2.47.0
- Operating System (or Browser): MacOS 11.3 (Apple Silicon)
- Node Version: 15.10.0
- Link to reproduction: https://replit.com/@jacquesblom/rollup-commonjs-default-import
Expected Behavior
react-outside-click-handler is an ES module package that is built to CJS. It sets the __esModule property on its exports (see here).
So when I import it (import OutsideClickHandler from "react-outside-click-handler") with the help of @rollup/plugin-commonjs, I'd expect OutsideClickHandler to be the module's default export.
My assumption is based on the behaviour mentioned in #481.
Actual Behavior
Importing the module returns the whole namespace:
import OutsideClickHandler from "react-outside-click-handler"
/*
OutsideClickHandler is...
{
default: [Function: OutsideClickHandler] {
propTypes: {
children: [Function: bound checkType],
onOutsideClick: [Function: bound checkType],
disabled: [Function],
useCapture: [Function],
display: [Function],
'prop-types-exact: ': [Function]
},
defaultProps: { disabled: false, useCapture: true, display: 'block' }
}
}
*/Additional Information
I have tried various combinations of the plugin's options but the behaviour is always the same.
The entry point for react-outside-click-handler is this file, which doesn't define __esModule. Is that where it's missing?
Others have experienced this with ViteJS but the packages mentioned there don't define __esModule.
jwoo0122, githoniel, ChaituVR, maoxiaoke and ezze