diff --git a/packages/component/src/components/page-list/use-all-page-setting.ts b/packages/component/src/components/page-list/use-all-page-setting.ts index 2ced020fae..8b0c5f5f47 100644 --- a/packages/component/src/components/page-list/use-all-page-setting.ts +++ b/packages/component/src/components/page-list/use-all-page-setting.ts @@ -20,7 +20,7 @@ export interface PageViewDBV1 extends DBSchema { } const pageViewDBPromise: Promise> = - environment.isServer + typeof window === 'undefined' ? // never resolve in SSR new Promise(() => {}) : openDB('page-view', 1, { diff --git a/packages/debug/package.json b/packages/debug/package.json index 74ba021e01..66d0fdaecd 100644 --- a/packages/debug/package.json +++ b/packages/debug/package.json @@ -3,7 +3,6 @@ "private": true, "main": "./src/index.ts", "dependencies": { - "@affine/env": "workspace:*", "debug": "^4.3.4" }, "devDependencies": { diff --git a/packages/debug/src/index.ts b/packages/debug/src/index.ts index c56dcfcd80..8f6cff09aa 100644 --- a/packages/debug/src/index.ts +++ b/packages/debug/src/index.ts @@ -1,12 +1,9 @@ -import { env } from '@affine/env'; import debug from 'debug'; type LogLevel = 'debug' | 'info' | 'warn' | 'error'; - const SESSION_KEY = 'affine:debug'; -const development = env.isDebug; -if (env.isBrowser) { +if (typeof window !== 'undefined') { // enable debug logs if the URL search string contains `debug` // e.g. http://localhost:3000/?debug if (window.location.search.includes('debug')) { @@ -15,11 +12,16 @@ if (env.isBrowser) { // we need to store the debug flag in sessionStorage sessionStorage.setItem(SESSION_KEY, 'true'); } - if (sessionStorage.getItem(SESSION_KEY) === 'true' || development) { + if (sessionStorage.getItem(SESSION_KEY) === 'true') { // enable all debug logs by default debug.enable('*'); console.warn('Debug logs enabled'); } +} else { + if (process.env.NODE_ENV === 'development') { + debug.enable('*'); + console.warn('Debug logs enabled'); + } } export class DebugLogger { diff --git a/packages/debug/tsconfig.json b/packages/debug/tsconfig.json index 7551cd781a..5f50a9a715 100644 --- a/packages/debug/tsconfig.json +++ b/packages/debug/tsconfig.json @@ -8,11 +8,6 @@ "noEmit": false, "outDir": "lib" }, - "references": [ - { - "path": "../env" - } - ], "include": ["./src"], "exclude": ["node_modules"] } diff --git a/yarn.lock b/yarn.lock index 2bafe91885..216ce4e69d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -158,7 +158,6 @@ __metadata: version: 0.0.0-use.local resolution: "@affine/debug@workspace:packages/debug" dependencies: - "@affine/env": "workspace:*" "@types/debug": ^4.1.8 debug: ^4.3.4 languageName: unknown