Skip to content

Commit 10371a3

Browse files
Merge pull request #3555 from PowerShell/andschwa/bundle
Bundle the extension
2 parents 123f602 + c629012 commit 10371a3

14 files changed

+105
-74
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

extension-dev.code-workspace

+14-14
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
"path": "../PowerShellEditorServices"
88
}
99
],
10-
"settings": {
11-
"files.associations": {
12-
"**/snippets/*.json": "jsonc",
13-
"**/.vsts-ci/**/*.yml": "azure-pipelines",
14-
},
15-
"typescript.tsdk": "./node_modules/typescript/lib",
16-
"powershell.codeFormatting.autoCorrectAliases": true,
17-
"powershell.codeFormatting.newLineAfterCloseBrace": false,
18-
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
19-
"powershell.codeFormatting.useCorrectCasing": true,
20-
"powershell.codeFormatting.whitespaceBeforeOpenBrace": false,
21-
"powershell.codeFormatting.whitespaceBetweenParameters": true,
22-
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline"
23-
}
10+
"settings": {
11+
"files.associations": {
12+
"**/snippets/*.json": "jsonc",
13+
"**/.vsts-ci/**/*.yml": "azure-pipelines",
14+
},
15+
"typescript.tsdk": "./node_modules/typescript/lib",
16+
"powershell.codeFormatting.autoCorrectAliases": true,
17+
"powershell.codeFormatting.newLineAfterCloseBrace": false,
18+
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
19+
"powershell.codeFormatting.useCorrectCasing": true,
20+
"powershell.codeFormatting.whitespaceBeforeOpenBrace": false,
21+
"powershell.codeFormatting.whitespaceBetweenParameters": true,
22+
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline"
23+
}
2424
}

package-lock.json

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-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",
@@ -65,6 +64,7 @@
6564
"@types/uuid": "~8.3.1",
6665
"@types/vscode": "~1.56.0",
6766
"@vscode/test-electron": "~1.6.2",
67+
"esbuild": "^0.12.25",
6868
"mocha": "~9.1.1",
6969
"mocha-junit-reporter": "~2.0.0",
7070
"mocha-multi-reporters": "~1.5.1",
@@ -78,9 +78,10 @@
7878
"extensionDependencies": [
7979
"vscode.powershell"
8080
],
81+
"main": "./out/main.js",
8182
"scripts": {
82-
"compile": "tsc -v && tsc -p ./ && tslint -p ./",
83-
"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",
8485
"test": "node ./out/test/runTests.js",
8586
"package": "vsce package --no-gitHubIssueLinking",
8687
"publish": "vsce publish"

src/features/Examples.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class ExamplesFeature implements vscode.Disposable {
99
private examplesPath: string;
1010

1111
constructor() {
12-
this.examplesPath = path.resolve(__dirname, "../../../examples");
12+
this.examplesPath = path.resolve(__dirname, "../../examples");
1313
this.command = vscode.commands.registerCommand("PowerShell.OpenExamplesFolder", () => {
1414
vscode.commands.executeCommand(
1515
"vscode.openFolder",

src/features/PesterTests.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class PesterTestsFeature implements vscode.Disposable {
1818
private invokePesterStubScriptPath: string;
1919

2020
constructor(private sessionManager: SessionManager) {
21-
this.invokePesterStubScriptPath = path.resolve(__dirname, "../../../modules/PowerShellEditorServices/InvokePesterStub.ps1");
21+
this.invokePesterStubScriptPath = path.resolve(__dirname, "../../modules/PowerShellEditorServices/InvokePesterStub.ps1");
2222

2323
// File context-menu command - Run Pester Tests
2424
this.command = vscode.commands.registerCommand(

src/logging.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class Logger implements ILogger {
4040
constructor() {
4141
this.logChannel = vscode.window.createOutputChannel("PowerShell Extension Logs");
4242

43-
this.logBasePath = path.resolve(__dirname, "../../logs");
43+
this.logBasePath = path.resolve(__dirname, "../logs");
4444
utils.ensurePathExists(this.logBasePath);
4545

4646
this.commands = [

src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { LanguageClientConsumer } from "./languageClientConsumer";
3636

3737
// The most reliable way to get the name and version of the current extension.
3838
// tslint:disable-next-line: no-var-requires
39-
const PackageJSON: any = require("../../package.json");
39+
const PackageJSON: any = require("../package.json");
4040

4141
// the application insights key (also known as instrumentation key) used for telemetry.
4242
const AI_KEY: string = "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217";
@@ -197,7 +197,7 @@ function checkForUpdatedVersion(context: vscode.ExtensionContext, version: strin
197197
if (choice === showReleaseNotes) {
198198
vscode.commands.executeCommand(
199199
"markdown.showPreview",
200-
vscode.Uri.file(path.resolve(__dirname, "../../CHANGELOG.md")));
200+
vscode.Uri.file(path.resolve(__dirname, "../CHANGELOG.md")));
201201
}
202202
});
203203
}

src/platform.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function getPlatformDetails(): IPlatformDetails {
4949
operatingSystem = OperatingSystem.Linux;
5050
}
5151

52-
const isProcess64Bit = process.arch === "x64";
52+
const isProcess64Bit = (process.arch === "x64" || process.arch === "arm64");
5353

5454
return {
5555
operatingSystem,

src/settings.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export function load(): ISettings {
157157

158158
const defaultDeveloperSettings: IDeveloperSettings = {
159159
featureFlags: [],
160-
bundledModulesPath: "../../../PowerShellEditorServices/module",
160+
bundledModulesPath: "../../PowerShellEditorServices/module",
161161
editorServicesLogLevel: "Normal",
162162
editorServicesWaitForDebugger: false,
163163
waitForSessionFileTimeoutSeconds: 240,
@@ -234,7 +234,7 @@ export function load(): ISettings {
234234
promptToUpdatePackageManagement:
235235
configuration.get<boolean>("promptToUpdatePackageManagement", true),
236236
bundledModulesPath:
237-
"../../modules",
237+
"../modules",
238238
useX86Host:
239239
configuration.get<boolean>("useX86Host", false),
240240
enableProfileLoading:

test/features/CustomViews.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ hello
7070
content: "console.log('asdf');",
7171
},
7272
{
73-
fileName: "../testCustomViews.js",
73+
fileName: "../../testCustomViews.js",
7474
content: "console.log('asdf');",
7575
},
7676
],
7777
cssFiles: [],
7878
expectedHtmlString: `<html><head></head><body>
7979
hello
8080
<script src="${convertToVSCodeResourceScheme(path.join(__dirname, "testCustomViews.js"))}"></script>
81-
<script src="${convertToVSCodeResourceScheme(path.join(__dirname, "../testCustomViews.js"))}"></script>
81+
<script src="${convertToVSCodeResourceScheme(path.join(__dirname, "../../testCustomViews.js"))}"></script>
8282
</body></html>`,
8383
},
8484

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)