This repository has been archived by the owner on Nov 17, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Related entities not correctly populated in latest version #38
Labels
Comments
🤔 I don't see how the package.json could affect the behavior of the library . How are you importing it? |
It's not very difficult to reproduce. The following sample code shows what's happening: import { schema } from 'normalizr';
import { denormalize } from 'denormalizr';
const user = new schema.Entity('user', {
group: group
});
const group = new schema.Entity('group', {
users: [user],
});
const entity = { id: 1, name: 'Lars', group: 1 };
const entities = {
user: {
1: { id: 1, name: 'Lars', group: 1 },
},
group: {
1: { id: 1, name: 'Test', users: [1] },
},
};
const result = denormalize(entity, entities, group);
// If we use denormalizr@0.5.0 (no browser field in package.json)
console.log(result) // { id: 1, name: 'Test', users: [{ id: 1, name: 'Lars', group: [circular]}] };
// if we use denormalizr@0.5.1 (browser field in package.json)
console.log(result) // { id: 1, name: 'Test', users: [{}] };
// If we manually remove browser field from denormalizr@0.5.1 package.json
console.log(result) // { id: 1, name: 'Test', users: [{ id: 1, name: 'Lars', group: [circular]}] }; I'm using webpack to bundle the library, so probably it's related to webpack using the |
Interesting, thanks, this should be the reason. Are you using webpack 1? |
Yes, |
@larsbs this should be fixed in |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The newest update (v0.5.1) has introduced a bug which causes related entities not being populated at all. For instance, if we have [Group] 1 --> * [User], the
users
property is not populated in the finalgroup
object.Seems to be related to the new
browsers
property added topackage.json
since removing this line restores the correct behaviour.The text was updated successfully, but these errors were encountered: