Support for import.meta.env or $env/dynamic/private in Netlify background functions.
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 32/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- node.js, typescript
调研方向
首先,使用 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
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
netlify/cli 的其他 Issue
-
db-status.test fails if the database is disabled可能已有人在做 @paulleephp 于 8 天前认领。 未关闭type: bug
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
`client-ip` is not an IP address when `x-forwarded-for` holds a list or a port可能已有人在做 @Dev-next-gen 于 28 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
`netlify dev` with `--cwd` from outside the project: every function 500s with "module is not defined in ES module scope" (`detectZisiBuilder` passes a string to `readPackageUp`)可能已有人在做 @bsplatt92 于 69 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
area: command: deploy area: docs type: feature
难度 1/5 1 小时以内 新手友好度 88/100
netlify/cli#1984 · 19 条评论 · 3 个 reaction ·
维护者通常 1 天内回复
-
type: bug
难度 4/5 3-5 天 新手友好度 20/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
Merit-Systems/x402scan#1312 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Native Web
难度 1/5 1 小时以内 新手友好度 80/100
digitalfabrik/integreat-app#4517 ·
维护者通常 2 天内回复
-
TLS guide repeats certs/ in the certificate directory可能已有人在做 @maheshrijal 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
prometheus/docs#3156 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
medusajs/dtc-starter#90 ·
维护者通常 1 天内回复