Skip to content

Commit 4cf250c

Browse files
authored
👷 CI and Build Updates (#204)
* 🧪 Implement SWC transpilation for testing and switch to pkgroll for builds * Switch to rollup * 👷 Update Build Tools, Rollup/Prettier/PNPM/VSCode * Fix build/package step
1 parent 0baee99 commit 4cf250c

18 files changed

Lines changed: 1235 additions & 832 deletions

.eslintignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
vscode.d.ts
2-
vscode.proposed.d.ts
2+
vscode.proposed.d.ts
3+
dist
4+
node_modules
5+
.vscode-test

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ jobs:
4949
"calendarVersion=$version" >> $ENV:GITHUB_OUTPUT
5050
"semanticVersion=$version" >> $ENV:GITHUB_OUTPUT
5151
52-
- name: 👷‍♂️ Build
52+
- name: 👷‍♂️ Build and Package
5353
run: |
54-
pnpm run build ${{steps.version.outputs.version}}
54+
pnpm package ${{steps.version.outputs.version}}
5555
5656
- name: ⬆ Artifact
5757
uses: actions/upload-artifact@v3

.mocharc.json

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
{
22
"$schema": "https://json.schemastore.org/mocharc",
3+
"spec": "**/*.test.ts",
4+
"extension": [
5+
"ts",
6+
"cts",
7+
"mts"
8+
],
9+
"require": [
10+
"@swc-node/register"
11+
],
12+
"ui": "bdd",
13+
"exit": true,
14+
"failZero": true,
315
"color": true,
416
"enable-source-maps": true,
5-
"extensions": [
6-
".js",
7-
".jsx"
8-
],
9-
"require": "source-map-support/register",
1017
"timeout": 10000,
11-
"spec": "dist/**/*.test.js",
12-
"ui": "bdd"
18+
"ignore": [
19+
"**/*.vscode.test.ts"
20+
],
21+
"grep": "vscode-e2e",
22+
"invert": true
1323
}

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
use-node-version=18.15.0
2+
engine-strict=true

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ dist
22
node_modules
33
package.json
44
package-lock.json
5+
pnpm-lock.yaml
6+
.vscode-test

.vscode/launch.json

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,20 @@
1818
"env": {
1919
"VSCODE_DEBUG_MODE": "true"
2020
},
21-
"outFiles": [
22-
"${workspaceFolder}/dist/**/*.js"
23-
],
21+
"presentation": {
22+
"group": "_build"
23+
},
24+
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
2425
"sourceMaps": true,
2526
"autoAttachChildProcesses": true,
26-
"skipFiles": [
27-
"<node_internals>/**",
28-
"**/extensionHostProcess.js",
29-
"**/.vscode/extensions/**"
30-
],
27+
"skipFiles": ["<node_internals>/**", "**/extensionHostProcess.js", "**/.vscode/extensions/**"],
3128
"showAsyncStacks": true,
3229
"smartStep": true,
3330
"preLaunchTask": "build-watch"
3431
},
3532
{
3633
"name": "Run Extension Multi-Root Workspace",
37-
"type": "extensionHost",
34+
"type": "extensionHost",
3835
"request": "launch",
3936
"args": [
4037
"--extensionDevelopmentPath=${workspaceFolder}",
@@ -45,41 +42,37 @@
4542
"env": {
4643
"VSCODE_DEBUG_MODE": "true"
4744
},
48-
"outFiles": [
49-
"${workspaceFolder}/dist/**/*.js"
50-
],
45+
"presentation": {
46+
"group": "_build"
47+
},
48+
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
5149
"sourceMaps": true,
5250
"autoAttachChildProcesses": true,
53-
"skipFiles": [
54-
"<node_internals>/**",
55-
"**/extensionHostProcess.js",
56-
"**/.vscode/extensions/**"
57-
],
51+
"skipFiles": ["<node_internals>/**", "**/extensionHostProcess.js", "**/.vscode/extensions/**"],
5852
"showAsyncStacks": true,
5953
"smartStep": true,
6054
"preLaunchTask": "build-watch"
6155
},
62-
{
63-
"name": "Test Extension",
64-
"type": "node",
65-
"request": "launch",
66-
"program": "${workspaceFolder}/dist/test/runTests.js",
56+
{
57+
"name": "Test Extension",
58+
"type": "node",
59+
"request": "launch",
60+
"program": "${workspaceFolder}/test/runTests.ts",
61+
"runtimeArgs": ["-r", "@swc-node/register"],
6762
"sourceMaps": true,
68-
"outFiles": [
69-
"${workspaceFolder}/dist/**/*.js"
70-
],
63+
"resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**", "!**/.vscode-test/**"],
7164
"smartStep": true,
72-
"attachSimplePort": 59229, // The default is 9229 but we want to avoid conflicts because we will have two vscode instances running.
73-
"env": {
74-
"__TEST_DEBUG_INSPECT_PORT": "59229" // Needs to match attachSimplePort
75-
},
76-
"presentation": {
77-
"hidden": false,
78-
},
79-
"internalConsoleOptions": "neverOpen",
80-
"console": "integratedTerminal",
81-
"autoAttachChildProcesses": false,
82-
"preLaunchTask": "test-watch"
83-
}
65+
"attachSimplePort": 59229, // The default is 9229 but we want to avoid conflicts because we will have two vscode instances running.
66+
"env": {
67+
"__TEST_DEBUG_INSPECT_PORT": "59229" // Needs to match attachSimplePort
68+
},
69+
"presentation": {
70+
"hidden": false,
71+
"group": "_test"
72+
},
73+
"internalConsoleOptions": "neverOpen",
74+
"console": "integratedTerminal",
75+
"autoAttachChildProcesses": false
76+
}
8477
]
8578
}

.vscode/settings.json

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
{
22
"github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"],
33
"editor.detectIndentation": false,
4-
"pester.testFilePath": [
5-
"Scripts/PesterInterface.[tT]ests.[pP][sS]1"
6-
],
4+
"pester.testFilePath": ["Scripts/PesterInterface.[tT]ests.[pP][sS]1"],
75
"typescript.format.semicolons": "remove", // Some actions ignore ESLint
86
"[typescript]": {
97
"editor.defaultFormatter": "vscode.typescript-language-features"
108
},
11-
"mochaExplorer.configFile": ".mocharc.json",
12-
"mochaExplorer.launcherScript": "dist/test/runTests",
13-
"mochaExplorer.autoload": false, // The test instance pops up every time discovery or run is done, this could be annoying on startup.
14-
"mochaExplorer.debuggerPort": 59229, // Matches the launch config, we dont want to use the default port as we are launching a duplicate instance of vscode and it might conflict.
15-
"mochaExplorer.ipcRole": "server",
16-
"mochaExplorer.ipcTimeout": 10000,
17-
"mochaExplorer.debuggerConfig": "Test Extension",
18-
"testExplorer.useNativeTesting": true,
19-
"mochaExplorer.env": {
20-
"VSCODE_VERSION": "insiders",
21-
"ELECTRON_RUN_AS_NODE": null
22-
},
9+
"mochaExplorer.configFile": ".mocharc.json",
10+
"mochaExplorer.logpanel": true,
11+
"testExplorer.useNativeTesting": true,
12+
"mochaExplorer.env": {
13+
"VSCODE_VERSION": "insiders",
14+
"ELECTRON_RUN_AS_NODE": null
15+
}
2316
}

.vscode/tasks.json

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,71 @@
11
{
22
"version": "2.0.0",
33
"tasks": [
4-
{
5-
"label": "test-watch",
6-
"icon": {
7-
"color": "terminal.ansiCyan",
8-
"id": "sync"
9-
},
10-
"type": "npm",
11-
"script": "build-test-watch",
12-
"group": "test",
13-
"problemMatcher": "$tsc-watch",
14-
"isBackground": true,
15-
"dependsOn": "build-watch" // We need to also build main.js extension for testing or it leads to sourcemap errors
16-
},
17-
{
18-
"label": "build-watch",
19-
"icon": {
20-
"color": "terminal.ansiCyan",
21-
"id": "sync"
22-
},
23-
"type": "npm",
24-
"script": "build-watch",
25-
"group": "build",
26-
"problemMatcher": "$esbuild-watch",
27-
"isBackground": true,
28-
}
29-
]
4+
{
5+
"label": "build-watch",
6+
"icon": {
7+
"color": "terminal.ansiBlue",
8+
"id": "sync"
9+
},
10+
"type": "npm",
11+
"script": "build-watch",
12+
"group": "build",
13+
"problemMatcher": {
14+
"owner": "typescript",
15+
"source": "rollup",
16+
"pattern": {
17+
"regexp": "^(.*):(\\d+):(\\d+) - (error|warning) TS(\\d+): (.*)$",
18+
"file": 1,
19+
"line": 2,
20+
"column": 3,
21+
"severity": 4,
22+
"code": 5,
23+
"message": 6
24+
},
25+
"severity": "info",
26+
"fileLocation": ["relative", "${workspaceFolder}"],
27+
"background": {
28+
"activeOnStart": true,
29+
"beginsPattern": "^rollup v\\d+\\.\\d+\\.\\d+$",
30+
"endsPattern": {
31+
"regexp": "^\\[[:-\\s\\d]+\\] waiting for changes\\.\\.\\.$"
32+
}
33+
}
34+
},
35+
"isBackground": true
36+
},
37+
{
38+
"label": "test-watch",
39+
"icon": {
40+
"color": "terminal.ansiCyan",
41+
"id": "sync"
42+
},
43+
"type": "npm",
44+
"script": "test-watch",
45+
"group": "test",
46+
"problemMatcher": {
47+
"owner": "typescript",
48+
"source": "mocha",
49+
"pattern": {
50+
"regexp": "^(.*):(\\d+):(\\d+) - (error|warning) TS(\\d+): (.*)$",
51+
"file": 1,
52+
"line": 2,
53+
"column": 3,
54+
"severity": 4,
55+
"code": 5,
56+
"message": 6
57+
},
58+
"severity": "info",
59+
"fileLocation": ["relative", "${workspaceFolder}"],
60+
"background": {
61+
"activeOnStart": true,
62+
"beginsPattern": " ",
63+
"endsPattern": {
64+
"regexp": "^ℹ \\[mocha\\] waiting for changes...$"
65+
}
66+
}
67+
},
68+
"isBackground": true
69+
}
70+
]
3071
}

package.json

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,25 @@
8686
],
8787
"main": "./dist/extension.js",
8888
"devDependencies": {
89+
"@rollup/plugin-commonjs": "^25.0.5",
90+
"@rollup/plugin-node-resolve": "^15.2.3",
91+
"@rollup/plugin-swc": "^0.2.1",
92+
"@rollup/plugin-terser": "^0.4.4",
93+
"@swc-node/register": "^1.6.8",
8994
"@types/chai": "^4.3.5",
9095
"@types/debounce-promise": "^3.1.6",
9196
"@types/glob": "^8.1.0",
9297
"@types/json-parse-safe": "^2.0.0",
9398
"@types/mocha": "^10.0.1",
94-
"@types/node": "^16.18.39",
99+
"@types/node": "^18.15.0",
95100
"@types/readline-transform": "^1.0.1",
96101
"@typescript-eslint/eslint-plugin": "^5.62.0",
97102
"@typescript-eslint/parser": "^5.62.0",
98103
"@vscode/dts": "^0.4.0",
99-
"@vscode/test-electron": "^2.3.3",
104+
"@vscode/test-electron": "^2.3.5",
100105
"@vscode/vsce": "^2.19.0",
101106
"chai": "^4.3.7",
107+
"debounce-promise": "^3.1.2",
102108
"esbuild": "^0.18.16",
103109
"eslint": "^8.45.0",
104110
"eslint-config-prettier": "^8.8.0",
@@ -107,25 +113,21 @@
107113
"eslint-plugin-n": "^15.7.0",
108114
"eslint-plugin-promise": "^6.1.1",
109115
"glob": "^10.3.3",
116+
"json-parse-safe": "^2.0.0",
117+
"lookpath": "^1.2.2",
110118
"mocha": "^10.2.0",
111119
"mocha-multi-reporters": "^1.5.1",
120+
"path": "^0.12.7",
121+
"pkgroll": "^2.0.1",
112122
"prettier": "^2.8.8",
113123
"prettier-eslint": "^15.0.1",
124+
"readline-transform": "^1.0.0",
125+
"rollup": "^3.29.4",
114126
"sinon": "^15.2.0",
115-
"source-map-support": "^0.5.21",
116-
"tsx": "^3.12.7",
127+
"tslog": "^4.9.2",
117128
"typescript": "^5.1.6",
118129
"utility-types": "^3.10.0"
119130
},
120-
"dependencies": {
121-
"@ctiterm/strip-ansi": "^1.0.0",
122-
"debounce-promise": "^3.1.2",
123-
"json-parse-safe": "^2.0.0",
124-
"lookpath": "^1.2.2",
125-
"path": "^0.12.7",
126-
"readline-transform": "^1.0.0",
127-
"tslog": "^4.8.2"
128-
},
129131
"extensionDependencies": [
130132
"ms-vscode.powershell"
131133
],
@@ -143,18 +145,25 @@
143145
}
144146
],
145147
"scripts": {
146-
"esbuild-base": "esbuild --format=cjs --platform=node --bundle --outdir=dist --external:vscode --external:@vscode/test-electron extension=src/extension.ts --metafile=dist/esbuild.json --sourcemap",
147-
"build": "vsce package --no-update-package-json --no-git-tag-version --no-dependencies",
148+
"package": "vsce package --no-update-package-json --no-git-tag-version --no-dependencies",
148149
"publish": "pnpm run publishStable --pre-release --no-git-tag-version",
149150
"publishStable": "vsce publish --no-update-package-json --no-dependencies",
150-
"tsc": "tsc",
151-
"build-watch": "pnpm run esbuild-base --watch",
152-
"build-test-watch": "pnpm run tsc --incremental --watch",
153-
"lint": "prettier --check .",
154-
"test-powershell": "mocha --exit -b dist/src/**/*.test.js",
155-
"test": "node ./dist/test/RunTests.js",
151+
"build": "rollup --config",
152+
"build-watch": "pnpm run build --watch",
153+
"lint-eslint": "eslint . --ext .ts",
154+
"lint-prettier": "prettier --check .",
155+
"lint-tsc": "tsc --noemit",
156+
"lint": "pnpm lint-eslint || pnpm lint-prettier || pnpm lint-tsc",
157+
"test-mocha": "mocha",
158+
"test-mocha-vscode": "node -r @swc-node/register test/runTests.ts",
159+
"test": "pnpm test-mocha && pnpm test-mocha-vscode",
160+
"test-watch": "pnpm test-mocha --watch",
156161
"download-api": "vscode-dts main",
157162
"postdownload-api": "vscode-dts main",
158-
"vscode:prepublish": "pnpm run esbuild-base --minify"
163+
"vscode:prepublish": "pnpm run build"
164+
},
165+
"dependencies": {
166+
"@ctiterm/strip-ansi": "^1.0.0",
167+
"@swc/core": "^1.3.92"
159168
}
160169
}

0 commit comments

Comments
 (0)