Tuesday 14 March 2017

Every VScode TS extension has its own local (thus in the future, automatically outdated) copy of tsc? And how to sync its `node_modules`?

Just getting into VScode extensibility and going through the standard files in the simple helloworld demo extension generated by yo code.

Keep in mind I haven't dabbled in TypeScript before, so I'm kinda looking to clear up some initial possibly-misconceptions (or indeed reaffirm my premature conclusions ;)

In package.json there's some scripts invoking "tsc" which of course must be the TypeScript Compiler. So in bash type in tsc and it goes not found, install nodejs-typescript?. Interesting so there must be a vscode-local copy! Doing a file search next and the match shows up inside my own helloworld dir!

So that means yo code just dumps some tsc version it has currently at hand, in fact a whole typescript package, along with a huge load of other node packages, inside the extension project's very own private hoard of node_modules.

Now granted, this is neat for reproducable builds. If you come back to your abandoned extension project of two years ago to tweak it some, it has everything in place to readily compile as it did long ago!

But what's the keeping-it-all-up-to-date story while my extension is still in active occasional development? Predictably tsc and that whole wad of infrastructure inside node_modules will keep getting improved, fixed, patched, updated. Obviously while I'm maintaining and evolving my extension, I want the latest stable version of all these things.

  • Do I simply delete node_module and vscode will refresh it?
  • Will it do so anyway when building my extension with a newer release of VScode than the one that built it last time around?
  • Does it fetch and place the required updates when I simply bump the version numbers listed in package.json and rebuild? But this would technically invoke tsc to replace itself? Not entirely scandalous, but sounds a bit shaky still

Here's how I got pondering all this, in package.json I find:

"devDependencies": {
    "typescript": "^2.0.3",
...

and as I hover ^2.0.3 it tells me Latest version: 2.2.1. Well huh? Latest version online? Is that the version VScode "has" but yo code didn't? Is that the maximum I could enter right now and it would still build? (Sure I'm gonna try it in a bit anyway but still! How do I know it'll actually really sorta compare what's in node_modules and update, or fail, rather than silently ignore?) And if so, update my ext-proj's node_modules too?

So many questions! I better not get started looking at all the other little fragments one can interactively hover over in an IntelliSense environment to raise only ever more questions! :D



via metaleap

No comments:

Post a Comment