ts-invariant
Advanced tools
Comparing version 0.3.3 to 0.4.0
@@ -12,4 +12,4 @@ /// <reference types="node" /> | ||
} | ||
declare const processStub: NodeJS.Process; | ||
declare let processStub: NodeJS.Process; | ||
export { processStub as process }; | ||
export default invariant; |
@@ -47,3 +47,22 @@ import { __extends } from 'tslib'; | ||
// import this process stub to avoid errors evaluating process.env.NODE_ENV. | ||
var processStub = typeof process === "object" ? process : { env: {} }; | ||
// However, because most ESM-to-CJS compilers will rewrite the process import | ||
// as tsInvariant.process, which prevents proper replacement by minifiers, we | ||
// also attempt to define the stub globally when it is not already defined. | ||
var processStub = { env: {} }; | ||
if (typeof process === "object") { | ||
processStub = process; | ||
} | ||
else | ||
try { | ||
// Using Function to evaluate this assignment in global scope also escapes | ||
// the strict mode of the current module, thereby allowing the assignment. | ||
// Inspired by https://github.com/facebook/regenerator/pull/369. | ||
Function("stub", "process = stub")(processStub); | ||
} | ||
catch (atLeastWeTried) { | ||
// The assignment can fail if a Content Security Policy heavy-handedly | ||
// forbids Function usage. In those environments, developers should take | ||
// extra care to replace process.env.NODE_ENV in their production builds, | ||
// or define an appropriate global.process polyfill. | ||
} | ||
var invariant$1 = invariant; | ||
@@ -50,0 +69,0 @@ |
@@ -51,3 +51,22 @@ 'use strict'; | ||
// import this process stub to avoid errors evaluating process.env.NODE_ENV. | ||
var processStub = typeof process === "object" ? process : { env: {} }; | ||
// However, because most ESM-to-CJS compilers will rewrite the process import | ||
// as tsInvariant.process, which prevents proper replacement by minifiers, we | ||
// also attempt to define the stub globally when it is not already defined. | ||
exports.process = { env: {} }; | ||
if (typeof process === "object") { | ||
exports.process = process; | ||
} | ||
else | ||
try { | ||
// Using Function to evaluate this assignment in global scope also escapes | ||
// the strict mode of the current module, thereby allowing the assignment. | ||
// Inspired by https://github.com/facebook/regenerator/pull/369. | ||
Function("stub", "process = stub")(exports.process); | ||
} | ||
catch (atLeastWeTried) { | ||
// The assignment can fail if a Content Security Policy heavy-handedly | ||
// forbids Function usage. In those environments, developers should take | ||
// extra care to replace process.env.NODE_ENV in their production builds, | ||
// or define an appropriate global.process polyfill. | ||
} | ||
var invariant$1 = invariant; | ||
@@ -58,2 +77,1 @@ | ||
exports.invariant = invariant; | ||
exports.process = processStub; |
{ | ||
"name": "ts-invariant", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"author": "Ben Newman <ben@apollographql.com>", | ||
@@ -40,3 +40,3 @@ "description": "TypeScript implementation of invariant(condition, message)", | ||
}, | ||
"gitHead": "d5765c576b70d6de0ab9539abba371c185e64f36" | ||
"gitHead": "2da3ab3d9eada0f37a6ed4a53c1932d651fb4014" | ||
} |
Sorry, the diff of this file is not supported yet
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
10868
203
2