Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esm-env

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esm-env - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

browser-fallback.js

6

CHANGELOG.md
# 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 @@

15

dev-fallback.js

@@ -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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc