-
Notifications
You must be signed in to change notification settings - Fork 321
Description
Description:
When creating a new Edge Function using the Supabase CLI, the generated template code contains Deno linting errors out of the box.
Steps to reproduce:
- Clear Deno cache:
rm -rf ~/.cache/deno(orrm -rf ~/Library/Caches/denoon macOS) or similar to clear your local deno cache. - Run
supabase functions new test-function - Open the generated
supabase/functions/test-function/index.tsfile in VSCode with the Deno extension enabled - Observe linting errors on line 6
Expected behavior:
The generated code should be free of linting-errors and follow Deno best practices without requiring manual fixes.
Actual behavior:
The generated template produces Deno IDE error and Deno linting warnings on line 6:
import 'jsr:@supabase/functions-js/edge-runtime.d.ts'Errors shown in IDE:
JSR package "@supabase/functions-js" is not installed or doesn't exist.(deno: not-installed-jsr)Inline 'npm:', 'jsr:' or 'https:' dependency not allowed - Add it as a dependency in a deno.json or package.json instead and reference it here via its bare specifier(deno-lint: no-import-prefix)Missing version in specifier - Add a version requirement after the package name(deno-lint: no-unversioned-import)
Note: Seems the 1st error sometimes goes away after a couple of minutes / seconds, to have it re-appear clear deno cache and restart/reload VSCode.
Suggested fix:
Error 2 and 3:
Add linting ignore comment:
// deno-lint-ignore no-import-prefix no-unversioned-importFor the 1st error to disappear you will need to install the package manually, or run the function locally with deno: deno run --allow-net --allow-env supabase/functions/test-function/index.ts to have it cached.
I guess for the devs of Supabase this have not been an issue since they probably have the package already installed.
Suggested fix:
Error 1:
Not sure the best way, but can be "fixed" this way (also fixes error 2 and 3):
The CLI should generate a deno.json file alongside the function with proper import mappings:
{
"imports": {
"@supabase/functions-js": "jsr:@supabase/functions-js@2"
}
}Then update the import to use the bare specifier:
import '@supabase/functions-js/edge-runtime.d.ts'But that generates a large lock file (100+ packages) since @supabase/functions-js has a transitive dependency on openai@^4.52.5
Environment:
- Supabase CLI version: 2.54.11
- Deno version: 2.5.6 (stable)
- OS: macOS (Darwin 23.6.0, aarch64)
- IDE: VSCode Version: 1.105.1