feat: inject environment variables from .env files into edge functions locally#5620
Conversation
📊 Benchmark resultsComparing with f30d409 Package size: 302 MB(no change) |
| * @param {Record<string, { sources: string[], value: string}>} env | ||
| * @return {void} | ||
| */ | ||
| export const injectEnvVariables = (env) => { |
There was a problem hiding this comment.
I made this function to only inject variables into process.env and split out all the dotenv stuff into the function above.
|
|
||
| await injectEnvVariables({ devConfig, env, site }) | ||
| env = await addDotEnvVariables({ devConfig, env, site }) | ||
| injectEnvVariables(env) |
There was a problem hiding this comment.
addDotEnvVariables now mutates env here and adds the variables from the dot-env files to it, so that later one we can use them in edge-functions. Previously dotenv variables were only added to process.env directly.
| @@ -1,4 +1,4 @@ | |||
| // Handlers are meant to be async outside tests | |||
| const { platform } = require('os') | |||
There was a problem hiding this comment.
I couldn't figure out what this comment means or where it applies to :D
|
@danez - I'm not sure what part of this PR you want me to review. I took a look through and couldn't identify any changes that will impact what's shown in the cli docs at https://deploy-preview-5620--cli.netlify.app/ Could you point me to the part of this PR that needs my review? I do see that docs.netlify.com documents some limitations around this behavior that will need to be updated/removed (on the Environment variables and functions page and the Edge Functions limits page)- I can open a PR to get the ball rolling on those changes. |
Sorry, i didn't mean to ask for a review. I just wanted to let you know that this is something that is changing which we might want to document :) |
eduardoboucas
left a comment
There was a problem hiding this comment.
Nice! Left a couple of comments but nothing blocking.
3494edb to
252a386
Compare
Summary
This allows any environment variables that are coming from dot-env files (
.env) to be accessed in edge functions.Similar to what is described here: https://docs.netlify.com/configure-builds/environment-variables/#build-locally
For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)