Local files with Edge Functions?

Importing from local files (i.e. utils.ts)?

Hey @omar2205

This is what I have done with JS

import { myImport } from "./common/functions.js"

export default async (request, context) => {

  /**
   * Stuff here...
   */
  
};

I don’t use TS, but I believe it is much the same.

I did a similar thing, but I keep seeing the utils function in the build logs.

Can you share the logs?

Packaging Edge Functions from netlify/edge-functions directory:
... actual functions 
- utils

I was thinking that maybe there is a way to include files without being treated as functions.

If it is in the edge-functions directory, it is treated as a function. Move utils.ts into another directory e.g.

edge-function
β”œβ”€β”€ common
β”‚   β”œβ”€β”€ auth.js
β”‚   └── utils.ts
β”œβ”€β”€ a-function.ts
└── hello-world.js

and include utils.ts as per previously mentioned.

1 Like