Git Product home page Git Product logo

Comments (5)

gpbl avatar gpbl commented on May 21, 2024

🤔 I don't see how the package.json could affect the behavior of the library . How are you importing it?

from denormalizr.

larsbs avatar larsbs commented on May 21, 2024

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 [email protected] (no browser field in package.json)
console.log(result)  // { id: 1, name: 'Test', users: [{ id: 1, name: 'Lars', group: [circular]}] };

// if we use [email protected] (browser field in package.json)
console.log(result)  // { id: 1, name: 'Test', users: [{}] };

// If we manually remove browser field from [email protected] 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 browser field instead of the main field.

from denormalizr.

gpbl avatar gpbl commented on May 21, 2024

I'm using webpack to bundle the library, so probably it's related to webpack using the browser field instead of the main field.

Interesting, thanks, this should be the reason. Are you using webpack 1?

from denormalizr.

larsbs avatar larsbs commented on May 21, 2024

Yes, [email protected] to be more precise.

from denormalizr.

gpbl avatar gpbl commented on May 21, 2024

@larsbs this should be fixed in v0.5.2! Thanks for the report, really appreciated 👍
Please reopen if not working as expected.

from denormalizr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.