Skip to content

Commit 9cea730

Browse files
committed
WIP: Enable bundling of extension with esbuild
Tests aren't setup yet.
1 parent b5353cc commit 9cea730

16 files changed

+45
-41
lines changed

.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

+5-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"type": "git",
2626
"url": "https://github.com/PowerShell/vscode-powershell.git"
2727
},
28-
"main": "./out/src/main",
28+
"main": "./out/main.js",
2929
"activationEvents": [
3030
"onDebugInitialConfigurations",
3131
"onDebugResolve:PowerShell",
@@ -80,11 +80,12 @@
8080
"vscode.powershell"
8181
],
8282
"scripts": {
83-
"compile": "tsc -v && tsc -p ./ && tslint -p ./",
84-
"compile-watch": "tsc -watch -p ./",
83+
"esbuild-base": "esbuild ./src/main.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node",
84+
"build": "npm run esbuild-base -- --sourcemap",
8585
"test": "node ./out/test/runTests.js",
8686
"package": "vsce package --no-gitHubIssueLinking",
87-
"publish": "vsce publish"
87+
"publish": "vsce publish",
88+
"vscode:prepublish": "npm run esbuild-base -- --minify"
8889
},
8990
"contributes": {
9091
"breakpoints": [

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/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/core/platform.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import mockFS = require("mock-fs");
66
import FileSystem = require("mock-fs/lib/filesystem");
77
import * as path from "path";
88
import * as sinon from "sinon";
9-
import * as platform from "../../src/platform";
9+
import * as platform from "../src/platform";
1010

1111
/**
1212
* Describes a platform on which the PowerShell extension should work,

test/core/settings.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import * as assert from "assert";
55
import * as vscode from "vscode";
6-
import Settings = require("../../src/settings");
6+
import Settings = require("../src/settings");
77

88
suite("Settings module", () => {
99
test("Settings load without error", () => {

test/features/CustomViews.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import rewire = require("rewire");
88
import vscode = require("vscode");
99

1010
// Setup types that are not exported.
11-
const customViews = rewire("../../src/features/CustomViews");
11+
const customViews = rewire("../src/features/CustomViews");
1212
const htmlContentViewClass = customViews.__get__("HtmlContentView");
1313
const HtmlContentView: typeof htmlContentViewClass = htmlContentViewClass;
1414

test/features/ExternalApi.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import * as assert from "assert";
55
import * as vscode from "vscode";
66
import { before, beforeEach, afterEach } from "mocha";
7-
import { IExternalPowerShellDetails, IPowerShellExtensionClient } from "../../src/features/ExternalApi";
7+
import { IExternalPowerShellDetails, IPowerShellExtensionClient } from "../src/features/ExternalApi";
88

99
// tslint:disable-next-line: no-var-requires
10-
const PackageJSON: any = require("../../../package.json");
10+
const PackageJSON: any = require("../../package.json");
1111
const testExtensionId = `${PackageJSON.publisher}.${PackageJSON.name}`;
1212

1313
suite("ExternalApi feature - Registration API", () => {

test/features/ISECompatibility.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import * as assert from "assert";
55
import * as vscode from "vscode";
6-
import { ISECompatibilityFeature } from "../../src/features/ISECompatibility";
6+
import { ISECompatibilityFeature } from "../src/features/ISECompatibility";
77

88
suite("ISECompatibility feature", () => {
99
test("It sets ISE Settings", async () => {

test/features/RunCode.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import rewire = require("rewire");
66
import vscode = require("vscode");
77

88
// Setup function that is not exported.
9-
const customViews = rewire("../../src/features/RunCode");
9+
const customViews = rewire("../src/features/RunCode");
1010
const createLaunchConfig = customViews.__get__("createLaunchConfig");
1111

1212
enum LaunchType {

test/features/UpdatePowerShell.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
import * as assert from "assert";
5-
import { GitHubReleaseInformation } from "../../src/features/UpdatePowerShell";
5+
import { GitHubReleaseInformation } from "../src/features/UpdatePowerShell";
66

77
// Due to Azure DevOps using the same macOS instances, the macOS builds hit
88
// the GitHub API rate limit often. Let's skip these tests on macOS until

test/runTests.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function main() {
1212
try {
1313
// The folder containing the Extension Manifest package.json
1414
// Passed to `--extensionDevelopmentPath`
15-
const extensionDevelopmentPath = path.resolve(__dirname, "../../");
15+
const extensionDevelopmentPath = path.resolve(__dirname, "../");
1616

1717
// The path to the extension test script
1818
// Passed to --extensionTestsPath

vscode-powershell.build.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ 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+
exec { & npm run build }
6868
}
6969

7070
#endregion

0 commit comments

Comments
 (0)