question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Convert gluegun source to TypeScript

See original GitHub issue

I’m about 80% through a major refactor, which includes converting over to TypeScript. So I’m filing this issue to track some of the items.

  1. I’m using ts-node right now, and it works pretty well. However, my assumption is that we should keep this as a devDependency and compile a JS bundle … when other CLIs import gluegun, they get the JS bundle. Is that right, or can we assume ts-node as a full dependency and call it good?
  2. If we do compile a JS bundle, we lose some of the debugging capability in the wild, because we won’t get reasonable line numbers.
  3. If we do compile, we could conceivably target/support older versions of node. Should we?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
skellockcommented, Dec 21, 2017
  1. Yes, you are right.

ts-node is great for dev but not for shipping. TypeScript isn’t really a bundler so it won’t pack up dependencies. It just turns our source into a different source. There will be a build step required for shipping. Add outDir: dist to the tsconfig.json (for example) then run tsc -p . and we’re done.

  1. Source maps is how you fix this.

sourceMaps: true in our config will emit these. With the right target setting, the output of ts is remarkably human. Not like Babel. In practice this isn’t a big deal. Being a superset of js is an advantage here. 🥇

  1. Yes and yes! Allowing people to opt-in to dependencies is the right way (albeit a little more work).

I also recommend going the bundle route on top of all this. Multi-format would be great to give more flexibility to our downstream. rollup can do all of this. And providing instructions to clis on how to do this too would be way above & beyond. 🏆

1reaction
GantMancommented, Dec 21, 2017

Supporting older versions of NODE!? Woah! epic!

Read more comments on GitHub >

github_iconTop Results From Across the Web

infinitered/gluegun: A delightful toolkit for building ... - GitHub
Gluegun. Gluegun is a delightful toolkit for building Node-based command-line interfaces (CLIs) in TypeScript or modern JavaScript, with support for:.
Read more >
Documentation - Migrating from JavaScript - TypeScript
Converting a JavaScript codebase over to TypeScript is, while somewhat tedious ... '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
Read more >
gluegun - npm
A delightful toolkit for building Node-powered CLIs.. Latest version: 5.1.2, last published: 8 months ago. Start using gluegun in your ...
Read more >
How to build a CLI with Node.js - Twilio
oclif a framework for building extensible CLIs by Heroku ( gluegun as an alternative). Additionally there are many convenient ways to consume ...
Read more >
ts-migrate: A Tool for Migrating to TypeScript at Scale - Medium
Take a JavaScript or partial TypeScript project and convert it ... the file extensions of the source code files from .js/.jsx to .ts/.tsx...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found