Skip to content

Commit

Permalink
Fix build warning on Next.js' client rendering
Browse files Browse the repository at this point in the history
Address #19
  • Loading branch information
dahlia committed Oct 5, 2024
1 parent cd3cba5 commit ebc4eb1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------
Expand Down
12 changes: 7 additions & 5 deletions logtape/fs.cjs
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
12 changes: 7 additions & 5 deletions logtape/nodeUtil.cjs
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit ebc4eb1

Please sign in to comment.