From 43f6ca648b828ae54d8be4788ba8983de3d1bd3a Mon Sep 17 00:00:00 2001 From: Steven Sherry Date: Mon, 4 Mar 2024 16:37:56 -0600 Subject: [PATCH 1/2] fix(cli): Attempt to verify non-cjs modules exist if cjs resolution fails --- cli/src/util/node.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cli/src/util/node.ts b/cli/src/util/node.ts index 1fb84678fa..223f48e607 100644 --- a/cli/src/util/node.ts +++ b/cli/src/util/node.ts @@ -56,6 +56,10 @@ export function resolveNode( try { return require.resolve(pathSegments.join('/'), { paths: [root] }); } catch (e) { + const path = [root, 'node_modules', ...pathSegments].join('/'); + if (require('fs').existsSync(path)) { + return path; + } return null; } } From ba3c30294c42c0383d9a556be012c8eb43f4e6df Mon Sep 17 00:00:00 2001 From: Steven Sherry Date: Mon, 4 Mar 2024 16:42:29 -0600 Subject: [PATCH 2/2] chore: Use ESM import --- cli/src/util/node.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/src/util/node.ts b/cli/src/util/node.ts index 223f48e607..914ca7029c 100644 --- a/cli/src/util/node.ts +++ b/cli/src/util/node.ts @@ -1,4 +1,5 @@ import { readFileSync } from '@ionic/utils-fs'; +import { existsSync } from 'fs'; import { resolve } from 'path'; import type typescript from 'typescript'; @@ -57,7 +58,7 @@ export function resolveNode( return require.resolve(pathSegments.join('/'), { paths: [root] }); } catch (e) { const path = [root, 'node_modules', ...pathSegments].join('/'); - if (require('fs').existsSync(path)) { + if (existsSync(path)) { return path; } return null;