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

Allow custom file extensions in --eval from CLI #2135

Open
PartMan7 opened this issue Sep 4, 2024 · 0 comments
Open

Allow custom file extensions in --eval from CLI #2135

PartMan7 opened this issue Sep 4, 2024 · 0 comments

Comments

@PartMan7
Copy link

PartMan7 commented Sep 4, 2024

Desired Behavior

As part of a prebuild step in a project of mine, I'm reading multiple tsx files, inserting a small snippet, and running them through ts-node --eval. I would like this to run if I specify an appropriate file extension.

Is this request related to a problem?

In the above case, even if I pass the appropriate config, due to the file name in eval being hardcoded as [eval].ts, it ends up evaluated as .ts.

image
npx ts-node --swc --compilerOptions '{"jsx":"react-jsx"}' -e 'const element = <div>You lost the game</div>;'

With the addition of a flag like --eval-extension '.tsx', the above could now work:

npx ts-node --swc --compilerOptions '{"jsx":"react-jsx"}' --eval-extension '.tsx' -e 'const element = <div>You lost the game</div>;'

Alternatives you've considered

Currently I'm adding an additional step to the process, where I pipe the output to an intermediate file and then interpret it through ts-node, but this is a bypass for an apparent shortcoming of the -e flag.

Additional context

This was run locally on 10.9.1.

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

1 participant