From 448f21620f7bd22a6d3e19af378bdf6058fe4dd6 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:55:34 -0700 Subject: [PATCH] chore: update client check for smaller bundle size (#12975) --- .changeset/rare-ears-agree.md | 5 +++++ packages/svelte/src/internal/client/timing.js | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/rare-ears-agree.md diff --git a/.changeset/rare-ears-agree.md b/.changeset/rare-ears-agree.md new file mode 100644 index 0000000000..392d32c786 --- /dev/null +++ b/.changeset/rare-ears-agree.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +chore: update client check for smaller bundle size diff --git a/packages/svelte/src/internal/client/timing.js b/packages/svelte/src/internal/client/timing.js index 3b9e5c511d..dc7d2ce4ed 100644 --- a/packages/svelte/src/internal/client/timing.js +++ b/packages/svelte/src/internal/client/timing.js @@ -1,11 +1,11 @@ /** @import { Raf } from '#client' */ import { noop } from '../shared/utils.js'; -const is_client = typeof window !== 'undefined'; +import { BROWSER } from 'esm-env'; -const request_animation_frame = is_client ? requestAnimationFrame : noop; +const request_animation_frame = BROWSER ? requestAnimationFrame : noop; -const now = is_client ? () => performance.now() : () => Date.now(); +const now = BROWSER ? () => performance.now() : () => Date.now(); /** @type {Raf} */ export const raf = {