Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Using lodash.merge for all merges (except webpack). #292

Merged
merged 4 commits into from
Oct 11, 2017

Conversation

Blackbaud-BobbyEarl
Copy link

@Blackbaud-BobbyEarl Blackbaud-BobbyEarl commented Oct 5, 2017

@codecov-io
Copy link

codecov-io commented Oct 5, 2017

Codecov Report

Merging #292 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #292   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          58     59    +1     
  Lines        1358   1365    +7     
  Branches      205    206    +1     
=====================================
+ Hits         1358   1365    +7
Flag Coverage Δ
#builder 100% <100%> (ø) ⬆️
#runtime 100% <ø> (ø) ⬆️
#srcapp 100% <ø> (ø) ⬆️
Impacted Files Coverage Δ
cli/build.js 100% <100%> (ø) ⬆️
utils/runtime-test-utils.js 100% <100%> (ø) ⬆️
config/sky-pages/sky-pages.config.js 100% <100%> (ø) ⬆️
utils/merge.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92dfe68...b59b918. Read the comment docs.

@Blackbaud-BobbyEarl
Copy link
Author

Blackbaud-BobbyEarl commented Oct 5, 2017

Also thanks to @blackbaud-brandonhare for tracking down the original bug in #288.

For future clarity, other alternatives and their pitfalls explained below:

  1. https://www.npmjs.com/package/merge For reasons that aren't entirely clear, this merge library was unable to have the override merge delete a key. So if default was { test: { inner: true } } was merged override { test: false }, test was still set. This behavior was documented in the original bug.

  2. https://www.npmjs.com/package/webpack-merge This almost worked, except for the plugin property in skyuxconfig.json. By design, those arrays are concatenated in order to work with Webpack.

  3. https://www.npmjs.com/package/lodash.merge This was the best choice as we could pull in just the merge module, instead of all of lodash. It correctly handled recursively merging as well as deleting keys.

Update

  1. Turns out, the default behavior for lodash.merge is merge arrays by taking the value at each index. So ['val1', 'val2'] merged with ['val3'] would produce ['val3', 'val2']. Not the behavior we want. Instead, we can use the lodash.mergeWith module and provider our own customizer. Again, @blackbaud-brandonhare has provided this work!

@Blackbaud-SteveBrush
Copy link
Member

Related? blackbaud/skyux2#1181

@Blackbaud-BobbyEarl Blackbaud-BobbyEarl changed the title Using lodash.merge for all merges (except webpack). [HOLD] Using lodash.merge for all merges (except webpack). Oct 9, 2017
* Updated merge to override arrays.

* Update package.json

* Renamed utils file.
* Updated merge to override arrays.

* Update package.json

* Renamed utils file.

* Fixed require
@Blackbaud-BobbyEarl Blackbaud-BobbyEarl merged commit 52e31ac into master Oct 11, 2017
@Blackbaud-BobbyEarl Blackbaud-BobbyEarl changed the title [HOLD] Using lodash.merge for all merges (except webpack). Using lodash.merge for all merges (except webpack). Oct 11, 2017
@Blackbaud-BobbyEarl Blackbaud-BobbyEarl deleted the lodash-merge branch January 20, 2018 22:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants