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

[💡 Feature]: Replace ts-node with tsx #11878

Closed
1 task done
christian-bromann opened this issue Dec 16, 2023 · 10 comments · Fixed by #12752
Closed
1 task done

[💡 Feature]: Replace ts-node with tsx #11878

christian-bromann opened this issue Dec 16, 2023 · 10 comments · Fixed by #12752
Assignees
Labels
help wanted Issues that are free to take by anyone interested Idea 💡 A new feature idea v9
Milestone

Comments

@christian-bromann
Copy link
Member

Is your feature request related to a problem?

We have been running into issues using ts-node lately, see:

For running TypeScript files on demand we currently use ts-node which seems to have difficulties with ESM/CJS as well as sourcemaps.

Describe the solution you'd like.

Switch to tsx which seems to have general better support for it.

Describe alternatives you've considered.

n/a

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested Idea 💡 A new feature idea labels Dec 16, 2023
@wdio-bot
Copy link
Contributor

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

@Delagen
Copy link

Delagen commented Jan 26, 2024

Now I solved this with running
TSX_TSCONFIG_PATH="./tsconfig.json" NODE_OPTIONS="$NODE_OPTIONS --import tsx" wdio run ./wdio.conf.js

Config need to be compiled to JS or need to be written in plain JS in case to prevent loading ts-node in @wdio/config by detection of extention of config file

@christian-bromann
Copy link
Member Author

@Delagen writing the config to the file system as JS file is not an option. We should provide the ability to just load TS files and execute them.

@Delagen
Copy link

Delagen commented Jan 26, 2024

@christian-bromann I understand, I use config in JS only to prevent loading of ts-node. All tests and etc. written in Typescript, an d not transpiled to JS manually, all compilation in memory via TSX

Only problem now, is ts-node if it present in node_modules it still try to load by runner, so I have to remove it manually with editing package.lock.json to enable execution in CI.

@goosewobbler
Copy link
Contributor

goosewobbler commented Apr 24, 2024

I took a look at this but it seems there is a fair bit of overlap with the removal of transpiler choice / autoCompileOpts as mentioned in #10362, so maybe we do them together or at least the latter one first.

Some things I noted:

@christian-bromann
Copy link
Member Author

so maybe we do them together or at least the latter one first.

Sounds good to me. I am open to remove autoCompileOpts all together and have it "just" work™.

@erwinheitzman
Copy link
Member

@goosewobbler sounds good. I think it is good to stick as much as possible to how the tools work out of the box (no config using wdio but instead document how wdio can be used with tsx). So if tsx recommends using environment variables to appoint a tsconfig then we just point to the tsx documentation, simple, clean and most of all less maintenance and confusion

@goosewobbler
Copy link
Contributor

@erwinheitzman tsx just provides both methods, CLI switch and env var, there's no explicit recommendation. I implemented a tsxTsConfigPath setting which is passed to the switch but can easily remove it if we want to reduce the maintenance load here.

@christian-bromann
Copy link
Member Author

I think being able to provide the path to a tsconfig.json makes sense since many projects have a different tsconfig.json for development and testing. One suggestion: I would call this option in WebdriverIO just tsConfigPath.

@christian-bromann
Copy link
Member Author

Re-assigning this to @goosewobbler as he took a first stab at a PR on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that are free to take by anyone interested Idea 💡 A new feature idea v9
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants