Closed char0n closed 3 years ago
Browser field is here for backwards compatibility only and will be removed as I move to ESM only (near Node.js v12 EOL).
I also have module
field that points to esm version of this module, for bundlers.
Sure, but for example in webpack, browser field gets priority over module field - https://webpack.js.org/configuration/resolve/#resolvemainfields. This effectively means that CJS version of formdata is being bundled instead of ESM one.
Don't Webpack read exports
first?
Yes, webpack@5 reads exports
, and then fallback to browser
. webpack@4 (everything running on create react app) uses browser
field and ignores exports
field.
It's no big deal, just IMHO pointing browser
field to ESM build makes more sense as webpack@4 is still very widely used. I can issue a PR.
I don't really see any reason for this change if webpack can deal with it. Browser field will be removed anyway in the nearest future and there's almost no content in browser.ts
Right, I've just pointed to this and thought that it might be oversight.
I've noticed that the
browser
field is defined in following way:Wouldn't it make more sense to point the field to
./lib/esm/browser.js
? I know the file doesn't have any imports, so it doesn't really matter if it's CJS or ESM, but looks odd to be pointing to CJS.