Skip to content

Commit

Permalink
fix(cli): Attempt to verify non-cjs modules exist if cjs resolution f…
Browse files Browse the repository at this point in the history
…ails (#7310)
  • Loading branch information
Steven0351 authored Mar 5, 2024
1 parent 286b694 commit 663e7b3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cli/src/util/node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { readFileSync } from '@ionic/utils-fs';
import { existsSync } from 'fs';
import { resolve } from 'path';
import type typescript from 'typescript';

Expand Down Expand Up @@ -56,6 +57,10 @@ export function resolveNode(
try {
return require.resolve(pathSegments.join('/'), { paths: [root] });
} catch (e) {
const path = [root, 'node_modules', ...pathSegments].join('/');
if (existsSync(path)) {
return path;
}
return null;
}
}

0 comments on commit 663e7b3

Please # to comment.