Support for import.meta.env or $env/dynamic/private in Netlify background functions.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 474
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 53
Description
Describe the bug
SvelteKit uses a wrapper around import.meta.env ($env/dynamic/private, ...see all here) to expose environment variables. When deploying code to Netlify background functions, these configuration parameters are not visible. I find myself having to write code such as:
let db_url = process.env.DB_URL ?? import.meta.env.DB_URL;
Is support for import.meta.env or $env/dynamic/private on the roadmap?
Similarly, when I try to use SvelteKit's $env/dynamic/public, I get the following error:
[ERROR] Could not resolve "$env/dynamic/public"
docker-web-app-1 |
docker-web-app-1 | src/lib/env/env_clientside.ts:1:20:
docker-web-app-1 | 1 │ import { env } from '$env/dynamic/public';
docker-web-app-1 | ╵ ~~~~~~~~~~~~~~~~~~~~~
docker-web-app-1 |
docker-web-app-1 | You can mark the path "$env/dynamic/public" as external to exclude it from the bundle, which will remove this error.
Steps to reproduce
Import $env/dynamic/private or any of its related variants in a background function.
Configuration
No response
Environment
System:
OS: Linux 5.15 KDE neon 5.26 5.26
CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
Memory: 7.27 GB / 15.34 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 16.18.0 - ~/apps/node-v16.18.0-linux-x64/bin/node
npm: 8.19.2 - ~/apps/node-v16.18.0-linux-x64/bin/npm
npmPackages:
netlify-cli: ^12.0.11 => 12.2.7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with a Netlify background function that imports $env/dynamic/private or $env/dynamic/public, using the configuration and netlify-cli version in the issue. Trace how the CLI bundles background functions and supplies environment variables. Done means the supported import paths resolve and the expected environment values are available in deployed background functions, with coverage for the reported cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- cli, cloud
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100