Skip to content

Commit

Permalink
Merge pull request #1740 from ably/1734/remove-browser-warning-for-ve…
Browse files Browse the repository at this point in the history
…rcel-edge-runtime

[ECO-4742] Remove warning about using web bundle in Vercel Edge runtime
  • Loading branch information
VeskeR authored Apr 17, 2024
2 parents 60faa30 + 66befcb commit d0a43d1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/platform/web/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import * as Utils from 'common/lib/util/utils';
// Workaround for salesforce lightning locker compat
const globalObject = Utils.getGlobalObject();

if (typeof Window === 'undefined' && typeof WorkerGlobalScope === 'undefined') {
// @ts-ignore
const isVercelEdgeRuntime = typeof EdgeRuntime === 'string';

// We get false positive result here in the Vercel Edge runtime because it lacks the usual global browser objects, such as Window.
// However, it is closer to the browser environment, so it intentionally uses browser bundles when importing packages.
// Therefore, we do an additional check to avoid logging this incorrect warning for Vercel Edge runtime.
if (typeof Window === 'undefined' && typeof WorkerGlobalScope === 'undefined' && !isVercelEdgeRuntime) {
console.log(
"Warning: this distribution of Ably is intended for browsers. On nodejs, please use the 'ably' package on npm",
);
Expand Down

0 comments on commit d0a43d1

Please sign in to comment.