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?
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.
Most helpful comment
How do I run
ts-node-devwithts-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-nodeandts-node-dev. Thets-nodeversion is run bynode --loader ts-node/esm. I also triedts-node-dev -r esmbut that did not work.