Skip to content

Commit d220c99

Browse files
authored
fix: bundling compatibility with webpack@5 (#2519)
* fix: bundling compatibility with webpack@5 when using webpack v5 to bundle code that calls `require('sinon')` (cjs) , it would have defaulted to "exports->require" and fail with multiple node-api requirements (util, timers, etc.) this patch ensures that anyone who bundles sinon for browser gets the (browser-compatible) esm version. tested on both webpack v5 and v4. should be noted that v4 worked even without this patch, as it automatically injected polyfills. v5 no longer does so. with this PR, people using webpack@4 to bundle sinon at least see size improvement, as the polyfills are no longer required. * fix: revert change for package.json -> "browser" browserify doesn't seem to like esm. leave that entry point alone, and ensure "exports" -> "browser" (which webpack@5 uses) is esm.
1 parent b4f868d commit d220c99

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"module": "./pkg/sinon-esm.js",
122122
"exports": {
123123
".": {
124+
"browser": "./pkg/sinon-esm.js",
124125
"require": "./lib/sinon.js",
125126
"import": "./pkg/sinon-esm.js"
126127
},

0 commit comments

Comments
 (0)