angular-skyhook icon indicating copy to clipboard operation
angular-skyhook copied to clipboard

backend.backend is not a constructor

Open mikanyg opened this issue 6 years ago • 6 comments

Just updated to version 1.3.2 of @angular-skyhook/multi-backend and 1.3.0 of @angular-skyhook/core and I am getting the following error:

ERROR TypeError: backend.backend is not a constructor at MultiBackend.js:239 at Array.forEach () at new _default (MultiBackend.js:227) at index.js:60 at angular-skyhook-multi-backend.js:45 at createDragDropManager (factories.js:4) at angular-skyhook-core.js:1543 at ZoneDelegate.invoke (zone-evergreen.js:359) at Zone.run (zone-evergreen.js:124) at NgZone.runOutsideAngular (core.js:39571)

Did I miss some breaking change between 1.2.1 and 1.3.0/1.3.2 ?

mikanyg avatar Oct 13 '19 15:10 mikanyg

It’s a bit weird that the issue would only show up now, considering dnd-multi-backend has apparently always treated backends as constructors. The main backends are not actually constructors. Can you file or search for an issue on LouisBrunner/dnd-multi-backend ? Note that we’re still using 3.x as I couldn’t get 4.0 to work at all, so that’s another one.

https://github.com/react-dnd/react-dnd/blob/704245d47892f9d465b1b4465203f5c8464eb5a7/packages/core/html5-backend/src/index.ts#L7-12

cormacrelf avatar Oct 14 '19 04:10 cormacrelf

(Oh, I figured out that dnd-multi-backend 4.0 is a really breaking change, requiring using react-dnd-cjs and all the -cjs versions of all those packages. I won’t make my dependents do that (and then switch back), so no v4, only v5 which will fix this apparently.)

Upshot is we probably need a maintenance release on 3.x, or a workaround wrapper class to make every backend a constructor even when it’s not. I think 4.0 was mainly react-dnd-centric changes, which is why 3.x still works with dnd-core v9 if you partially apply your backends to pass options in. @LouisBrunner any chance of a 3.x fix?

cormacrelf avatar Oct 14 '19 05:10 cormacrelf

See the issue on dnd-multi-backend. Essentially, you can also work around this by transpiling to ES5 in all cases. Angular 8 I believe will try to deliver ES2015 to capable browsers, but if you turn that off (however that works), this will probably work again. I would probably just wait for another patch release that upgrades to dnd-multi-backend 5.0.0, which is now in alpha and will hopefully include my PR.

cormacrelf avatar Oct 19 '19 09:10 cormacrelf

@cormacrelf 5.0.0-rc02 (and future v5) should address this. You mention a 3.x fix, do you mean the same fix applied on the v3 branch?

LouisBrunner avatar Oct 19 '19 13:10 LouisBrunner

Nah don’t worry about it if you’ve already got 5 off the ground

cormacrelf avatar Oct 19 '19 13:10 cormacrelf

Any news on when the next release will be out?

mikanyg avatar Jan 26 '20 22:01 mikanyg