attr-accept
attr-accept copied to clipboard
ESM build
Replace old dist/es/index.js with dist/index.mjs that uses ESM syntax, and properly link to it via module and exports.
Fixes #63
I also updated Webpack because otherwise I couldn't get it to run on modern Node.
What kind of change does this PR introduce?
- [ ] Bug Fix
- [ ] Feature
- [ ] Refactoring
- [ ] Style
- [x] Build
- [ ] Chore
- [ ] Documentation
- [ ] CI
Did you add tests for your changes?
- [ ] Yes, my code is well tested
- [x] Not relevant
If relevant, did you update the documentation?
- [x] Yes, I've updated the documentation
- [ ] Not relevant
Summary
See #63. This lets you import accept from 'attr-accept' in ESM code.
Does this PR introduce a breaking change?
If anyone directly imported dist/es/index.js, it no longer exists. (It seems to be a holdover that made a "fake" ES module.)
Other information
You can test the example in the README by making a file test.mjs and then running node test.mjs. (The .mjs extension forces ESM mode.)
Superseded by https://github.com/react-dropzone/attr-accept/pull/66?
I updated the deps in package-lock.json, as suggested in https://github.com/react-dropzone/attr-accept/pull/66#issuecomment-2403171182
This let me actually try npm testing, and there were some additional issues that needed resolving (now fixed):
- Added
type: "module"topackage.jsonso that tests are treated as ESM. All files were already ESM anyway, except: - Rename
webpack.config.jstowebpack.config.cjsso it can remain in CJS. - Updated Mocha to enable ESM support.
If you want this PR and would rather it use a modern/faster build framework such as esbuild instead of Webpack, let me know.
This one can be closed now that #75 was merged.