Skip to content

Commit 2fbf6fa

Browse files
author
Ahmed Mahmoud
committed
v5.0.2: Add Jest compatibility with dual module builds and clean exports
- Add CommonJS build alongside ESM for Jest compatibility without consumer configuration - Fix mixed named/default exports warning by removing duplicate default export - Update exports to use clean named-only pattern (modern best practice) - Generate both dist/index.js (ESM) and dist/index.cjs (CJS) for maximum compatibility - Update package.json with proper dual module export configuration - Fix 'Entry module is using named and default exports together' Vite warning - Ensure consumers don't need to use .default accessor Resolves Jest 'cannot find module' errors in Next.js 16+ environments Improves consumer experience with cleaner import patterns
1 parent a8fd25b commit 2fbf6fa

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [5.0.2] - 2025-11-11
6+
7+
### Fixed
8+
- 🔧 **Jest Compatibility**: Added CommonJS build alongside ESM for better Jest/testing compatibility
9+
- 📦 **Dual Module Export**: Package now exports both ESM and CJS formats
10+
-**No Configuration Needed**: Works out-of-the-box with Jest in Next.js, CRA, and other environments
11+
12+
### Changed
13+
- **Build Output**: Now generates both `index.js` (ESM) and `index.cjs` (CommonJS)
14+
- **Package Exports**: Updated to properly expose both module formats
15+
16+
## [5.0.1] - 2025-11-11
17+
18+
### Fixed
19+
- 📝 **Documentation**: Updated README with correct scoped package name and installation instructions
20+
- 🔗 **Package Links**: Fixed npm badges and import examples
21+
522
## [5.0.0] - 2025-11-10
623

724
### Breaking Changes

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"name": "@dev-ahmed-mahmoud/react-custom-scrollbars",
3-
"version": "5.0.1",
3+
"version": "5.0.2",
44
"description": "Modern React scrollbars component with TypeScript support and React 19 compatibility",
55
"type": "module",
6-
"main": "./dist/index.js",
6+
"main": "./dist/index.cjs",
77
"module": "./dist/index.js",
88
"types": "./dist/index.d.ts",
99
"exports": {
1010
".": {
1111
"types": "./dist/index.d.ts",
12-
"import": "./dist/index.js"
12+
"import": "./dist/index.js",
13+
"require": "./dist/index.cjs"
1314
}
1415
},
1516
"files": [

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { default as Scrollbars, default } from './Scrollbars'
1+
export { default as Scrollbars } from './Scrollbars'
22
export type {
33
ScrollbarsProps,
44
ScrollbarsRef,

vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export default defineConfig({
1616
lib: {
1717
entry: resolve(import.meta.dirname, 'src/index.ts'), // Use import.meta.dirname (Node 20.11+)
1818
name: 'ReactCustomScrollbars',
19-
formats: ['es'],
20-
fileName: 'index',
19+
formats: ['es', 'cjs'], // Add CommonJS format for Jest compatibility
20+
fileName: (format) => `index.${format === 'es' ? 'js' : 'cjs'}`,
2121
},
2222
rollupOptions: {
2323
external: ['react', 'react-dom'],

0 commit comments

Comments
 (0)