This PR adds a module entry to package.json, pointing to src/index.js, which allows tools that use ES modules to avoid having to interoperate with the package's CommonJS build. This works around a problem that I've been experiencing including react-dropzone in a project that builds using Rollup.
More Details of My Problem
I'm including react-dropzone in a project that build using Rollup and have run into an issue with it importing this package (attr-accept).
react-dropzone ships an ES module build, but this package does not, which causes @rollup/plugin-commonjs to run into some interop issues, and means that this line ends up trying to call an object, which throws an exception. (It's basically calling accepts() when it needs to be calling accepts.default().)
I've worked around the issue in my project through a horrible hack in my Rollup configuration to add a module entry to this package's package.json. I would love to get a version of this package published that includes it already so I can get rid of my horrible hack. There are other benefits to exposing an ES module build anyway.
This PR adds a
module
entry topackage.json
, pointing tosrc/index.js
, which allows tools that use ES modules to avoid having to interoperate with the package's CommonJS build. This works around a problem that I've been experiencing includingreact-dropzone
in a project that builds using Rollup.More Details of My Problem
I'm including
react-dropzone
in a project that build using Rollup and have run into an issue with it importing this package (attr-accept
).react-dropzone
ships an ES module build, but this package does not, which causes@rollup/plugin-commonjs
to run into some interop issues, and means that this line ends up trying to call an object, which throws an exception. (It's basically callingaccepts()
when it needs to be callingaccepts.default()
.)Interop issues with
@rollup/plugin-commonjs
are discussed in great detail here: https://github.com/rollup/plugins/issues/481I've worked around the issue in my project through a horrible hack in my Rollup configuration to add a
module
entry to this package'spackage.json
. I would love to get a version of this package published that includes it already so I can get rid of my horrible hack. There are other benefits to exposing an ES module build anyway.