Comparing version 1.2.0 to 1.2.1
# esm-env | ||
## 1.2.1 | ||
### Patch Changes | ||
- fix: address error in non-Vite bundlers when no conditions set ([#13](https://github.com/benmccann/esm-env/pull/13)) | ||
## 1.2.0 | ||
@@ -4,0 +10,0 @@ |
@@ -1,13 +0,6 @@ | ||
if (!import.meta.env) { | ||
// changes to import.meta only apply to this file | ||
// we have to do this to be able to directly access import.meta.env.DEV | ||
// bunlder defines such as Vite will only replace import.meta.env.DEV and not import.meta.env?.DEV | ||
// we also can't do import.meta.env && import.meta.env.DEV because that breaks tree-shaking | ||
import.meta.env = {}; | ||
const node_env = globalThis.process?.env?.NODE_ENV; | ||
if (!node_env) { | ||
console.warn('If bundling, conditions should include development or production. If not bundling, conditions or NODE_ENV should include development or production. See https://www.npmjs.com/package/esm-env for tips on setting conditions in popular bundlers and runtimes.'); | ||
} | ||
// import.meta.env.DEV can be replaced by a bundler define such as Vite does and the rest of this | ||
// expression can then be condensed down to a single boolean by the bundler if such a define is used | ||
// Otherwise, if there were no conditions defined and the build time replacement of import.meta.env.DEV | ||
// didn't happen then fallback to runtime check of process.env.NODE_ENV | ||
export default !!(import.meta.env.DEV ?? process?.env?.NODE_ENV !== 'production'); | ||
export default node_env && !node_env.toLowerCase().includes('prod'); |
{ | ||
"name": "esm-env", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"repository": { | ||
@@ -12,3 +12,2 @@ "type": "git", | ||
"type": "module", | ||
"sideEffects": false, | ||
"exports": { | ||
@@ -21,3 +20,5 @@ ".": { | ||
"browser": "./true.js", | ||
"default": "./false.js" | ||
"development": "./false.js", | ||
"production": "./false.js", | ||
"default": "./browser-fallback.js" | ||
}, | ||
@@ -24,0 +25,0 @@ "./development": { |
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
10
3939
14