Skip to content

Commit

Permalink
Remove deepmerge-ts for simpler implementation (#8086)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Aug 15, 2023
1 parent c19987d commit fa29e4a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
1 change: 0 additions & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@
"common-ancestor-path": "^1.0.1",
"cookie": "^0.5.0",
"debug": "^4.3.4",
"deepmerge-ts": "^4.3.0",
"devalue": "^4.3.2",
"diff": "^5.1.0",
"es-module-lexer": "^1.3.0",
Expand Down
26 changes: 24 additions & 2 deletions packages/astro/src/core/config/tsconfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { deepmerge } from 'deepmerge-ts';
import { existsSync } from 'node:fs';
import { join } from 'node:path';
import * as tsr from 'tsconfig-resolver';
Expand Down Expand Up @@ -96,5 +95,28 @@ export function updateTSConfigForFramework(
return target;
}

return deepmerge(target, presets.get(framework)!);
return deepMergeObjects(target, presets.get(framework)!);
}

// Simple deep merge implementation that merges objects and strings
function deepMergeObjects<T extends Record<string, any>>(a: T, b: T): T {
const merged: T = { ...a };

for (const key in b) {
const value = b[key];

if (a[key] == null) {
merged[key] = value;
continue;
}

if (typeof a[key] === 'object' && typeof value === 'object') {
merged[key] = deepMergeObjects(a[key], value);
continue;
}

merged[key] = value;
}

return merged;
}
8 changes: 0 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fa29e4a

Please sign in to comment.