Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function(path: string, options: ResolveOptions) {
const ext = extname(path);
if (
ext === '.css' ||
ext === '.scss' ||
ext === '.sass' ||
ext === '.less' ||
ext === '.styl'
) {
return require.resolve('identity-obj-proxy');
}
// Try to use the defaultResolver
try {
return defaultResolver(path, options);
} catch (e) {
// Fallback to using typescript
compilerSetup = compilerSetup || getCompilerSetup(options.rootDir);
const { compilerOptions, host } = compilerSetup;
return ts.resolveModuleName(path, options.basedir, compilerOptions, host)
.resolvedModule.resolvedFileName;
}
};