How to use the jest-resolve/build/defaultResolver function in jest-resolve

To help you get started, we’ve selected a few jest-resolve examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nrwl / nx / packages / jest / plugins / resolver.ts View on Github external
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;
  }
};

jest-resolve

MIT
Latest version published 1 year ago

Package Health Score

88 / 100
Full package analysis

Similar packages