swc-project / swc-project/swc-node
@swc-node/register/esm doesn't recognize `.ts` file
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 95
- Avg merge
- 14d 11h
- Merged PRs (30d)
- 1
Description
Reproduction Procedure
- Clone this
yarnyarn dev
- Version
node: 14.18.3@swc-node/register: 1.6.0 ~ 1.6.4
- Executed Prompt:
SWCRC=true node --loader @swc-node/register/esm index.ts - Note that
< 1.6, this behavior fall back into #704
.swcrc
{
"jsc": {
"baseUrl": ".",
"parser": {
"syntax": "typescript",
"tsx": true,
"dynamicImport": true
},
"target": "es5"
},
"module": {
"type": "es6"
}
}
Symptoms
yarn run v1.22.19
$ SWCRC=true node --loader @swc-node/register/esm index.ts
(node:19817) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^
[Error: ENOENT: no such file or directory, open '/home/sekyu-kwon/temp/index.ts.mjs'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/home/my-name/temp/index.ts.mjs'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
As you can see, it doesn't recognize .ts. Also same with .mts.
Is it related to .swcrc recognition issues like #701 ?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with index.ts, the shown .swcrc, and SWCRC=true node --loader @swc-node/register/esm index.ts. Then inspect the @swc-node/register/esm loader entry point and its extension-resolution path, including the analogous .mts case. Done means the loader recognizes these TypeScript files without trying to open a generated .ts.mjs path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100