How to improve Deno DX for Supabase Edge Functions? #8779
-
Sorry for the language, but it's a lot of developer experience friction, really. When I use cloud functions from other cloud providers I can usually get up and running in 5 minutes and at the same time my VSCode won't be screaming errors because my functions are simply written in JavaScript or TypeScript. Deno is a different beast, it's a separate runtime with a separate linter and separate development environment configurations. A total pain in the ass to deal with. Look at it, TypeScript IntelliSense doesn't even work out of the box on a project that uses ESLint. I've tried installing deno, installing the Deno VSCode extension, creating a deno.config file, configuring the Deno VSCode extension's deno.config and deno.path properties. It's just a mess. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 17 replies
This comment has been hidden.
This comment has been hidden.
-
Had the same issue, and made it work as follows:
Hope it helps. |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
Here is an end to end example of configuring VSCode to work with Deno - https://youtu.be/rzglqRdZUQE?t=144 and end to end quickstart here - https://supabase.com/docs/guides/functions/quickstart If you are using Edge functions along with other code, checkout how to configure Deno with VSCode workspaces here - https://www.youtube.com/watch?v=lFhU3L8VoSQ |
Beta Was this translation helpful? Give feedback.
-
The steps are pretty simple actually: Install Deno CLI from this page Make sure deno is in your PATH variables on windows. To test this, in a new terminal, type "deno" and if it says command not found you've got an issue. Google on how to fix this. Install Deno Vscode Extension from this page Create a And put the following inside of it:
For example, my directory structure looks like this:
In your functions, when adding new libraries, you might notice an error: As it mentions, it is because the library is not cached. After caching it: You can see that all the vscode goodies start to work. I hope these help. |
Beta Was this translation helpful? Give feedback.
-
Using Deno for Edge functions has been the worst part of our DX with Supabase so far. The docs don't go much beyond a simple, 1 file function index.ts file with a few external deps because as soon as you get into trying to import local files, deps from multiple CDNs, more custom import_map.json setups, things get very hard to scale, run for development and deploy. Even testing locally with I wish they would've opted for the industry standard of Node and later added Deno for those who want to be at the cutting edge. |
Beta Was this translation helpful? Give feedback.
-
I faced similar issues. I ended up having 2 import files, one for local development and one for production. Supabase will automatically pick import_map.json from functions folder and we manually set local_import_map.json in the vscode settings. Basically your local import can use npm: packages and will be perfectly typed. But on prod, supabase needs pure esm files from services like esm.sh. Not the best DX. Haven't been able how to have pretty absolute urls like @utils as those do not work when deployed to supabase but work in deno locally. I can't believe it would be too difficult to sync secrets across big providers like GCP and AWS and allow the flows supported by those cloud functions with the CLI and then allow any language to be used (specially since there are many client libraries making this even smoother). |
Beta Was this translation helpful? Give feedback.
Had the same issue, and made it work as follows:
denoland.vscode-deno
extension"deno.enablePaths": ["supabase/functions"]
to.vscode/settings.json
"include": ["**/*.ts"]
totsconfig.json
Hope it helps.