-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
Node 22
Jiti 2
Reproduction
https://codesandbox.io/p/devbox/d2pgh5
Describe the bug
I am trying to import a typescript file using jiti that uses createRequire
. This file is importing another file using the createRequire
func. However, this required file is not processed through jiti.
Firstly the createRequire call fails if no extension is provided.
Secondly, if extension is provided, the typescript syntax in it is not recognized.
The debug logs show this file never hits jiti.
How can I ensure jiti processes the files required using createRequire
Additional context
No response
Logs
[jiti] [init] version: 2.4.2 module-cache: true fs-cache: true interop-defaults: true
[jiti] [cache] [hit] ./test.ts ~> /tmp/jiti/workspace-test.4a7478dd.mjs
[jiti] [transpile] [esm] ./test.ts (0.849ms)
node:internal/modules/cjs/loader:1143
const err = new Error(message);
^
Error: Cannot find module './another'
Require stack:
- /project/workspace/test.ts
at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
at Module._load (node:internal/modules/cjs/loader:984:27)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:179:18)
at /project/workspace/test.ts:5:16
at async Function.import (/project/workspace/node_modules/jiti/dist/jiti.cjs:1:199772)
at async file:///project/workspace/index.mjs:7:29 {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/project/workspace/test.ts' ]
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working