abort-controller icon indicating copy to clipboard operation
abort-controller copied to clipboard

Add extension to package.json:main

Open betamos opened this issue 4 years ago • 1 comments

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.

betamos avatar Mar 17 '20 09:03 betamos

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"
    }
  },

ptpaterson avatar Jan 25 '22 16:01 ptpaterson