Ts-node-dev: Can ts-node-dev be used with esm?

Created on 29 Apr 2019  路  13Comments  路  Source: wclr/ts-node-dev

I can run it with ts-node itself with
node -r esm -r ts-node/register...

But I assume that at this moment ts-node-dev can not be combined with esm?

Most helpful comment

How do I run ts-node-dev with ts-node/esm? related issue https://github.com/TypeStrong/ts-node/issues/1007.

I have a sample repo where I'm trying to use top level await with scripts for ts-node and ts-node-dev. The ts-node version is run by node --loader ts-node/esm. I also tried ts-node-dev -r esm but that did not work.

All 13 comments

I am using it in https://github.com/este/este and it works. But note there is a bug, so version must be fixed. Check esm issues.

I'm not sure, but probably should.

How would you transfrom this to ts-node-dev?
node -r esm -r ts-node/register/transpile-only src/index.ts

I don't see the register options for ts-node-dev library.

-r should work, it is node's option, try:
ts-node-dev -r esm --transpile-only src/index.ts

This does not work unfortunately as esm needs to be loaded before ts-node. Could we add a check for that logic in this library?
Link to related discussion: https://github.com/TypeStrong/ts-node/issues/722

@karensg
Check it with the latest version, I inserted the check.

Thanks for your help!

Tried with v37, the flag does not seem to influence anything. Using what you suggested:
ts-node-dev -r esm --transpile-only src/index.ts

Getting these kind of errors:

import { readFileSync } from 'fs';
       ^
SyntaxError: Unexpected token {

@karensg
Should be working now.

Interesting. New version does not work with the old versions of "esm": "3.2.20" but works with the last version of esm. Thank you. It's fixed for me.

It works for me too. Absolute madness!
Thanks!

Interesting. New version does not work with the old versions of "esm": "3.2.20" but works with the last version of esm. Thank you. It's fixed for me.

Well it could be handled, but don't think it is very relevant.

How do I run ts-node-dev with ts-node/esm? related issue https://github.com/TypeStrong/ts-node/issues/1007.

I have a sample repo where I'm trying to use top level await with scripts for ts-node and ts-node-dev. The ts-node version is run by node --loader ts-node/esm. I also tried ts-node-dev -r esm but that did not work.

@alesso-x
I'm not sure how ESM loader works and how it should be configured bu this test is passing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Chnapy picture Chnapy  路  6Comments

urish picture urish  路  4Comments

jraoult picture jraoult  路  3Comments

kachkaev picture kachkaev  路  11Comments

capc0 picture capc0  路  5Comments