Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECO-4742] Remove warning about using web bundle in Vercel Edge runtime #1740

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading