From 85d8312fef66a5c95dab2ff675588f09bb54b43d Mon Sep 17 00:00:00 2001 From: Matthew Bastien Date: Wed, 9 Oct 2024 14:43:33 -0400 Subject: [PATCH 1/4] build the tests into dist/ alongside the source --- .vscode-test.js | 4 ++-- .vscode/launch.json | 3 +-- .vscode/settings.json | 4 ++-- .vscode/tasks.json | 5 ++--- package.json | 12 +++++------- tsconfig.json | 7 +++++-- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.vscode-test.js b/.vscode-test.js index 35afecdba..90afe6dc6 100644 --- a/.vscode-test.js +++ b/.vscode-test.js @@ -27,7 +27,7 @@ module.exports = defineConfig({ tests: [ { label: "integrationTests", - files: ["out/test/common.js", "out/test/integration-tests/**/*.test.js"], + files: ["dist/test/common.js", "dist/test/integration-tests/**/*.test.js"], version: process.env["VSCODE_VERSION"] ?? "stable", workspaceFolder: "./assets/test", launchArgs: [ @@ -50,7 +50,7 @@ module.exports = defineConfig({ }, { label: "unitTests", - files: ["out/test/common.js", "out/test/unit-tests/**/*.test.js"], + files: ["dist/test/common.js", "dist/test/unit-tests/**/*.test.js"], version: process.env["VSCODE_VERSION"] ?? "stable", launchArgs: [ "--disable-extensions", diff --git a/.vscode/launch.json b/.vscode/launch.json index 5e1219b61..f10b5ffcc 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -30,7 +30,6 @@ "--profile=testing-debug" ], "outFiles": [ - "${workspaceFolder}/out/**/*.js", "${workspaceFolder}/dist/**/*.js" ], "env": { @@ -45,7 +44,7 @@ "testConfiguration": "${workspaceFolder}/.vscode-test.js", "testConfigurationLabel": "unitTests", "outFiles": [ - "${workspaceFolder}/out/**/*.js" + "${workspaceFolder}/dist/**/*.js" ], "preLaunchTask": "compile-tests" } diff --git a/.vscode/settings.json b/.vscode/settings.json index 5c31c3df8..2ef8db44a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,10 @@ // Place your settings in this file to overwrite default and user settings. { "files.exclude": { - "out": false // set this to true to hide the "out" folder with the compiled JS files + "dist": false // set this to true to hide the "dist" folder with the compiled JS files }, "search.exclude": { - "out": true // set this to false to include "out" folder in search results + "dist": true // set this to false to include "dist" folder in search results }, // Turn off tsc task auto detection since we have the necessary tasks as npm scripts "typescript.tsc.autoDetect": "off", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index db015fca9..dc58f8390 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,9 +6,8 @@ { "label": "build", "type": "npm", - "script": "esbuild-watch", - "problemMatcher": "$esbuild-watch", - "isBackground": true, + "script": "esbuild", + "problemMatcher": "$esbuild", "presentation": { "reveal": "never" }, diff --git a/package.json b/package.json index cb7a99612..004a2ae89 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "workspaceContains:compile_commands.json", "onDebugResolve:swift-lldb" ], - "main": "./dist/extension.js", + "main": "./dist/src/extension.js", "contributes": { "icons": { "swift-icon": { @@ -1267,11 +1267,9 @@ ], "scripts": { "vscode:prepublish": "npm run esbuild-bundle", - "esbuild-base": "del-cli ./dist && esbuild \"./src/**/*.ts\" --outdir=dist --format=cjs --platform=node --target=node18", - "esbuild": "npm run esbuild-base", - "esbuild-watch": "npm run esbuild-base -- --watch", - "esbuild-bundle": "del-cli ./dist && esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node --target=node18 --minify --sourcemap", - "compile": "tsc", + "esbuild": "del-cli ./dist && esbuild \"./src/**/*.ts\" --outdir=dist/src --format=cjs --platform=node --target=node18 --sourcemap", + "esbuild-bundle": "del-cli ./dist && esbuild ./src/extension.ts --bundle --outfile=dist/src/extension.js --external:vscode --format=cjs --platform=node --target=node18 --minify --sourcemap", + "compile": "del-cli ./dist && tsc", "watch": "tsc --watch", "lint": "eslint ./ --ext ts && tsc --noEmit", "format": "prettier --check *.json src test", @@ -1283,7 +1281,7 @@ "integration-test": "npm test -- --label integrationTests", "unit-test": "npm test -- --label unitTests", "coverage": "npm test -- --coverage", - "compile-tests": "del-cli ./assets/test/**/.build && npm run compile && npm run esbuild", + "compile-tests": "del-cli ./assets/test/**/.build && npm run compile", "package": "vsce package", "dev-package": "vsce package --no-update-package-json 1.12.0-dev", "preview-package": "vsce package --pre-release", diff --git a/tsconfig.json b/tsconfig.json index d13fda314..a02db30f3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "target": "ES2020", - "outDir": "out", + "outDir": "dist", "lib": ["ES2020"], "sourceMap": true, "strict": true /* enable all strict type-checking options */ @@ -11,5 +11,8 @@ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ // "noUnusedParameters": true, /* Report errors on unused parameters. */ }, - "exclude": ["node_modules", ".vscode-test"] + "include": [ + "src/**/*.ts", + "test/**/*.ts" + ], } From 213199bb3ae2d727389f7f16ce01e96ad0aa5c8b Mon Sep 17 00:00:00 2001 From: Matthew Bastien Date: Wed, 9 Oct 2024 14:55:45 -0400 Subject: [PATCH 2/4] fix formatting errors --- tsconfig.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index a02db30f3..1f3f311c4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,8 +11,5 @@ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ // "noUnusedParameters": true, /* Report errors on unused parameters. */ }, - "include": [ - "src/**/*.ts", - "test/**/*.ts" - ], + "include": ["src/**/*.ts", "test/**/*.ts"] } From b7980000bf155fcf15db6d3632b362970dbe1a1a Mon Sep 17 00:00:00 2001 From: Matthew Bastien Date: Thu, 10 Oct 2024 13:43:59 -0400 Subject: [PATCH 3/4] use compile script instead of esbuild script for devopment builds of the extension --- .vscode/tasks.json | 5 +++-- package.json | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index dc58f8390..f852e361a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,11 +6,12 @@ { "label": "build", "type": "npm", - "script": "esbuild", - "problemMatcher": "$esbuild", + "script": "watch", + "problemMatcher": "$tsc-watch", "presentation": { "reveal": "never" }, + "isBackground": true, "group": { "kind": "build", "isDefault": true diff --git a/package.json b/package.json index 004a2ae89..0e50d54ed 100644 --- a/package.json +++ b/package.json @@ -1266,11 +1266,10 @@ "vadimcn.vscode-lldb" ], "scripts": { - "vscode:prepublish": "npm run esbuild-bundle", - "esbuild": "del-cli ./dist && esbuild \"./src/**/*.ts\" --outdir=dist/src --format=cjs --platform=node --target=node18 --sourcemap", - "esbuild-bundle": "del-cli ./dist && esbuild ./src/extension.ts --bundle --outfile=dist/src/extension.js --external:vscode --format=cjs --platform=node --target=node18 --minify --sourcemap", + "vscode:prepublish": "npm run bundle", + "bundle": "del-cli ./dist && esbuild ./src/extension.ts --bundle --outfile=dist/src/extension.js --external:vscode --format=cjs --platform=node --target=node18 --minify --sourcemap", "compile": "del-cli ./dist && tsc", - "watch": "tsc --watch", + "watch": "del-cli ./dist && tsc --watch", "lint": "eslint ./ --ext ts && tsc --noEmit", "format": "prettier --check *.json src test", "pretest": "npm run compile-tests", From 72a7bd45e28bac72d7459d63a4bdadd02c04b44c Mon Sep 17 00:00:00 2001 From: Matthew Bastien Date: Thu, 10 Oct 2024 13:44:23 -0400 Subject: [PATCH 4/4] remove esbuild-problem-matchers from recommended extensions --- .vscode/extensions.json | 1 - CONTRIBUTING.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 539d83104..e680869ad 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -2,7 +2,6 @@ // See http://go.microsoft.com/fwlink/?LinkId=827846 // for the documentation about the extensions.json format "recommendations": [ - "connor4312.esbuild-problem-matchers", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode" ] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a9eedcc5..a6bc91dbf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,7 +28,7 @@ nvm install npm install ``` -When you first open the project in VS Code you will be recommended to also install [`ESLint`](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint), [`Prettier - Code formatter`](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) and [`esbuild Problem Matchers`](https://marketplace.visualstudio.com/items?itemName=connor4312.esbuild-problem-matchers). Please do so. `ESLint`, `Prettier - Code formatter` is used to ensure a consistent style and we expect everyone who contributes to follow this style as well. `esbuild Problem Matchers` provides proper error output from building the project. +When you first open the project in VS Code you will be recommended to also install [`ESLint`](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and [`Prettier - Code formatter`](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode). Please do so. `ESLint`, `Prettier - Code formatter` is used to ensure a consistent style and we expect everyone who contributes to follow this style as well. To run your version of the Swift extension while in VS Code, press `F5`. This will open up another instance of VS Code with it running. You can use the original version of VS Code to debug it.