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/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
// Expose Slider 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
// set via the explicit `.default` assignment 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 the Slider class itself — *not* a
// `{default: Slider, __esModule: true}` namespace object.
//
// Without the `module.exports = Slider` line, the compiled lib/index.js emits
// `exports.default = Slider; 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 `<Slider />` crashes with
// `Element type is invalid: ... got: object` (React error #130).
// See https://github.com/rolldown/rolldown/issues/8061.

import Slider from "./slider";

export default Slider;
module.exports = Slider;
module.exports.default = Slider;