Skip to content

Commit 363fe9d

Browse files
committed
fix: use static exports instead of lazy getters
Static exports allow Node.js cjs-module-lexer to detect named exports correctly, improving ESM interop and bundler behavior.
1 parent 8c36f57 commit 363fe9d

2 files changed

Lines changed: 9 additions & 20 deletions

File tree

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
unreleased
2+
========================
3+
4+
* fix: use static exports instead of lazy getters to improve ESM compatibility
5+
16
2.2.2 / 2026-01-07
27
=========================
38

index.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,25 @@ exports = module.exports = bodyParser
2424
* JSON parser.
2525
* @public
2626
*/
27-
Object.defineProperty(exports, 'json', {
28-
configurable: true,
29-
enumerable: true,
30-
get: () => require('./lib/types/json')
31-
})
27+
exports.json = require('./lib/types/json')
3228

3329
/**
3430
* Raw parser.
3531
* @public
3632
*/
37-
Object.defineProperty(exports, 'raw', {
38-
configurable: true,
39-
enumerable: true,
40-
get: () => require('./lib/types/raw')
41-
})
33+
exports.raw = require('./lib/types/raw')
4234

4335
/**
4436
* Text parser.
4537
* @public
4638
*/
47-
Object.defineProperty(exports, 'text', {
48-
configurable: true,
49-
enumerable: true,
50-
get: () => require('./lib/types/text')
51-
})
39+
exports.text = require('./lib/types/text')
5240

5341
/**
5442
* URL-encoded parser.
5543
* @public
5644
*/
57-
Object.defineProperty(exports, 'urlencoded', {
58-
configurable: true,
59-
enumerable: true,
60-
get: () => require('./lib/types/urlencoded')
61-
})
45+
exports.urlencoded = require('./lib/types/urlencoded')
6246

6347
/**
6448
* Create a middleware to parse json and urlencoded bodies.

0 commit comments

Comments
 (0)