diff --git a/src/jiti.ts b/src/jiti.ts index 5b98d7d3..a28d9915 100644 --- a/src/jiti.ts +++ b/src/jiti.ts @@ -167,9 +167,6 @@ export default function createJITI( } // Try native require resolve - if ((opts.extensions as string[]).includes(extname(id))) { - return nativeRequire.resolve(id, options); - } try { return nativeRequire.resolve(id, options); } catch (error) { @@ -178,6 +175,8 @@ export default function createJITI( for (const ext of _additionalExts) { resolved = tryResolve(id + ext, options) || + // TODO: Only do this for imports within a typescript parent module + tryResolve(id.replace(/\.(c|m)?j(sx?)$/, ".$1t$2"), options) || tryResolve(id + "/index" + ext, options); if (resolved) { return resolved; diff --git a/test/__snapshots__/fixtures.test.ts.snap b/test/__snapshots__/fixtures.test.ts.snap index 69db8b4c..052d2771 100644 --- a/test/__snapshots__/fixtures.test.ts.snap +++ b/test/__snapshots__/fixtures.test.ts.snap @@ -1,4 +1,4 @@ -// Vitest Snapshot v1 +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`fixtures > async > stdout 1`] = `"works"`; diff --git a/test/fixtures/typescript/index.ts b/test/fixtures/typescript/index.ts index b3388b72..2565bd3c 100644 --- a/test/fixtures/typescript/index.ts +++ b/test/fixtures/typescript/index.ts @@ -1,6 +1,6 @@ import test, { FeedService } from "./test"; import Clazz from "./decorators"; -import { test as satisfiesTest } from "./satisfies"; +import { test as satisfiesTest } from "./satisfies.js"; export type { Test } from "./types";