UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

49 lines (47 loc) • 1.58 kB
const FORBIDDEN_EXPO_PATTERN_SOURCES = [ "^expo$", "^expo-.*", "^@expo/.*", "^expo-modules-core$", "^@expo/config-plugins$", "^babel-preset-expo$" ]; const FORBIDDEN_EXPO_PATTERNS = FORBIDDEN_EXPO_PATTERN_SOURCES.map((source) => new RegExp(source)); function isForbiddenExpoSpecifier(specifier) { const bare = specifier.split("?")[0].split("#")[0]; const name = bare.startsWith("@") ? bare.split("/").slice(0, 2).join("/") : bare.split("/")[0]; return FORBIDDEN_EXPO_PATTERNS.some((pattern) => pattern.test(name)); } function findForbiddenDependencies(resolved) { const names = Array.isArray(resolved) ? resolved : Object.keys(resolved); return [...new Set(names.filter(isForbiddenExpoSpecifier))].sort(); } function auditUnpackedManifest(manifest) { return findForbiddenDependencies({ ...manifest.dependencies, ...manifest.devDependencies, ...manifest.peerDependencies }); } function createResolutionRecorder() { const events = []; return { record(specifier, importer) { if (isForbiddenExpoSpecifier(specifier)) { throw new Error(`[one] forbidden expo specifier resolves: "${specifier}"`); } if (specifier.includes("/expo/") || specifier.includes("expo-modules-core")) { throw new Error(`[one] forbidden expo source path resolves: "${specifier}"`); } events.push({ specifier, importer }); }, events() { return [...events]; } }; } export { FORBIDDEN_EXPO_PATTERN_SOURCES, auditUnpackedManifest, createResolutionRecorder, findForbiddenDependencies, isForbiddenExpoSpecifier }; //# sourceMappingURL=closure.mjs.map