abort-controller
abort-controller copied to clipboard
Add extension to package.json:main
I'm seeing breakages with Webpack, and several other issues and forks seem to indicate issues with bundlers.
My understanding, which is shallow, is that at one point it was recommended to use extension-less main
. It seem that now the recommendation is to use main
with an extension, and that should probably be the js file, for compatibility.
As for the ES modules etc, there are now conditional exports through the exports
field.
I had issues using this package with create-react-app
and webpack 5. One solution I found was to add this to package.json
"exports": {
".": {
"import": "./dist/abort-controller.mjs",
"require": "./dist/abort-controller.js",
"default": "./dist/abort-controller.js"
},
"./polyfill": {
"import": "./polyfill.mjs",
"require": "./polyfill.js",
"default": "./polyfill.js"
}
},