Skip to content

Commit 332c98b

Browse files
committed
fix: web-fragments#83 - only show console logs in dev mode
1 parent 74c3af5 commit 332c98b

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

.changeset/two-weeks-own.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"reframed": patch
3+
---
4+
5+
fix: #83 - only show console logs in dev mode

packages/reframed/src/reframed.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,12 @@ async function reframeWithFetch(
145145
.pipeThrough(new TextDecoderStream())
146146
.pipeTo(new WritableDOMStream(target))
147147
.finally(() => {
148-
console.log("reframing done (reframeWithFetch)!", {
149-
source: reframedSrc,
150-
target,
151-
title: iframe.contentDocument?.title,
152-
});
148+
import.meta.env.DEV &&
149+
console.log("reframing done (reframeWithFetch)!", {
150+
source: reframedSrc,
151+
target,
152+
title: iframe.contentDocument?.title,
153+
});
153154
resolve();
154155
});
155156
});
@@ -188,10 +189,11 @@ async function reframeFromTarget(
188189
);
189190
});
190191

191-
console.log("reframing done (reframeFromTarget)!", {
192-
source,
193-
title: document.defaultView!.document.title,
194-
});
192+
import.meta.env.DEV &&
193+
console.log("reframing done (reframeFromTarget)!", {
194+
source,
195+
title: document.defaultView!.document.title,
196+
});
195197
resolve();
196198
});
197199

packages/web-fragments/tsconfig.base.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"moduleResolution": "Bundler",
1818
"resolveJsonModule": true,
1919
"isolatedModules": true,
20-
"jsx": "react-jsx"
20+
"jsx": "react-jsx",
21+
"types": ["vite/client"]
2122
}
2223
}

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"module": "ES2022",
66
"lib": ["ESNext", "DOM", "DOM.Iterable"],
77
"skipLibCheck": true,
8+
"types": ["vite/client"],
89

910
/* Bundler mode */
1011
"moduleResolution": "bundler",

0 commit comments

Comments
 (0)