Skip to content

Conversation

@edsrzf
Copy link
Contributor

@edsrzf edsrzf commented Jul 30, 2020

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().)

Interop issues with @rollup/plugin-commonjs are discussed in great detail here: rollup/plugins#481

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.

@okonet okonet merged commit adf4856 into react-dropzone:master Jul 30, 2020
@github-actions
Copy link

🎉 This PR is included in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ayal ayal mentioned this pull request Jul 30, 2020
@edsrzf edsrzf deleted the es-module branch July 30, 2020 19:35
@edsrzf
Copy link
Contributor Author

edsrzf commented Jul 30, 2020

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants