Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can ts-node-dev be used with esm? #65

Closed
karensg opened this issue Apr 29, 2019 · 14 comments
Closed

Can ts-node-dev be used with esm? #65

karensg opened this issue Apr 29, 2019 · 14 comments

Comments

@karensg
Copy link

karensg commented Apr 29, 2019

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?

@wclr
Copy link
Owner

wclr commented May 2, 2019

I'm not sure, but probably should.

@karensg
Copy link
Author

karensg commented May 6, 2019

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.

@wclr
Copy link
Owner

wclr commented May 7, 2019

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

@karensg
Copy link
Author

karensg commented May 8, 2019

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: TypeStrong/ts-node#722

@wclr
Copy link
Owner

wclr commented May 8, 2019

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

@karensg
Copy link
Author

karensg commented May 8, 2019

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 {

@wclr
Copy link
Owner

wclr commented May 8, 2019

@karensg
Should be working now.

@steida
Copy link

steida commented May 8, 2019

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.

@karensg
Copy link
Author

karensg commented May 8, 2019

It works for me too. Absolute madness!
Thanks!

@karensg karensg closed this as completed May 8, 2019
@wclr
Copy link
Owner

wclr commented May 9, 2019

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.

@alesso-x
Copy link

alesso-x commented Sep 11, 2020

How do I run ts-node-dev with ts-node/esm? related issue TypeStrong/ts-node#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.

@wclr
Copy link
Owner

wclr commented Sep 11, 2020

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

@sippeangelo
Copy link

I've completely given up on the mess that is ESM and opted for fix-esm. Worked fine with ts-node-dev for me.

@homerjam
Copy link

homerjam commented Jan 3, 2022

How do I run ts-node-dev with ts-node/esm? related issue TypeStrong/ts-node#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.

#212 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants