-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
Create ts-transpile
bin script
#939
Create ts-transpile
bin script
#939
Conversation
Now that we can specify configuration via We should also think about the naming. |
@cspotcode It's useful for shebang purposes: I don't have to rely on there always being env variables set, or a tsconfig.json that's configured to not typecheck. The ability to specify config via As for the name, I don't think it's any more confusing than the |
Why is this an issue? I'd also love to lean on this feature here if possible, otherwise it'd be easy to have a lot of different |
Debugging:It's useful for debugging, as it means I can quickly write a TypeScript script w/o having to change anything outside of the file I'm working in, and still have it compile quickly while getting nice autocompletion & type checking via my IDE. This also means I don't risk committing the disabling of type checking for the whole project. Teaching:There are a lot of stuff controlled by Quick utility scriptingI like TypeScript a lot, because it helps keep my code safe & greatly empowers my IDE to provide far better support, with things like auto completion. I also work as the technical lead of the team responsible for looking after my company's infrastructure, and responding to high priority requests such as application outages. As such, the ability to write a single TS file that can be ran anywhere (since it's tied only to its own file and that This also removes the hum and haring over adding and removing an extra dependency: iirc I think I tried The alternative is to introduce a build step somewhere, which is an whole other ball of wax that defeats the point. The underlying theme that's common across the above is that this allows you to easily write files that are completely self contained - I actually think that having a Ultimately I think that |
What problems did you hit with I'd be more agreeable if the name started with the It also begs the question: do we make a Someone on the TypeScript team is building a new "twoslash" tool for embedding interactive TypeScript demos into websites. It allows specifying compiler flags via comments at the top of the file. I wonder if someone can build a solution similar to that? https://www.typescriptlang.org/v2/dev/twoslash/ |
Requiring me to explain to others that they now have to install a third global dependency for something. While I agree that one package is typically very harmless, when working with developers who have mostly only worked with a single primary language that operators rather differently (In this case Ruby), adding another package to the list of things they have to keep in their head makes it harder to get them to dip their toes into the water.
Yes it is different - it's introducing a new dependency into the tree that has to be justified, and that has to be managed. Case and point (and also overlapping with my previous point about making things more scary for developers who have only ever worked in one language space), installing
"But, I've got I understand that this is an npm issue, but it's still more differences than "none" vs adding a new file to Additionally, projects can have policies in place that have strict rules around packages that can and cannot be installed - while I think attempting to audit every package you install manually is not a good use of one's time, it's harder for me to get approval for two packages that I want for what some could call a convenience than one package. As a real-world example, the New Zealand government provide a high security platform called CWP, which has very high security requirements around packages; such as not being allowed to use any package that isn't on a stable release channel (i.e no
I'm happy with that. It would also align it with the register name; would you like me to rename it to
I assume you're meaning both flags of I think it's reasonable to say that it's not reasonable to facilitate every permutation, but I do think it's reasonable to support transpile mode as a shebang, due to what it does. Additionally,
No, that is not the goal. The goal of this specific PR is one of accessibility and convenience, since a large number of distro don't support passing arguments to shebangs. |
@G-Rath this makes sense, happy to make it a feature. I’m good with either naming, but agree it’s probably better to namespace under |
For what it's worth, my preference is to name it Despite what I said earlier, I'm also happy to get this merged. Seems like a really high-value utility. |
I'm not a fan of I think it's a cute shortening, but prefer the more expressive I'll rename and push. |
It's an acronym for "Transpile Only", just as I hit a use-case for Do either of you know where people typically rely on the non-script-mode behavior? |
No, but I also rely on the defaults, so not sure the impact - I'll run (that'll be in about 30 minutes, as I'm just about to leave for work) |
@G-Rath thanks, that'd be great. As far as I know, the only difference between script-mode and non-script-mode is the default for
For my case, if my helper scripts don't use script-mode, then someone tries to run |
Sadly I don't think it'll provide as much insight as I hoped now that I understand the difference.
I think I've hit this before, and it's an interesting one - overall I think it tends to be rather contextually based, as sometimes you want That's why I think overall the project default is the correct default behaviour: it's reasonable to expect (or hope) it'll behave the same as often as possible regardless of things like what directory you're in - otherwise it's another thing I have to discuss with developers: "so to regenerate the rules table you just run this script - but make sure you only call it in this directory; or a directory that has a In saying that, I think the actual default should be to act as TS does for resolving the Then, |
To clarify, it sounds like we agree that the default should be "--script-mode." Do I have that right?
This describes the behavior of It matches the behavior of
|
Yes my apologies - for some reason I crossed the two behaviours in my head when replying, so "script" & "project" should be inverted in my previous comment.
Good point; given that I think it's better to match nodes behaviour over tsc. I'm going to start using (btw I think this might be worth breaking out into a seperate top-level issue, so we can discuss it without bogging down this PR - we could also pin it to increase visibility, and hopefully get some other people to have a go at using |
Yeah, good call, I created #949. |
@andrewbranch is there anything actions still outstanding before this PR can be merged? |
@G-Rath did you ping the right person? I am a member of TypeStrong, but I’ve never been involved with ts-node. |
@andrewbranch My apologies - I mixed you up with @cspotcode who is also an Andrew, but really I was aiming for @blakeembrey, so I failed on two fronts :/ Cheers for the heads up, and thanks for the work you've done with TypeScript 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some time to merge and publish this, but I think the bin files need to be renamed. After that I'll try cutting a release.
package.json
Outdated
@@ -6,7 +6,8 @@ | |||
"types": "dist/index.d.ts", | |||
"bin": { | |||
"ts-node": "dist/bin.js", | |||
"ts-script": "dist/script.js" | |||
"ts-script": "dist/script.js", | |||
"ts-node-transpile-only": "dist/transpile.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on #948 (comment) I think we need to rename to dist/bin-script.js
and dist/bin-transpile.js
. Once that's done I can take a stab at merging and publishing a new release.
Fixes #703