Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Support for import.meta.env or $env/dynamic/private in Netlify background functions.

未关闭
#5,286 17 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
32/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
领域
cli, cloud

调研方向

首先,使用 issue 中的配置和 netlify-cli 版本,通过导入 $env/dynamic/private 或 $env/dynamic/public 的 Netlify background function 重现该故障。跟踪 CLI 如何打包 background functions 并提供环境变量。当受支持的导入路径能够解析,并且预期的环境值可在已部署的 background functions 中使用,同时覆盖报告的案例时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

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 
主要语言
TypeScript
星标
1.9k
派生
481
平均合并
1 天 11 小时
30 天内合并 PR
74

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

netlify/cli 的其他 Issue

查看 netlify/cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。