UNPKG

whodis-react

Version:

React hooks and components for secure, best practices authentication in seconds

22 lines 947 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasPackageAccessible = void 0; /** * detects whether a package can be imported in a universal, and safe, way * * note: * - carefully prevents react-native's metro bundler from throwing an error while proactively fetching all dependencies * - it specifically requires the import to be within a try-catch to not throw its own error * - ref: https://github.com/react-native-community/discussions-and-proposals/issues/120 */ const hasPackageAccessible = (packageName) => { try { require(`${packageName}`); // note: we cast it into a string to avoid: https://stackoverflow.com/questions/42908116/webpack-critical-dependency-the-request-of-a-dependency-is-an-expression return true; } catch (_a) { return false; } }; exports.hasPackageAccessible = hasPackageAccessible; //# sourceMappingURL=hasPackageAvailable.js.map