fix test
This commit is contained in:
parent
84690a5e94
commit
ca1ad4d57e
|
|
@ -319,19 +319,18 @@ export function resolveImportSpecifierExtension(resolved: string, isPathMapping:
|
|||
break; // Do not try '' when a more specific extension like '.jsx' matched.
|
||||
}
|
||||
|
||||
if (dirExists(resolved)) {
|
||||
// If we import a package, let Node.js figure out the correct import based on package.json.
|
||||
// Following TypeScript's path mapping logic, index files and package.json are not resolved in ESM.
|
||||
// TypeScript does not interpret package.json for path mappings: https://www.typescriptlang.org/docs/handbook/modules/reference.html#paths-should-not-point-to-monorepo-packages-or-node_modules-packages
|
||||
if (!isPathMapping && fileExists(path.join(resolved, 'package.json')))
|
||||
const shouldNotResolveDirectory = isPathMapping && isESM;
|
||||
|
||||
if (!shouldNotResolveDirectory && dirExists(resolved)) {
|
||||
// If we import a package, let Node.js figure out the correct import based on package.json.
|
||||
if (fileExists(path.join(resolved, 'package.json')))
|
||||
return resolved;
|
||||
|
||||
// Following TypeScript's path mapping logic, index files are still resolved in CommonJS.
|
||||
const shouldNotResolveIndex = isPathMapping && isESM;
|
||||
if (!shouldNotResolveIndex) {
|
||||
const dirImport = path.join(resolved, 'index');
|
||||
return resolveImportSpecifierExtension(dirImport, isPathMapping, isESM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fileExists(resolved: string) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue