fix(vite): improve commonjs handling (#3336)

Fixes https://github.com/denoland/fresh/issues/3323
This commit is contained in:
Marvin Hagemeister
2025-09-04 12:59:13 +02:00
committed by GitHub
parent b94aab2a1a
commit 4138b8ca66
17 changed files with 1096 additions and 218 deletions
@@ -0,0 +1,4 @@
// deno-lint-ignore no-explicit-any
export default function entries(obj: any) {
return Object.entries(obj);
}
@@ -0,0 +1,30 @@
export interface ColorSupport {
level: 1 | 2 | 3;
hasBasic: boolean;
has256: boolean;
has16m: boolean;
}
function toLevel(depth: number): 1 | 2 | 3 {
if (depth === 1) return 1;
if (depth === 8) return 2;
if (depth === 24) return 3;
return 1;
}
function toSupport(depth: number): ColorSupport {
const level = toLevel(depth);
return {
level,
hasBasic: true,
has256: level >= 2,
has16m: level >= 3,
};
}
export default {
// deno-lint-ignore no-process-global
stdout: toSupport(process.stdout.getColorDepth()),
// deno-lint-ignore no-process-global
stderr: toSupport(process.stderr.getColorDepth()),
};