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) (#7313)
  • Loading branch information
Steven0351 authored Mar 6, 2024
1 parent 25cbdb0 commit 28e7f08
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 28e7f08

Please sign in to comment.