Comparing version 7.3.1 to 7.4.0
@@ -0,1 +1,4 @@ | ||
## 7.4.0 (21/08/2023) | ||
* Do not use `process.env` by default in non-Node.js environments (#155) | ||
## 7.3.1 (24/04/2023) | ||
@@ -2,0 +5,0 @@ * Fix parsing even floating point numbers (#166) |
@@ -55,2 +55,3 @@ 'use strict' | ||
module.exports = from(process.env) | ||
/* istanbul ignore next */ | ||
module.exports = from(typeof process === 'undefined' ? {} : process.env) |
{ | ||
"name": "env-var", | ||
"version": "7.3.1", | ||
"version": "7.4.0", | ||
"description": "Verification, sanitization, and type coercion for environment variables in Node.js", | ||
@@ -5,0 +5,0 @@ "main": "env-var.js", |
@@ -51,3 +51,3 @@ # env-var | ||
### Javascript example | ||
### Node.js Javascript example | ||
@@ -73,3 +73,3 @@ ```js | ||
### TypeScript example | ||
### Node.js TypeScript example | ||
@@ -85,2 +85,17 @@ ```ts | ||
### WebApp Example | ||
When using environment variables in a web application, usually your tooling | ||
such as `vite` imposes special conventions and doesn't expose `process.env`. | ||
Use `from` function to workaround this, and create an `env` object like so: | ||
```ts | ||
import { from } from 'env-var' | ||
const env = from({ | ||
BASE_URL: import.meta.env.BASE_URL, | ||
VITE_CUSTOM_VARIABLE: import.meta.env.CUSTOM_VARIABLE | ||
}) | ||
``` | ||
For more examples, refer to the `/example` directory and [EXAMPLE.md](EXAMPLE.md). A summary of the examples available in `/example` is written in the ['Other examples' section of EXAMPLE.md](EXAMPLE.md#other-examples). | ||
@@ -87,0 +102,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41410
695
170