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

Support API JavaScript #13

Closed
tachibana-shin opened this issue May 19, 2022 · 9 comments
Closed

Support API JavaScript #13

tachibana-shin opened this issue May 19, 2022 · 9 comments
Labels

Comments

@tachibana-shin
Copy link

Hi,

I think it would be great to have a JavaScript API for other compilers to use like tsup

Like it:

import { build } from "tsx"

build({
  entry: "src/main.ts",
  watch: true
})
@privatenumber
Copy link
Owner

Not sure if I follow what you're suggesting.

What's your use-case?

@tachibana-shin
Copy link
Author

I am creating a framework and it needs a command to run typescript in development mode. I am intending to use tsx to run the compiled typescript script

@privatenumber
Copy link
Owner

privatenumber commented May 19, 2022

You mean the uncompiled TypeScript code.

In your code, you can currently:

I'll considering exporting a method that spawns tsx given a file path. But the JS API will be limited to a spawn because it needs to be read by the Loader API.

Would love to hear more about your use-case when you have more details.

@tachibana-shin
Copy link
Author

I tried spawn but when something goes wrong the error message is all white text. I don't think I can debug if the error message is not so prominent

@privatenumber
Copy link
Owner

I believe the output stream needs to be TTY for colors to be outputted.

You can inherit the stdout to display colors: https://github.com/esbuild-kit/tsx/blob/a271f4d1773bfb0ffdd072aa36e996c6e8602b32/src/run.ts#L21-L25

@tachibana-shin

This comment was marked as off-topic.

@tachibana-shin

This comment was marked as off-topic.

@privatenumber
Copy link
Owner

Back to the original request.

You can now spawn a tsx process without losing color in stderr.

Is this request closable?

@tachibana-shin
Copy link
Author

Closed

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants