diff --git a/CHANGES.md b/CHANGES.md index 482939a..e6bdc04 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,11 @@ Version 0.6.4 To be released. + - Fixed a build warning due to importing `node:fs` and `node:util` modules on + Next.js' client rendering. [[#19]] + +[#19]: https://github.com/dahlia/logtape/issues/19 + Version 0.6.3 ------------- diff --git a/logtape/fs.cjs b/logtape/fs.cjs index 40171ff..fe20ac6 100644 --- a/logtape/fs.cjs +++ b/logtape/fs.cjs @@ -1,10 +1,12 @@ let fs = null; if ( - "process" in globalThis && "versions" in globalThis.process && - "node" in globalThis.process.versions && - typeof globalThis.caches === "undefined" && - typeof globalThis.addEventListener !== "function" || - "Bun" in globalThis + typeof window === "undefined" && ( + "process" in globalThis && "versions" in globalThis.process && + "node" in globalThis.process.versions && + typeof globalThis.caches === "undefined" && + typeof globalThis.addEventListener !== "function" || + "Bun" in globalThis + ) ) { try { // Intentionally confuse static analysis of bundlers: diff --git a/logtape/nodeUtil.cjs b/logtape/nodeUtil.cjs index dc5c169..0984aff 100644 --- a/logtape/nodeUtil.cjs +++ b/logtape/nodeUtil.cjs @@ -1,10 +1,12 @@ let util = null; if ( - "process" in globalThis && "versions" in globalThis.process && - "node" in globalThis.process.versions && - typeof globalThis.caches === "undefined" && - typeof globalThis.addEventListener !== "function" || - "Bun" in globalThis + typeof window === "undefined" && ( + "process" in globalThis && "versions" in globalThis.process && + "node" in globalThis.process.versions && + typeof globalThis.caches === "undefined" && + typeof globalThis.addEventListener !== "function" || + "Bun" in globalThis + ) ) { try { // Intentionally confuse static analysis of bundlers: