Can't resolve 'react-dnd/lib/DragDropContext' with [email protected]

[email protected] code:

[email protected] looks like changed lib/ directory tree. https://github.com/react-dnd/react-dnd/pull/1205:

[email protected] package.json锛寃ill auto update [email protected]:
"dependencies": {
"frontend-collective-react-dnd-scrollzone": "^1.0.1",
"lodash.isequal": "^4.5.0",
"prop-types": "^15.6.1",
"react-dnd": "^7.0.1",
"react-dnd-html5-backend": "^7.0.1",
"react-lifecycles-compat": "^3.0.4",
"react-virtualized": "^9.19.1"
}
We are also facing the same issue, when can we expect the merge of this PR?
Module not found: Error: Can't resolve 'react-dnd/lib/DragDropContext' in '/temp/node_modules/react-sortable-tree/dist'
We are importing
import { Consumer as DragDropContextConsumer } from 'react-dnd/lib/DragDropContext';
but react-dnd has changed their lib path from react-dnd/lib/DragDropContext to react-dnd/lib/esm/DragDropContext
Please fix this

If you're using this package in a top-level project, you can use a mechanism like Yarn resolutions or npm-force-resolutions to override the resolved version of react-dnd and force a good version (like 7.0.2).
This did not work for my use case, so I've published a forked version of this package as a temporary workaround until this issue is fixed: fixed-react-sortable-tree
It would be great if this was fixed.
https://github.com/react-dnd/react-dnd/issues/1247
See the comment from react-dnd:
It should be in react-dnd/lib/cjs/DragDropContext.js
With the 7.1 release, we added separate builds for ES Modules and CommonJS. Previously they had all been CommonJS. I assumed that most people were importing the types at the library's top level, so I made this a minor version, e.g.:
import {DragDropContext} from 'react-dnd'
@intizarahmad We are not using DragDropContext but Consumer, which is not exported.
Someone probably also should get issue going in react-dnd repository to export DragDropConsumer so this issue could be avoided in future.
Was not very fun to suddenly not be able to build a project without changing anything.
For yarn adding to
"resolutions": {
"react-sortable-tree/**/react-dnd": "7.0.2"
}
to package.json did the trick, thanks @quigleyj-mavenomics for pointing this out
@wuweiweiwu Will you have time to look on it and eventually publish new version?
Guys, where is a solution?
@sunndeath
There are multiple instructions how to immediately unfuck the build process in this thread.
Fix seems to be merged but is not released yet.
@sunndeath
There are multiple instructions how to immediately unfuck the build process in this thread.
Fix seems to be merged but is not released yet.
refactor from:
import { DragDropContext } from 'react-dnd';
to:
import DragDropContext from 'react-dnd/lib/cjs/DragDropContext.js';
don't work for me,
where is the another way to fix it?
Wonder where you tried to put that...
It is a solution to fix library itself not how you use it.
https://github.com/frontend-collective/react-sortable-tree/issues/463#issuecomment-470654505
This is the reason semver exists and MUST be respected! You don't just publish a major breaking change under a minor release version 馃槧
Thanks @quigleyj-mavenomics and @ecnaidar for the temporary solution.
come on~please fix it~~~馃槶
released in 2.6.1!!! Thanks for waiting!
Most helpful comment
If you're using this package in a top-level project, you can use a mechanism like Yarn
resolutionsornpm-force-resolutionsto override the resolved version ofreact-dndand force a good version (like7.0.2).This did not work for my use case, so I've published a forked version of this package as a temporary workaround until this issue is fixed:
fixed-react-sortable-tree