Skip to content

Conversation

@nlaplante
Copy link

Currently, having the same key in multiple json files doesn't merge them together. The value from last object having a shared key will be used and will overwrite the values from the other objects under the same key.

This pull request changes this by relying on deepmerge to deeply merge the objects together so that the same key can exist in multiple json files.

Example:

core/en.json

{
  'key1': 'something',
  'key2:' {
    'another': 'thing'
  }
}

addons/en.json

{
  'key2': {
    'and': 'this'
  }
}

will result in:

{
  'key1': 'something',
  'key2: {
    'another': 'thing',
    'and': 'this'
  }
}

@denniske denniske merged commit e0173a2 into rbalet:master Sep 13, 2018
@denniske
Copy link
Collaborator

Looking good. Thank you :)

@nlaplante
Copy link
Author

Thanks for merging this quick! 👍

@GuillaumeSpera
Copy link

Hello, since deepmerge has been added, I have the following error :

ERROR in ./node_modules/ngx-translate-multi-http-loader/fesm5/ngx-translate-multi-http-loader.js
Module not found: Error: Can't resolve 'deepmerge' in '.\node_modules\ngx-translate-multi-http-loader\fesm5'

I don't see any trace of deepmerge in the dependencies of the published package.
I have the lastest version
"_id": "ngx-translate-multi-http-loader@2.1.0",

Does it works for you guys ?

@denniske
Copy link
Collaborator

We have added deepmerge in the dependencies dictionary in the package.json. I dont know why this does not work.

Note that the dependencies are also not correctly listed on other packages like:
https://www.npmjs.com/package/@ngx-translate/http-loader

As a workaround you can probably add deepmerge to the package.json of your project.

I will figure out how to add the dependencies correctly.

@GuillaumeSpera
Copy link

Thanks for the quick answer :)

I did try to add deepmerge directly to my project, didn't work either.
I do see the dependencies in the Github repository, I don't know how published package behave as to why the package.json of the module doesn't have the same dependencies.

I'll post here if I can find a temporary fix.

@nlaplante
Copy link
Author

There seems to be some issues in package.json. First, there's no version tag. Additionally, the package is flagged as private (see private: true). I don't know if this has an effect on the issue?

@GuillaumeSpera
Copy link

After clearing all node modules and reinstalling everything, I made it work by adding the deepmerge dependency to my project.

Still need to fix the published package.json though

@denniske
Copy link
Collaborator

denniske commented Oct 8, 2018

I have added deepmerge to the dependencies now. So everything should work now without you having to include it manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants