Skip to content

Commit 047691b

Browse files
committed
feat: add subpath exports for individual parsers
Add an exports field to package.json exposing json, raw, text, and urlencoded parsers as subpath exports. This allows consumers to import individual parsers directly: - CommonJS: require('body-parser/json') - ESM: import json from 'body-parser/json' The change is fully backward compatible and enables users to opt into loading only the parsers they need.
1 parent 5740886 commit 047691b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
"type": "opencollective",
1313
"url": "https://opencollective.com/express"
1414
},
15+
"exports": {
16+
".": "./index.js",
17+
"./package.json": "./package.json",
18+
"./json": "./lib/types/json.js",
19+
"./raw": "./lib/types/raw.js",
20+
"./text": "./lib/types/text.js",
21+
"./urlencoded": "./lib/types/urlencoded.js"
22+
},
1523
"dependencies": {
1624
"bytes": "^3.1.2",
1725
"content-type": "^1.0.5",

0 commit comments

Comments
 (0)