Skip to content

Commit ede368c

Browse files
grdsdevclaude
andauthored
fix: add Node 18 deprecation notice (#1506)
* fix: add Node 18 deprecation notice * run pnpm install * fix: improve Node 18 deprecation warning and fix import typo - Add browser environment check to only show Node.js deprecation warning in Node.js - Fix typo in types import path 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: correct import typo and improve code formatting - Fix typo in types import path - Improve formatting of Node.js 18 deprecation warning condition 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * 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 * add engines field in package.json * remove engine * revert pnpm-lock.yaml * revert package-lock.json --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5b1118d commit ede368c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/index.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,31 @@ export const createClient = <
3939
): SupabaseClient<Database, SchemaName, Schema> => {
4040
return new SupabaseClient<Database, SchemaName, Schema>(supabaseUrl, supabaseKey, options)
4141
}
42+
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()) {
64+
console.warn(
65+
`⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. ` +
66+
`Please upgrade to Node.js 20 or later. ` +
67+
`For more information, visit: https://github.com/orgs/supabase/discussions/37217`
68+
)
69+
}

0 commit comments

Comments
 (0)