Skip to content

Commit

Permalink
fix: use structuredClone instead of lodash when supported (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
steverep authored Feb 29, 2024
1 parent aee7270 commit 7c2bf49
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const PluginError = require('plugin-error');
const through = require('through');
const Vinyl = require('vinyl');

// Polyfill structuredClone with lodash to support node versions < 17.
if (typeof global.structuredClone !== 'function') {
global.structuredClone = cloneDeep;
}

const PLUGIN_NAME = 'gulp-merge-json';

const mergeOrConcatArrays = (concatArrays, mergeArrays) => (objValue, srcValue) => {
Expand Down Expand Up @@ -63,7 +68,7 @@ module.exports = function mergeJson(opts) {
throw new PluginError(PLUGIN_NAME, `${PLUGIN_NAME}: Invalid start and/or end object!`);
}

let merged = cloneDeep(options.startObj);
let merged = structuredClone(options.startObj);
let firstFile = null;

function parseAndMerge(file) {
Expand Down

0 comments on commit 7c2bf49

Please sign in to comment.