Skip to content

Commit ce4040b

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 ce4040b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
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+
"./lib/*": "./lib/*.js",
23+
"./lib/*.js": "./lib/*.js",
24+
"./lib/types/*": "./lib/types/*.js",
25+
"./lib/types/*.js": "./lib/types/*.js"
26+
},
1527
"dependencies": {
1628
"bytes": "^3.1.2",
1729
"content-type": "^1.0.5",

0 commit comments

Comments
 (0)