istanbuljs / istanbuljs/esm-loader-hook

0.2.0 fails when run in conjunction with ts-node/esm and decorators

Open
#9 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
11
Forks
3
PR merge metrics
No merged PRs in 30d

Description

My project is in typescript and I'm using `ts-node/esm` loader also. My code has decorators in the code. When I revert back to 0.1.0 of this project it works.

This is the error:
```
SyntaxError[ @/Users/jchase24/code/recovery/apps/recovery-auth-api/src/controllers/auth.controller.test.ts ]: /Users/jchase24/code/recovery/apps/recovery-auth-api/src/controllers/auth.controller.ts: Support for the experimental syntax 'decorators' isn't currently enabled (45:1):

43 | import { ConfigService } from '../services/config/config.service.js'
44 |
> 45 | @ApiPath({
| ^
46 | path: '/',
47 | name: 'Authentication'
48 | })

Add @babel/plugin-proposal-decorators (https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-decorators) to the 'plugins' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-decorators (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-decorators) to the 'plugins' section to enable parsing.
at instantiate (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parse-error/credentials.ts:62:21)
at toParseError (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parse-error.ts:60:12)
at Parser.raise (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/tokenizer/index.ts:1474:19)
at Parser.expectOnePlugin (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/tokenizer/index.ts:1539:18)
at Parser.parseDecorator (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parser/statement.ts:713:10)
at Parser.parseDecorators (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parser/statement.ts:692:28)
at Parser.parseStatementLike (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parser/statement.ts:418:25)
at Parser.parseModuleItem (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parser/statement.ts:365:17)
at Parser.parseBlockOrModuleBlockBody (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parser/statement.ts:1345:16)
at Parser.parseBlockBody (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parser/statement.ts:1319:10)
at Parser.parseProgram (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parser/statement.ts:226:10)
at Parser.parseTopLevel (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parser/statement.ts:208:25)
at Parser.parse (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/parser/index.ts:45:10)
at parse (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/parser/src/index.ts:67:38)
at parser (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/core/src/parser/index.ts:28:19)
at parser.next ()
at normalizeFile (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/core/src/transformation/normalize-file.ts:52:24)
at normalizeFile.next ()
at run (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/core/src/transformation/index.ts:38:36)
at run.next ()
at transform (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/core/src/transform.ts:29:20)
at transform.next ()
at step (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/gensync/index.js:261:32)
at /Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/gensync/index.js:273:13
at async.call.result.err.err (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/gensync/index.js:223:11)
at cb (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/gensync/index.js:189:28)
at /Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/@babel/core/src/gensync-utils/async.ts:90:7
at /Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/gensync/index.js:113:33
at step (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/gensync/index.js:287:14)
at /Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/gensync/index.js:273:13
at async.call.result.err.err (/Users/jchase24/code/recovery/apps/recovery-auth-api/node_modules/gensync/index.js:223:11)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with ts-node/esm and a TypeScript file containing decorators, comparing version 0.2.0 with 0.1.0. Start by tracing the ESM instrumentation and Babel parser path shown in the error; done means decorated TypeScript runs under 0.2.0 without the reported syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.