Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Improve debugging guide to explain about importing submodules (#21403)

Rodrigo Mansuelia84de3437e26
diff --git a/apps/docs/content/guides/functions/debugging.mdx b/apps/docs/content/guides/functions/debugging.mdx
index c9bccc5c505..4ac083221b9 100644
--- a/apps/docs/content/guides/functions/debugging.mdx
+++ b/apps/docs/content/guides/functions/debugging.mdx
@@ -148,6 +148,12 @@ The source code of a function is subject to size limits:
### Analyze dependencies
+When analyzing dependencies for your Supabase Edge Functions, it's essential to review both Deno and NPM dependencies to ensure optimal performance and resource utilization.
+By selectively importing only the required submodules, you can effectively reduce the size of your function's dependencies and optimize its performance.
+Before finalizing your imports, ensure to review both Deno and NPM dependencies, checking for any unnecessary or redundant dependencies that can be removed. Additionally, check for outdated dependencies and update to the latest versions if possible.
+
+#### Deno Dependencies
+
Run `deno info`, providing the path to your input map if you use one.
Review the dependencies listed in the output. Pay attention to any significantly large dependencies, as they can contribute to increased bundle size and potential boot time issues.
Examine if there are any unnecessary or redundant dependencies that can be removed. Check for outdated dependencies and update to the latest versions if possible.
@@ -156,6 +162,16 @@ Examine if there are any unnecessary or redundant dependencies that can be remov
deno info --import-map=/path/to/import_map.json /path/to/function/index.ts
```
+#### NPM Dependencies
+
+Additionally, if you utilize NPM modules in your Edge Functions, it's crucial to be mindful of their size and impact on the overall bundle size. While importing NPM modules, consider using the notation `import { submodule } from 'npm:package/submodule'` to selectively import specific submodules rather than importing the entire package. This approach can help minimize unnecessary overhead and streamline the execution of your function.
+
+For example, if you only need the `Sheets` submodule from the `googleapis` package, you can import it like this:
+
+```typescript
+import { Sheets } from 'npm:@googleapis/sheets'
+```
+
## Limitations
- Outgoing connections to ports `25`, `465`, and `587` are not allowed.