flitbit / diff

Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.
MIT License
2.99k stars 213 forks source link

TypeError: Cannot set property 'DeepDiff' of undefined #131

Closed xavdid closed 5 years ago

xavdid commented 6 years ago

Using version 1.0.1, I'm getting that error thrown here.

What's weird is that the code works fine in isolation, but when dropped into my company's monolith, I get that error when running tests. Given that, my guess is that it's related to our using babel-jest, which does some pre-processing on our code.

It looks like #129 addressed this, but there might still be something up with it.

xanderberkein commented 6 years ago

Got the same issue here on 1.0.1 in a react-native project.

ellej16 commented 6 years ago

Heya! Got the same issue on libraries which have this as a dependency. What workarounds/fixes did you guys settle on? @xanderberkein @xavdid

xanderberkein commented 6 years ago

@ellej16 Check out my PR! https://github.com/flitbit/diff/pull/134

ellej16 commented 6 years ago

Heya! Quite new in js so i don't understand much how it got fixed, but I suppose the PR fixes web issues as well?

Hopefully this one gets merged and released soon! In the meantime might have to use another library unfortunately :/ (will use it at a different project hopefully!)

But thanks for replying @xanderberkein !

xanderberkein commented 6 years ago

The PR works for any environment where root isn't defined.

You can try testing it out by importing my branch in your "main" project. All dependencies should use that version as well then:

yarn add github:xanderberkein/diff#master
xavdid commented 5 years ago

@xanderberkein any chance of that getting merged here and released as part fo the original diff?

xanderberkein commented 5 years ago

Yes, my PR has been merged! Should be part of diff since 1.0.2

xavdid commented 5 years ago

Ah, perfect! I've confirmed this is resolved. Thanks so much.