-
Notifications
You must be signed in to change notification settings - Fork 505
Use tsx for parsing typescript sources #771
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
base: master
Are you sure you want to change the base?
Conversation
`ts-node` has issues working with `esm`, so switch it out in favour of using `tsx` which just works "out of the box".
|
I'm not sure if this is something you'd consider @lorenwest, but I was having issues working with TypeScript and |
|
Thank you for bringing this to our attention. That sounds like a healthy option to support. Do you have any ideas about how an installation would choose It has to run with current installations, so the default may have to be |
|
So that's why I'm not super dedicated to this approach. Maybe this can be adapted so that I'm not super sure what the best approach is as I don't have much history with this project and wouldn't want to introduce something that's against the goals/style here. Thanks for taking a look though, and happy to bring |
|
Leaving open if any contributors want to take on this issue. |
|
I am not familiar with tsx and am neutral on this proposal. |
Is that a bad thing in a config library? Least Power suggests to me that reflection in load time logic might be a bridge too far. I could see a case for this being a wontfix. Do you know if this plays nice with nyc? If so then I’m on board. Does it make #740 worse, better, indifferent? Could you take a stab at updating the readme to reflect this caveat? |
Sadly, no.
|
|
I was hoping for advice from the Istanbul people but no luck so far |
|
See #847 |
|
Depending on how this ticket plays out, we may need to overlook the downsides of this solution. |
|
FYI, just ran into an issue (I belive nodejs/node#59364 referenced above) when trying to use native ts support after upgrading node from 22.17 to 22.18. I load Error: Cannot parse config file: '<PROJECT_PATH>/config/default.ts': Error: Must use import to load ES Module: <PROJECT_PATH>/config/default.ts
require() of ES modules is not supported.
require() of <PROJECT_PATH>/config/default.ts from <PROJECT_PATH>/node_modules/config/parser.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from <PROJECT_PATH>/package.json.I made a wrapper import c from './defaultConfig.ts';
export default c;This avoids Maybe you could somehow work this into your lib? |
ts-nodehas issues working withesm, so switch it out in favour of usingtsxwhich just works "out of the box".