The January Release Notes – Extension Authoring section says I should be able to update my package.json file to include the following:
{
"engines": {
"vscode": "^0.10.8"
},
"devDependencies": {
"typescript": "^1.7.5",
"vscode": "^0.11.x"
}
}
It also notes the following:
vscode.d.ts is no longer shipping within the vscode npm module.engine field in your extension is used to determine which version of vscode.d.ts to use.It does not, however, tell me where vscode.d.ts is installed. I used to be able to do imports like:
import { TextEditor } from 'vscode';
However, now I'm getting an error:
Cannot find module 'vscode'.
It's not clear to me, the new way to do these imports and I've tried tracking down vscode.d.ts to no avail, so I'm at a loss.
@jedmao you need to run a "npm install" after those changes so that the vscode.d.ts is fetched. The location of this file actually did not change, it should still be within node_modules/vscode/vscode.d.ts
@bpasero one step ahead of you. Not only did I run npm install after those steps, but after it wasn't working, I did npm uninstall vscode and then npm install again, just to make sure. There is no file at node_modules/vscode/vscode.d.ts, even though node_modules/vscode/package.json has within it:
"typings": "vscode.d.ts",
The closest thing I could find was a file at node_modules/vscode/typings/index.d.ts, but I don't think that's what I want.
@bpasero I also did an npm cache clean just now, deleted my node_modules folder and did a fresh npm install. Same issue.
@alexandrudima, do you know more about this? I'm looking at https://github.com/Microsoft/vscode-editorconfig/blob/master/typings/vscode-typings.d.ts with your name on it.
@jedmao there was a bug that prevented the vscode.d.ts file to be installed. When you run npm install please verify you see output like this:
Detected VS Code engine version: ^0.10.6
Found minimal version that qualifies engine range: 0.10.6
Fetching vscode.d.ts from: https://raw.githubusercontent.com/Microsoft/vscode/0.10.6/src/vs/vscode.d.ts
vscode.d.ts successfully installed!
Wanted to try and reproduce the problem here just for fun, so I uninstalled vscode from one of my existing, and perfectly functioning extensions, then followed the instructions listed on that page and updated the devDependencies of its package.json file to ^0.11.1. After running npm install however, the vscode.d.ts file was still no where to be found...
So I ran node ./node_modules/vscode/bin/install manually an got:
Error installing vscode.d.ts: Missing VSCode engine declaration in package.json.
Looked at the install script, figured that NPM package vars weren't set for some reason, then added this script to my package.json:
"pkgvars": "node ./node_modules/vscode/bin/install"
Using npm run pkgvars resulted in a successful download. _shrug_
@bpasero I definitely don't see the output you pasted above. I even tried changing my engine from ^0.10.8 to ^0.10.6 to make sure my settings were consistent w/ yours and still no output like that.
Then, I tried changing my vscode dev dependency from ^0.11.x to 0.11.1 like @mattacosta did above and I'm still not seeing your output.
Is there always going to be an engine version consistent with the version displayed in Visual Studio Code -> Help -> About?
Lastly, you said there "was" a bug. That gave me more qeustions:
^0.11.x vscode dev dependency? If so, perhaps the January release notes need to be updated to inform others of the same issue.The vscode devDependency is for the vscode _node package_. This is not the same as the VS Code application, which is managed separately. So it has nothing to do with any Jan/Feb/whenever release, and is available now.
Also, here's the issue that was fixed in 0.11.1: https://github.com/Microsoft/vscode-extension-vscode/issues/10
Have you tried running vscode's install script from your package.json though?
@mattacosta I'm aware that vscode is just an npm package. My question was concerning the engine setting.
I didn't run vscode's install script from package.json, because I'm not interested in that solution. I'm interested in solutions that don't require adding instructions to my README and work out-of-the-box for future contributors. Now, if you're suggesting I make it a post install script, that might be doable, but the release notes and guides don't say anything about this and I'd prefer to follow the golden path.
That said, I'm going to attempt using the post install script until this project evolves. Thanks for the link to the issue!
Sorry, I realised that I did not mention the necessary postinstall script. I updated the new & noteworthy. Any extension consuming the VS Code npm module 0.11.x needs to add the following to the package.json:
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install"
}
It works!
> [email protected] postinstall z:\Documents\GitHub\vscode-editorconfig
> node ./node_modules/vscode/bin/install
Detected VS Code engine version: ^0.10.8
Found minimal version that qualifies engine range: 0.10.8
Fetching vscode.d.ts from: https://raw.githubusercontent.com/Microsoft/vscode/0.10.8/src/vs/vscode.d.ts
vscode.d.ts successfully installed!
Still, I think others could well benefit from this in the release notes, right where it mentions the ^0.11.x dev dependency.
Why don't you add vscode.d.ts to DefinitelyTyped?
Because it does not support versioning...
Most helpful comment
Sorry, I realised that I did not mention the necessary postinstall script. I updated the new & noteworthy. Any extension consuming the VS Code npm module 0.11.x needs to add the following to the package.json: