one
Version:
One is a React framework for web, iOS, and Android apps.
53 lines (51 loc) • 1.61 kB
JavaScript
var FORBIDDEN_EXPO_PATTERN_SOURCES = [
"^expo$",
"^expo-.*",
"^@expo/.*",
"^expo-modules-core$",
"^@expo/config-plugins$",
"^babel-preset-expo$"
];
var FORBIDDEN_EXPO_PATTERNS = FORBIDDEN_EXPO_PATTERN_SOURCES.map(function(source) {
return new RegExp(source);
});
function isForbiddenExpoSpecifier(specifier) {
var bare = specifier.split("?")[0].split("#")[0];
var name = bare.startsWith("@") ? bare.split("/").slice(0, 2).join("/") : bare.split("/")[0];
return FORBIDDEN_EXPO_PATTERNS.some(function(pattern) {
return pattern.test(name);
});
}
function findForbiddenDependencies(resolved) {
var 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() {
var 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.native.js.map