Skip to content

Conversation

@akapug
Copy link
Member

@akapug akapug commented Nov 25, 2025

Ready for review Powered by Pull Request Badge

Summary

When a TypeScript file imports a relative path without an extension (e.g., import { x } from './helper'), Elide now tries resolving with TypeScript extensions before falling back to the default module resolution.

Problem

Currently, multi-file TypeScript projects don't work in Elide because relative imports like ./helper fail to resolve - Elide doesn't try ./helper.ts.

Reproduction:

// main.ts
import { helper } from './helper'
console.log(helper())

// helper.ts
export function helper(): string {
  return 'Hello from helper'
}

Running elide main.ts fails with TypeError: Module not found: './helper'

Solution

Added TypeScript extension resolution in ElideUniversalJsModuleLoader:

  1. When resolving a relative import from a TypeScript source
  2. And the specifier has no extension
  3. Try extensions in order: .ts, .tsx, .mts, .cts, .js, .mjs, .cjs, .jsx
  4. Also try index file resolution (./foo./foo/index.ts)

This matches the behavior of tsc and other TypeScript tooling.

Note

For production apps, bundling with esbuild is still recommended. This enhancement improves DX for simple multi-file scripts.

When a TypeScript file imports a relative path without an extension
(e.g., `import { x } from './helper'`), try resolving with TypeScript
extensions (.ts, .tsx, .mts, .cts) before falling back to the default
module resolution.

This enables multi-file TypeScript projects to work without requiring
explicit extensions in import statements, matching the behavior of tsc
and other TypeScript tooling.

Extensions tried in order: .ts, .tsx, .mts, .cts, .js, .mjs, .cjs, .jsx

Also supports index file resolution (./foo -> ./foo/index.ts).
@akapug akapug requested a review from sgammon as a code owner November 25, 2025 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant