You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Node option for experimental and module resolutions #880
I have a project that is written in typescript that imports node modules that are not transpiled. So I want to be able to use both ts-node to handle my code and pass flags to node so I can use native imports.
@thearegee There's a long thread around here where people have commented on possible implementations, but yes - still looking for a PR! Happy to work with you on getting it out.
@blakeembrey if you could link the thread, or let me know if there was a preference in approach and maybe give me a point in the right direction I will knock something up tomorrow
I would love to get something like this in because it will make my project so much cleaner
I was thinking we need the ability to pass any node flags to ts-node. I looked at some tickets I could find, some looked like they suggested using environmental variables:
First I was wondering if you had a preference of what you would like?
Secondly I was struggling to understand how you were passing the script to node where you could set these flags. I looked into in your bin.js you were using vm and there was potentially a chance you could use importModuleDynamically from: https://nodejs.org/api/vm.html#vm_script_runinnewcontext_sandbox_options
However I didn't see this being executed when I was playing around. So yeah, I'm happy do the work, just need a little guidance on how you expect this to work and some more context.
Node flags to TS node is a much different request and we should keep these separate, but I’ll be the first to decline supporting node.js flags in the TS Node executable. If you go through the Git history, you’ll discover that used to be possible - it was just too much to maintain and had some annoying edge cases. Every feature brings more issues/requests so I ended up removing it in favor of using node native features.
@thearegee native module support was implemented and published, and feedback is being tracked in #1007
I think that covers what you wanted here, so I'm closing this. Let me know if you were asking for something else and we can reopen as needed.
Activity
blakeembrey commentedon Sep 4, 2019
@thearegee There's a long thread around here where people have commented on possible implementations, but yes - still looking for a PR! Happy to work with you on getting it out.
robinglen commentedon Sep 4, 2019
@blakeembrey if you could link the thread, or let me know if there was a preference in approach and maybe give me a point in the right direction I will knock something up tomorrow
I would love to get something like this in because it will make my project so much cleaner
robinglen commentedon Sep 5, 2019
I was thinking we need the ability to pass any node flags to ts-node. I looked at some tickets I could find, some looked like they suggested using environmental variables:
Others seemed to suggest maybe use
argvso maybe more like this:First I was wondering if you had a preference of what you would like?
Secondly I was struggling to understand how you were passing the script to node where you could set these flags. I looked into in your
bin.jsyou were usingvmand there was potentially a chance you could useimportModuleDynamicallyfrom: https://nodejs.org/api/vm.html#vm_script_runinnewcontext_sandbox_optionsHowever I didn't see this being executed when I was playing around. So yeah, I'm happy do the work, just need a little guidance on how you expect this to work and some more context.
Thanks,
Rob
blakeembrey commentedon Sep 6, 2019
Node flags to TS node is a much different request and we should keep these separate, but I’ll be the first to decline supporting node.js flags in the TS Node executable. If you go through the Git history, you’ll discover that used to be possible - it was just too much to maintain and had some annoying edge cases. Every feature brings more issues/requests so I ended up removing it in favor of using node native features.
blakeembrey commentedon Sep 6, 2019
The issue is #436.
robinglen commentedon Sep 6, 2019
@blakeembrey so would you be open for both
--experimental-modulesand--es-module-specifier-resolution=nodeas apposed allowing for any node flag?I will catch up on the issue today
cspotcode commentedon Jul 29, 2020
@thearegee native module support was implemented and published, and feedback is being tracked in #1007
I think that covers what you wanted here, so I'm closing this. Let me know if you were asking for something else and we can reopen as needed.
wvhulle commentedon Dec 20, 2022
ts-node --experimentalSpecifierResolution nodeworks for me