Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/react-jw-player.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,24 @@ class ReactJWPlayer extends Component {
ReactJWPlayer.defaultProps = defaultProps;
ReactJWPlayer.displayName = displayName;
ReactJWPlayer.propTypes = propTypes;
export default ReactJWPlayer;

// Expose ReactJWPlayer as the CJS `module.exports` directly so the compiled
// entry works under both of the default-import conventions that bundlers use
// for CJS modules:
//
// - The Babel-interop path used by Rollup, webpack < 5, Vite 7, and bundlers
// that honor `__esModule: true`: reads `exports.default`, which we still
// expose via `module.exports.default = ReactJWPlayer` below.
// - The Node ESM-for-CJS path used by Vite 8 (rolldown), webpack 5, and Node
// itself when the consumer package has `"type": "module"`: reads
// `module.exports`, which is now the ReactJWPlayer class itself — *not* a
// `{default: ReactJWPlayer, __esModule: true}` namespace object.
//
// Without this, the compiled dist/react-jw-player.js emits
// `exports.default = ReactJWPlayer; exports.__esModule = true;` and leaves
// `module.exports` as the full `exports` object, so consumers on the Node
// ESM-for-CJS path receive that namespace and `<ReactJWPlayer />` crashes
// with `Element type is invalid: ... got: object` (React error #130).
// See https://github.com/rolldown/rolldown/issues/8061.
module.exports = ReactJWPlayer;
module.exports.default = ReactJWPlayer;