Skip to content

Commit 41d6286

Browse files
committed
fix(typescript): address Greptile review findings on TS7 upgrade
- packages/logger: 'window' in globalThis treats a shim that leaves globalThis.window explicitly undefined as browser-only, silently dropping production server logs. Restore the original typeof !== 'undefined' semantics via an inline cast instead, so it stays correct without requiring DOM lib in every consumer. - packages/ts-sdk, packages/cli: both are tsc-built, published as Node ESM (package.json "type": "module" with an "exports" map). "moduleResolution": "bundler" is too permissive for that target - it accepts import patterns (e.g. extensionless relative imports) that Node's actual ESM resolver rejects at runtime. Switch both to "module"/"moduleResolution": "nodenext", the correct pairing for a published Node ESM package. Verified real tsc builds (not just --noEmit) still succeed for both.
1 parent 222716d commit 41d6286

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/cli/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"extends": "@sim/tsconfig/library-build.json",
33
"compilerOptions": {
44
"target": "ES2020",
5-
"moduleResolution": "bundler",
5+
"module": "nodenext",
6+
"moduleResolution": "nodenext",
67
"outDir": "./dist",
78
"rootDir": "./src"
89
},

packages/logger/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ export class Logger {
201201
private shouldLog(level: LogLevel): boolean {
202202
if (!this.config.enabled) return false
203203

204-
if (getNodeEnv() === 'production' && 'window' in globalThis) {
204+
if (
205+
getNodeEnv() === 'production' &&
206+
typeof (globalThis as { window?: unknown }).window !== 'undefined'
207+
) {
205208
return false
206209
}
207210

packages/ts-sdk/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"extends": "@sim/tsconfig/library-build.json",
33
"compilerOptions": {
44
"target": "ES2020",
5-
"module": "ES2020",
5+
"module": "nodenext",
66
"lib": ["ES2020"],
7-
"moduleResolution": "bundler",
7+
"moduleResolution": "nodenext",
88
"outDir": "./dist",
99
"rootDir": "./src"
1010
},

0 commit comments

Comments
 (0)