attr-accept icon indicating copy to clipboard operation
attr-accept copied to clipboard

ESM build

Open edemaine opened this issue 2 years ago • 2 comments

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

edemaine avatar Jul 21 '23 19:07 edemaine

Superseded by https://github.com/react-dropzone/attr-accept/pull/66?

rolandjitsu avatar Oct 04 '24 20:10 rolandjitsu

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" to package.json so that tests are treated as ESM. All files were already ESM anyway, except:
  • Rename webpack.config.js to webpack.config.cjs so 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.

edemaine avatar Oct 09 '24 19:10 edemaine

This one can be closed now that #75 was merged.

jonkoops avatar Nov 11 '24 12:11 jonkoops