This is my custom VSCode extension template. Mainly used to illustrate my blog post about aliases actually.
- Clone the repo
- Do
git remote remove origin
- Find all occurenses of
templaet
in the project and replace them with your extension name
You're good to go!
Aliases are configure in tsconfig.json
. There are 2 sample aliases.
To use aliasing in another extension you need to do the following:
- Migrate the following code from webpack config:
const tsconfigContent = require('./tsconfig.json');
const alias = {}
Object.entries(tsconfigContent.compilerOptions.paths).forEach(([aliasName, [ aliasContent ]]) => {
const name = aliasName.replace('/*', '');
const aliasPath = path.resolve(root, 'out', aliasContent.replace('/*', ''));
alias[name] = aliasPath;
})
- Move
alias.ts
to your test folder - Migrate the following code from
runTest.ts
import './alias';
import 'module-alias/register';
- Install
module-alias
package
I have a restriction on the VSCode version I can use at work, so I create my extensions with respect to that. For this template it means I have a code that makes sure I run test against a speciic version instead of the latest stable.
The version under test is specified in package.json
in engines.vscode
.
To remove this functionality simply change thfollowing line in runTest.ts
:
await runTests({ extensionDevelopmentPath, extensionTestsPath, version });
to
await runTests({ extensionDevelopmentPath, extensionTestsPath });