Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function tryNodeResolver(importRequest, file, config) {
return nodeResolver.resolve(
importRequest,
file,
// we use Object.assign so that this file is compatible with slightly older
// versions of node.js used by IDEs (eg. resolvers are run in the Electron
// process in Atom)
Object.assign({}, config, {
extensions: ['.js', '.json', '.ts', '.tsx'],
isFile,
})
);
}
function checkImages(source, file, config, platform=null) {
var splitSource = source.split('.');
var noSuffix = splitSource.slice(0, -1).join('.');
var suffix = '.' + splitSource.slice(-1);
var platformPart = (platform === null ? '' : `.${platform}`);
for(sizeSuffix of ['', ...sizeSuffixes]) {
const pathToTry = `${noSuffix}${sizeSuffix}${platformPart}${suffix}`;
const image = nodeResolve(pathToTry, file, config);
if(image.found) {
return image
}
}
return {found: false};
}
function resolvePlatform(source, file, config, platform) {
if (isImage(source)) {
return checkImages(source, file, config, platform);
}
else {
return nodeResolve(source + '.' + platform, file, config);
}
}