vercel / vercel/examples

Turborepo + Hono - Relative imports require explicit extensions with node16/nodenext

Open
#1,188 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.2k
Forks
1.8k
Avg merge
3d 12h
Merged PRs (30d)
6

Description

Trying the template of Turborepo + Hono with the simple setup as it is I can deploy normally.
But if I extend the example to a more real world scenario, for example, introducing more folders and other packages from the monorepo like:

// hono - src/index.ts
import { ... } from "@acme/..."; // from a package in the monorepo
import { auth } from "./lib/auth"; // from a relative file for organization purposes

When trying the build I'm getting this kind of errors.

Error: ../../packages/api/src/index.ts(2,35): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './orpc.js'?
../../packages/api/src/index.ts(3,32): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './root.js'?
../../packages/api/src/index.ts(4,27): error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './root.js'?

How can I configure the tsconfig.json or something to make it work?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Turborepo + Hono template, its tsconfig.json files, and the imports in src/index.ts and packages/api/src/index.ts. Reproduce the node16/nodenext build error and determine the configuration or import convention needed; done means the documented example builds with the shown relative imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.