Skip to content

Commit d6446de

Browse files
committed
Setup bundling and fix tasks
While we need to bundle the extension code with `eslint` we still have to use `tsc` for the tests, which is annoying. This also fixes are (already broken) VS Code launch tasks!
1 parent 3c19b64 commit d6446de

File tree

5 files changed

+63
-50
lines changed

5 files changed

+63
-50
lines changed

.vscode/launch.json

+10-12
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
"request": "launch",
88
"runtimeExecutable": "${execPath}",
99
"args": [
10-
"--extensionDevelopmentPath=${workspaceRoot}"
10+
"--disable-extensions",
11+
"--extensionDevelopmentPath=${workspaceFolder}"
1112
],
12-
"stopOnEntry": false,
1313
"sourceMaps": true,
14-
"outFiles": [
15-
"${workspaceFolder}/out/src/**/*.js"
16-
],
14+
"outFiles": [ "${workspaceFolder}/out/main.js" ],
1715
"preLaunchTask": "Build"
1816
},
1917
{
@@ -22,15 +20,15 @@
2220
"request": "launch",
2321
"runtimeExecutable": "${execPath}",
2422
"args": [
25-
"--disable-extensions",
26-
"ms-vscode.powershell-preview",
23+
// The tests require Code be opened with a workspace, which exists in
24+
// `test`, but this has to be passed as a CLI argument, not just `cwd`.
25+
"${workspaceFolder}/test",
26+
"--disableExtensions",
2727
"--extensionDevelopmentPath=${workspaceFolder}",
28-
"--extensionTestsPath=${workspaceFolder}/out/test/testRunner.js",
29-
"${workspaceFolder}/test"
30-
],
31-
"outFiles": [
32-
"${workspaceFolder}/out/**/*.js"
28+
"--extensionTestsPath=${workspaceFolder}/out/test/index.js",
3329
],
30+
"sourceMaps": true,
31+
"outFiles": [ "${workspaceFolder}/out/test/**/*.js" ],
3432
"preLaunchTask": "Build"
3533
},
3634
{

.vscodeignore

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
.vscode/**
2-
.vscode-test/**
3-
vscode-powershell.build.ps1
4-
typings/**
5-
**/*.ts
1+
.github/
2+
.poshchan/
3+
.vscode/
4+
.vscode-test/
5+
.vsts-ci/
6+
logs/
7+
node_modules/
8+
out/
9+
scripts/
10+
sessions/
11+
src/
12+
test/
13+
tools/
14+
15+
!out/main.js
16+
17+
.editorconfig
18+
.gitattributes
619
.gitignore
7-
tsconfig.json
8-
build/**
9-
bin/EditorServices.log
10-
bin/DebugAdapter.log
11-
bin/*.vshost.*
12-
bin/PowerShell/**
13-
logs/**
14-
out/test/**
15-
test/**
16-
sessions/**
17-
scripts/Install-VSCode.ps1
18-
tools/**
19-
.poshchan/**
20-
.github/**
21-
.vsts-ci/**
20+
.markdownlint.json
21+
.vscodeignore
2222
build.ps1
23+
extension-dev.code-workspace
24+
*.vsix
2325
tsconfig.json
2426
tslint.json
27+
vscode-powershell.build.ps1

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"type": "git",
2626
"url": "https://github.com/PowerShell/vscode-powershell.git"
2727
},
28-
"main": "./out/src/main",
2928
"activationEvents": [
3029
"onDebugInitialConfigurations",
3130
"onDebugResolve:PowerShell",
@@ -79,9 +78,10 @@
7978
"extensionDependencies": [
8079
"vscode.powershell"
8180
],
81+
"main": "./out/main.js",
8282
"scripts": {
83-
"compile": "tsc -v && tsc -p ./ && tslint -p ./",
84-
"compile-watch": "tsc -watch -p ./",
83+
"lint": "tslint --project tsconfig.json",
84+
"build": "tsc --project tsconfig.json && esbuild ./src/main.ts --outdir=out --sourcemap --bundle --minify --external:vscode --platform=node",
8585
"test": "node ./out/test/runTests.js",
8686
"package": "vsce package --no-gitHubIssueLinking",
8787
"publish": "vsce publish"

tsconfig.json

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
2-
"compilerOptions": {
3-
"rootDir": ".",
4-
"module": "commonjs",
5-
"target": "es6",
6-
"outDir": "out",
7-
"lib": [
8-
"es2017",
9-
"DOM"
10-
],
11-
"sourceMap": true
12-
},
13-
"exclude": [
14-
"node_modules"
15-
]
2+
"compilerOptions": {
3+
// NOTE: The TypeScript compiler is only used for building the tests (and
4+
// the sources which the tests need). The extension is built with `esbuild`.
5+
"module": "commonjs",
6+
"outDir": "out",
7+
"target": "ES6",
8+
"lib": [ "ES6", "DOM" ],
9+
"sourceMap": true,
10+
"rootDir": ".",
11+
// TODO: We need to enable stricter checking...
12+
// "strict": true,
13+
// "noImplicitReturns": true,
14+
// "noFallthroughCasesInSwitch": true,
15+
// "noUnusedParameters": true
16+
},
17+
"include": [ "src", "test" ],
1618
}

vscode-powershell.build.ps1

+11-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,17 @@ task CopyEditorServices -If { !(Test-Path ./modules/PowerShellEditorServices) -a
6464

6565
task Build CopyEditorServices, Restore, {
6666
Write-Host "`n### Building vscode-powershell" -ForegroundColor Green
67-
exec { & npm run compile }
67+
# TODO: TSLint is deprecated and we need to switch to ESLint.
68+
# https://github.com/PowerShell/vscode-powershell/pull/3331
69+
exec { & npm run lint }
70+
71+
# TODO: When supported we should use `esbuild` for the tests too. Although
72+
# we now use `esbuild` to transpile, bundle, and minify the extension, we
73+
# still use `tsc` to transpile everything in `src` and `test` because the VS
74+
# Code test runner expects individual files (and globs them at runtime).
75+
# Unfortunately `esbuild` doesn't support emitting 1:1 files (yet).
76+
# https://github.com/evanw/esbuild/issues/944
77+
exec { & npm run build }
6878
}
6979

7080
#endregion

0 commit comments

Comments
 (0)