nitro
nitro copied to clipboard
feat(runtime-config): export `applyEnv` and `getEnv` from nitropack
๐ Linked issue
โ Type of change
- [ ] ๐ Documentation (updates to the documentation, readme, or JSdoc annotations)
- [ ] ๐ Bug fix (a non-breaking change that fixes an issue)
- [ ] ๐ Enhancement (improving an existing functionality like performance)
- [x] โจ New feature (a non-breaking change that adds functionality)
- [ ] ๐งน Chore (updates to the build process or auxiliary tools and libraries)
- [ ] โ ๏ธ Breaking change (fix or feature that would cause existing functionality to change)
๐ Description
This adds applyEnv
and getEnv
as exports, as well as allowing them to operate on a custom env
object instead of reading from process.env
.
This would be a useful feature for frameworks to provide more accurate runtimeConfig
at the build time. For example, we already inline these utils in https://github.com/nuxt/test-utils/pull/655 and would need to do the same for https://github.com/nuxt/nuxt/issues/24224 and https://github.com/nuxt/nuxt/issues/26960.
Of course, that would be fine, but it would nicer to be able to simulate the runtime behaviour of Nitro with these utils, as suggested in https://github.com/nuxt/nuxt/issues/24224#issuecomment-1805495557.
I've included them in the core nitropack
export but I would almost prefer nitropack/utils
, perhaps, to allow space for other similar utilities?
๐ Checklist
- [ ] I have linked an issue or discussion.
- [ ] I have updated the documentation accordingly.