Skip to content

.tsx files cannot be resolved when they are imported from the index.ts in the root of the project #275

@igorjacauna

Description

@igorjacauna

Environment

node@22
c12@3.3.0

Reproduction

First of all, sorry for the title. This is just the scenario where I found the issue in my project, but I’m not sure if the structure itself is what’s actually causing it.

I created a Stackblitz with almost the same structure as my project: https://stackblitz.com/edit/vitejs-vite-sb9kfluw?file=package.json

Let me explain.

I have an index.ts in the root of the project that imports several files, including .tsx files. For some reason, when I try to use changelogen, it throws an error saying the .tsx files cannot be resolved.

At first, I thought it was a jiti issue. But even when I used the same jiti version as in another working project, the problem wasn’t resolved. So I started checking dependency differences and found the issue was with c12.

In the Stackblitz project there is a override with c12@3.3.0 (try running npm run bump to see it).

If we downgrade c12 to 3.2.0 and run npm run bump, the issue goes away (just ignore the “git not found” error 😄).

Describe the bug

.tsx files cannot be resolved when they are imported from the index.ts in the root of the project

Additional context

https://stackblitz.com/edit/vitejs-vite-sb9kfluw?file=tsconfig.json,src%2FApp.tsx,package.json,index.ts&terminal=dev

Logs

at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at jitiResolve (node_modules/jiti/dist/jiti.cjs:1:190064)
    at jitiRequire (node_modules/jiti/dist/jiti.cjs:1:192130)
    at import (node_modules/jiti/dist/jiti.cjs:1:202951)
    at src/routes.ts:3:53
    at eval_evalModule (node_modules/jiti/dist/jiti.cjs:1:199388)
    at jitiRequire (node_modules/jiti/dist/jiti.cjs:1:193075)
    at import (node_modules/jiti/dist/jiti.cjs:1:202951)
    at index.ts:2:44

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions