Skip to content

Commit ec3c428

Browse files
committed
feat: add Node.js <= 18 deprecation warning
- Add deprecation warning for Node.js versions 18 and below - Extract shouldShowDeprecationWarning function with robust version parsing - Parse major version number from process.version using regex - Handle edge cases: null version, malformed strings, browser environments - Display informative warning message directing users to upgrade to Node.js 20+ - Include link to GitHub discussion for more information
1 parent eadbaf9 commit ec3c428

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/index.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,29 @@ export const createClient = <
4040
return new SupabaseClient<Database, SchemaName, Schema>(supabaseUrl, supabaseKey, options)
4141
}
4242

43-
// Check for Node.js 18 deprecation
44-
if (
45-
typeof window === 'undefined' &&
46-
typeof process !== 'undefined' &&
47-
process.version &&
48-
process.version.startsWith('v18')
49-
) {
43+
// Check for Node.js <= 18 deprecation
44+
function shouldShowDeprecationWarning(): boolean {
45+
if (
46+
typeof window !== 'undefined' ||
47+
typeof process === 'undefined' ||
48+
process.version === undefined ||
49+
process.version === null
50+
) {
51+
return false
52+
}
53+
54+
const versionMatch = process.version.match(/^v(\d+)\./)
55+
if (!versionMatch) {
56+
return false
57+
}
58+
59+
const majorVersion = parseInt(versionMatch[1], 10)
60+
return majorVersion <= 18
61+
}
62+
63+
if (shouldShowDeprecationWarning()) {
5064
console.warn(
51-
`⚠️ Node.js 18 is deprecated and will no longer be supported in future versions of @supabase/supabase-js. ` +
65+
`⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. ` +
5266
`Please upgrade to Node.js 20 or later. ` +
5367
`For more information, visit: https://github.com/orgs/supabase/discussions/37217`
5468
)

0 commit comments

Comments
 (0)