Skip to content

Bundle the extension #3555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/out/src/**/*.js"
],
"outFiles": [ "${workspaceFolder}/out/main.js" ],
"preLaunchTask": "Build"
},
{
Expand All @@ -22,15 +20,15 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extensions",
"ms-vscode.powershell-preview",
// The tests require Code be opened with a workspace, which exists in
// `test`, but this has to be passed as a CLI argument, not just `cwd`.
"${workspaceFolder}/test",
"--disableExtensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/testRunner.js",
"${workspaceFolder}/test"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
"--extensionTestsPath=${workspaceFolder}/out/test/index.js",
],
"sourceMaps": true,
"outFiles": [ "${workspaceFolder}/out/test/**/*.js" ],
"preLaunchTask": "Build"
},
{
Expand Down
43 changes: 23 additions & 20 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
.vscode/**
.vscode-test/**
vscode-powershell.build.ps1
typings/**
**/*.ts
.github/
.poshchan/
.vscode/
.vscode-test/
.vsts-ci/
logs/
node_modules/
out/
scripts/
sessions/
src/
test/
tools/

!out/main.js

.editorconfig
.gitattributes
.gitignore
tsconfig.json
build/**
bin/EditorServices.log
bin/DebugAdapter.log
bin/*.vshost.*
bin/PowerShell/**
logs/**
out/test/**
test/**
sessions/**
scripts/Install-VSCode.ps1
tools/**
.poshchan/**
.github/**
.vsts-ci/**
.markdownlint.json
.vscodeignore
build.ps1
extension-dev.code-workspace
*.vsix
tsconfig.json
tslint.json
vscode-powershell.build.ps1
28 changes: 14 additions & 14 deletions extension-dev.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
"path": "../PowerShellEditorServices"
}
],
"settings": {
"files.associations": {
"**/snippets/*.json": "jsonc",
"**/.vsts-ci/**/*.yml": "azure-pipelines",
},
"typescript.tsdk": "./node_modules/typescript/lib",
"powershell.codeFormatting.autoCorrectAliases": true,
"powershell.codeFormatting.newLineAfterCloseBrace": false,
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
"powershell.codeFormatting.useCorrectCasing": true,
"powershell.codeFormatting.whitespaceBeforeOpenBrace": false,
"powershell.codeFormatting.whitespaceBetweenParameters": true,
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline"
}
"settings": {
"files.associations": {
"**/snippets/*.json": "jsonc",
"**/.vsts-ci/**/*.yml": "azure-pipelines",
},
"typescript.tsdk": "./node_modules/typescript/lib",
"powershell.codeFormatting.autoCorrectAliases": true,
"powershell.codeFormatting.newLineAfterCloseBrace": false,
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
"powershell.codeFormatting.useCorrectCasing": true,
"powershell.codeFormatting.whitespaceBeforeOpenBrace": false,
"powershell.codeFormatting.whitespaceBetweenParameters": true,
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline"
}
}
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"type": "git",
"url": "https://github.com/PowerShell/vscode-powershell.git"
},
"main": "./out/src/main",
"activationEvents": [
"onDebugInitialConfigurations",
"onDebugResolve:PowerShell",
Expand Down Expand Up @@ -65,6 +64,7 @@
"@types/uuid": "~8.3.1",
"@types/vscode": "~1.56.0",
"@vscode/test-electron": "~1.6.2",
"esbuild": "^0.12.25",
"mocha": "~9.1.1",
"mocha-junit-reporter": "~2.0.0",
"mocha-multi-reporters": "~1.5.1",
Expand All @@ -78,9 +78,10 @@
"extensionDependencies": [
"vscode.powershell"
],
"main": "./out/main.js",
"scripts": {
"compile": "tsc -v && tsc -p ./ && tslint -p ./",
"compile-watch": "tsc -watch -p ./",
"lint": "tslint --project tsconfig.json",
"build": "tsc --project tsconfig.json && esbuild ./src/main.ts --outdir=out --sourcemap --bundle --minify --external:vscode --platform=node",
"test": "node ./out/test/runTests.js",
"package": "vsce package --no-gitHubIssueLinking",
"publish": "vsce publish"
Expand Down
2 changes: 1 addition & 1 deletion src/features/Examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class ExamplesFeature implements vscode.Disposable {
private examplesPath: string;

constructor() {
this.examplesPath = path.resolve(__dirname, "../../../examples");
this.examplesPath = path.resolve(__dirname, "../../examples");
this.command = vscode.commands.registerCommand("PowerShell.OpenExamplesFolder", () => {
vscode.commands.executeCommand(
"vscode.openFolder",
Expand Down
2 changes: 1 addition & 1 deletion src/features/PesterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class PesterTestsFeature implements vscode.Disposable {
private invokePesterStubScriptPath: string;

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

// File context-menu command - Run Pester Tests
this.command = vscode.commands.registerCommand(
Expand Down
2 changes: 1 addition & 1 deletion src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Logger implements ILogger {
constructor() {
this.logChannel = vscode.window.createOutputChannel("PowerShell Extension Logs");

this.logBasePath = path.resolve(__dirname, "../../logs");
this.logBasePath = path.resolve(__dirname, "../logs");
utils.ensurePathExists(this.logBasePath);

this.commands = [
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { LanguageClientConsumer } from "./languageClientConsumer";

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

// the application insights key (also known as instrumentation key) used for telemetry.
const AI_KEY: string = "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217";
Expand Down Expand Up @@ -197,7 +197,7 @@ function checkForUpdatedVersion(context: vscode.ExtensionContext, version: strin
if (choice === showReleaseNotes) {
vscode.commands.executeCommand(
"markdown.showPreview",
vscode.Uri.file(path.resolve(__dirname, "../../CHANGELOG.md")));
vscode.Uri.file(path.resolve(__dirname, "../CHANGELOG.md")));
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function getPlatformDetails(): IPlatformDetails {
operatingSystem = OperatingSystem.Linux;
}

const isProcess64Bit = process.arch === "x64";
const isProcess64Bit = (process.arch === "x64" || process.arch === "arm64");

return {
operatingSystem,
Expand Down
4 changes: 2 additions & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function load(): ISettings {

const defaultDeveloperSettings: IDeveloperSettings = {
featureFlags: [],
bundledModulesPath: "../../../PowerShellEditorServices/module",
bundledModulesPath: "../../PowerShellEditorServices/module",
editorServicesLogLevel: "Normal",
editorServicesWaitForDebugger: false,
waitForSessionFileTimeoutSeconds: 240,
Expand Down Expand Up @@ -234,7 +234,7 @@ export function load(): ISettings {
promptToUpdatePackageManagement:
configuration.get<boolean>("promptToUpdatePackageManagement", true),
bundledModulesPath:
"../../modules",
"../modules",
useX86Host:
configuration.get<boolean>("useX86Host", false),
enableProfileLoading:
Expand Down
4 changes: 2 additions & 2 deletions test/features/CustomViews.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ hello
content: "console.log('asdf');",
},
{
fileName: "../testCustomViews.js",
fileName: "../../testCustomViews.js",
content: "console.log('asdf');",
},
],
cssFiles: [],
expectedHtmlString: `<html><head></head><body>
hello
<script src="${convertToVSCodeResourceScheme(path.join(__dirname, "testCustomViews.js"))}"></script>
<script src="${convertToVSCodeResourceScheme(path.join(__dirname, "../testCustomViews.js"))}"></script>
<script src="${convertToVSCodeResourceScheme(path.join(__dirname, "../../testCustomViews.js"))}"></script>
</body></html>`,
},

Expand Down
30 changes: 16 additions & 14 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"compilerOptions": {
"rootDir": ".",
"module": "commonjs",
"target": "es6",
"outDir": "out",
"lib": [
"es2017",
"DOM"
],
"sourceMap": true
},
"exclude": [
"node_modules"
]
"compilerOptions": {
// NOTE: The TypeScript compiler is only used for building the tests (and
// the sources which the tests need). The extension is built with `esbuild`.
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file configure the typescript compiler rather than esbuild?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, T(ype)S(cript)config.json. While esbuild supports transpiling typescript to javascript, it does not do any sort of type checking etc., and it also will only produce a bundled file. So we still need tsc around to type-check the sources and transpile the test code.

"module": "commonjs",
"outDir": "out",
"target": "ES6",
"lib": [ "ES6", "DOM" ],
"sourceMap": true,
"rootDir": ".",
// TODO: We need to enable stricter checking...
// "strict": true,
// "noImplicitReturns": true,
// "noFallthroughCasesInSwitch": true,
// "noUnusedParameters": true
},
"include": [ "src", "test" ],
}
12 changes: 11 additions & 1 deletion vscode-powershell.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,17 @@ task CopyEditorServices -If { !(Test-Path ./modules/PowerShellEditorServices) -a

task Build CopyEditorServices, Restore, {
Write-Host "`n### Building vscode-powershell" -ForegroundColor Green
exec { & npm run compile }
# TODO: TSLint is deprecated and we need to switch to ESLint.
# https://github.com/PowerShell/vscode-powershell/pull/3331
exec { & npm run lint }

# TODO: When supported we should use `esbuild` for the tests too. Although
# we now use `esbuild` to transpile, bundle, and minify the extension, we
# still use `tsc` to transpile everything in `src` and `test` because the VS
# Code test runner expects individual files (and globs them at runtime).
# Unfortunately `esbuild` doesn't support emitting 1:1 files (yet).
# https://github.com/evanw/esbuild/issues/944
exec { & npm run build }
}

#endregion
Expand Down