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

util: upgrade ts-node for native ESM support #4211

Merged
merged 1 commit into from Apr 3, 2022
Merged

util: upgrade ts-node for native ESM support #4211

merged 1 commit into from Apr 3, 2022

Conversation

MaikoTan
Copy link
Contributor

@MaikoTan MaikoTan commented Mar 25, 2022

ts-node has native ESM support in v10.7.0 version,
although according to the related PR says,
they are just spawn a child process that passed --loader ts-node/esm
options to node itself.
But no more painful ExperimentalWarning: --experimental-loader is an experimental feature. message in the output.

Also, upgrade typescript and typescript-eslint to the newer version.


By the way, seems like ts-node has added swc transpiler several versions ago,
and according to swc or ts-node, that this transpiler is significantly faster a lot.
But appearly swc has no ability to check the typescript type.
So I am wondering whether or not we can switch to this one?

ts-node has native ESM support in [v10.7.0 version](https://github.com/TypeStrong/ts-node/releases/tag/v10.7.0),
although according to the [related PR](TypeStrong/ts-node#1655) says,
they are just spawn a child process that passed `--loader ts-node/esm`
options to node itself.

Also, upgrade `typescript` and `typescript-eslint` to the newer version.
@MaikoTan
Copy link
Contributor Author

MaikoTan commented Mar 25, 2022

npm run test is still using the loader option for node with ts-node/esm, but seems like mocha has hacked the node require to do its trick to support ESM which is not compatible with ts-node currently.
I tried several solution to make mocha work with ts-node's ESM support but the only one that worked is the weirdo ts-node node_modules/.bin/mocha.(@_@;)
So the only continuing reporting ExperimentalWarning: --experimental-loader is an experimental feature. is the test script. Folks in the ts-node org said that is a rabbit hole, too. ┑( ̄Д  ̄)┍

@quisquous
Copy link
Owner

Thanks for this. Sorry I haven't merged it yet, I wanted to look at this locally a bit more.

@quisquous
Copy link
Owner

But appearly swc has no ability to check the typescript type.
So I am wondering whether or not we can switch to this one?

What do you mean, by this?

@MaikoTan
Copy link
Contributor Author

MaikoTan commented Apr 3, 2022

I mean that although ts-node is using tsc to transpile TypeScript code by default, but it can also use swc to transpile.
according to swc or ts-node, swc is much faster than tsc. You see, every time we run those TypeScript-written scripts, it always take about 1 second or more to transpile code. If we set the swc as the transpiler in ts-node, it takes much shorter time before running the script actually, but swc transpiler doesn't do any type-checking things, so I am not very sure whether it is worth to switch transpiler to swc in this case.

@quisquous
Copy link
Owner

Ah, ok! I think it'd be nice to have type checking for the dev server as well as at least some type checking for all the scripts (even if it's a separate step), but if there's some option to run swc in some places but not others and not lose any type checking coverage, that seems like an option.

@quisquous
Copy link
Owner

Overall though, I think this looks good. swc changes can come in some other PR. Thanks!

@quisquous quisquous merged commit 039a214 into quisquous:main Apr 3, 2022
github-actions bot pushed a commit that referenced this pull request Apr 3, 2022
ts-node has native ESM support in [v10.7.0 version](https://github.com/TypeStrong/ts-node/releases/tag/v10.7.0),
although according to the [related PR](TypeStrong/ts-node#1655) says,
they are just spawn a child process that passed `--loader ts-node/esm`
options to node itself.

Also, upgrade `typescript` and `typescript-eslint` to the newer version. 039a214
@MaikoTan MaikoTan deleted the util/upgrade-ts-node branch April 3, 2022 22:06
github-actions bot pushed a commit to SiliconExarch/cactbot that referenced this pull request Apr 3, 2022
…us#4211)

ts-node has native ESM support in [v10.7.0 version](https://github.com/TypeStrong/ts-node/releases/tag/v10.7.0),
although according to the [related PR](TypeStrong/ts-node#1655) says,
they are just spawn a child process that passed `--loader ts-node/esm`
options to node itself.

Also, upgrade `typescript` and `typescript-eslint` to the newer version. 039a214
github-actions bot pushed a commit to SiliconExarch/cactbot that referenced this pull request Apr 3, 2022
…us#4211)

ts-node has native ESM support in [v10.7.0 version](https://github.com/TypeStrong/ts-node/releases/tag/v10.7.0),
although according to the [related PR](TypeStrong/ts-node#1655) says,
they are just spawn a child process that passed `--loader ts-node/esm`
options to node itself.

Also, upgrade `typescript` and `typescript-eslint` to the newer version. 039a214
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

Successfully merging this pull request may close these issues.

None yet

2 participants