Skip to content

Commit 968f14b

Browse files
committed
fix: move browser to top of exports
The order of exports is important. If you want to serve a browser-specific file, it needs to go earlier in the exports object, otherwise one of the other exports will be matched. In this case the file being webpacked was using require, which matched `exports.require` before `exports.browser` so tried to require `./src/lib.cjs`, which then throws as it tries to require `util` which is not a dep of this module. The solution is just to move the `browser` field in front of `require` and `import`.
1 parent 52d7006 commit 968f14b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
"types": "./src/lib.d.ts",
1515
"exports": {
1616
".": {
17+
"browser": "./src/lib.browser.js",
1718
"import": "./src/lib.js",
18-
"require": "./src/lib.cjs",
19-
"browser": "./src/lib.browser.js"
19+
"require": "./src/lib.cjs"
2020
}
2121
},
2222
"scripts": {

0 commit comments

Comments
 (0)