dnd-multi-backend icon indicating copy to clipboard operation
dnd-multi-backend copied to clipboard

CJS build incompatible with react-dnd v16

Open jadenv opened this issue 3 years ago • 4 comments

The latest release of react-dnd is now only published as an ECMAScript module. See here: https://github.com/react-dnd/react-dnd/releases/tag/v16.0.0

This ends up breaking react-dnd-preview's CommonJS distribution (dist/cjs folder) with an error like this:

Error: Must use import to load ES Module: /node_modules/react-dnd/dist/index.js
require() of ES modules is not supported.
require() of /node_modules/react-dnd/dist/index.js from /node_modules/react-dnd-preview/dist/cjs/usePreview.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /node_modules/react-dnd/package.json.

jadenv avatar Apr 06 '22 15:04 jadenv

Hi @jadenv, thanks for raising this issue.

I guess that means I'll need to drop CommonJS distribution or is there any other way to address this problem?

LouisBrunner avatar Aug 31 '22 14:08 LouisBrunner

@LouisBrunner yeah, I think dropping the CommonJS dist going forward would make sense since react-dnd is ESM-Only too.

jadenv avatar Aug 31 '22 14:08 jadenv

I have implemented it on main (latest ReactDnD, ESM-only) but I am having some webpack issues when dealing with ESM.

In case you have any idea how to solve this, don't hesitate to raise a PR. (https://louisbrunner.github.io/dnd-multi-backend/examples/react-dnd-multi-backend.html)

LouisBrunner avatar Sep 01 '22 15:09 LouisBrunner

@LouisBrunner https://github.com/LouisBrunner/dnd-multi-backend/pull/91 if you can check

maiconcarraro avatar Sep 15 '22 05:09 maiconcarraro

Just reverted main so the demo works again, v8 changes are now on the next branch for anyone interested.

LouisBrunner avatar Sep 26 '22 11:09 LouisBrunner

first, thanks a lot for this great library :)

is this next branch going to be merged to main for a new version? I'm using dnd with this library in a project that recently got switched to nextjs and it's failing to compile due to the Common JS module, or could version be added to the package.json file so that a specific branch can be installed with yarn? I could create a PR for it if needed

carlos-movember avatar Sep 29 '22 02:09 carlos-movember

@carlos-movember I just released 8.0.0-alpha.0 under the next tag on NPM, feel free to feedback here if it works

LouisBrunner avatar Dec 06 '22 21:12 LouisBrunner

8.0.0-alpha.0 is working perfectly for me !

TCheruy avatar Dec 09 '22 16:12 TCheruy

@TCheruy Thank you for confirming. Could you give 8.0.0-alpha.1 a tryand tell me if it also works for you?

If it does, I will be finally releasing 8.0.0 under the latest tag and finally close this issue 🎉

LouisBrunner avatar Dec 10 '22 17:12 LouisBrunner

@LouisBrunner Yep, it's working for me, thanks for your work !

TCheruy avatar Dec 12 '22 17:12 TCheruy

@TCheruy Thank you for confirming.

8.0.0 is now live! 🚀

LouisBrunner avatar Dec 13 '22 17:12 LouisBrunner