UNPKG

import-conductor

Version:

Automatically organize your Typescript import statements

23 lines 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isThirdParty = void 0; const config_1 = require("../config"); function breakdownPath(path) { return path.split('/').map((_, i, arr) => arr.slice(0, i + 1).join('/')); } function isThirdParty(libName) { let isThirdPartyModule = false; const { thirdPartyDependencies, userLibPrefixes } = config_1.getConfig(); try { isThirdPartyModule = require.resolve(libName).indexOf('/') < 0; } catch (_a) { console.log(); console.warn(`⚡ You are importing ${libName} but it is not installed.`); console.warn(`⚡ Trying to figure out import category based on library name: ${libName}`); isThirdPartyModule = !libName.startsWith('.') && !userLibPrefixes.some((prefix) => libName.startsWith(prefix)); } return isThirdPartyModule || breakdownPath(libName).some((subPath) => thirdPartyDependencies.has(subPath)); } exports.isThirdParty = isThirdParty; //# sourceMappingURL=is-third-party.js.map