Skip to content

Commit 55f5e1f

Browse files
Ievgenii.MykhalevskyiIevgenii.Mykhalevskyi
Ievgenii.Mykhalevskyi
authored and
Ievgenii.Mykhalevskyi
committed
made a single package for releases which optimises the speed of execution of extension
1 parent 8709de4 commit 55f5e1f

File tree

9 files changed

+136
-28
lines changed

9 files changed

+136
-28
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"ignorePatterns": [
2727
"out",
2828
"dist",
29-
"**/*.d.ts"
29+
"**/*.d.ts",
30+
"esbuild.js"
3031
]
3132
}

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"--extensionDevelopmentPath=${workspaceFolder}"
1414
],
1515
"outFiles": [
16-
"${workspaceFolder}/out/**/*.js"
16+
"${workspaceFolder}/dist/**/*.js"
1717
],
1818
"preLaunchTask": "${defaultBuildTask}"
1919
},

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"cSpell.words": [
2727
"appletvsimulator",
2828
"autowatcher",
29+
"connor",
2930
"Debuggee",
3031
"devicectl",
3132
"disasm",

.vscode/tasks.json

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
11
// See https://go.microsoft.com/fwlink/?LinkId=733558
22
// for the documentation about the tasks.json format
33
{
4-
"version": "2.0.0",
5-
"tasks": [
6-
{
7-
"type": "npm",
8-
"script": "watch",
9-
"problemMatcher": "$tsc-watch",
10-
"isBackground": true,
11-
"presentation": {
12-
"reveal": "never"
13-
},
14-
"group": {
15-
"kind": "build",
16-
"isDefault": true
17-
}
18-
}
19-
]
20-
}
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "watch",
8+
"dependsOn": [
9+
"npm: watch:tsc",
10+
"npm: watch:esbuild"
11+
],
12+
"presentation": {
13+
"reveal": "never"
14+
},
15+
"group": {
16+
"kind": "build",
17+
"isDefault": true
18+
}
19+
},
20+
{
21+
"type": "npm",
22+
"script": "watch:esbuild",
23+
"group": "build",
24+
"problemMatcher": "$esbuild-watch",
25+
"isBackground": true,
26+
"label": "npm: watch:esbuild",
27+
"presentation": {
28+
"group": "watch",
29+
"reveal": "never"
30+
}
31+
},
32+
{
33+
"type": "npm",
34+
"script": "watch:tsc",
35+
"group": "build",
36+
"problemMatcher": "$tsc-watch",
37+
"isBackground": true,
38+
"label": "npm: watch:tsc",
39+
"presentation": {
40+
"group": "watch",
41+
"reveal": "never"
42+
}
43+
}
44+
]
45+
}

.vscodeignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,16 @@
33
.vscode
44
build
55
**/__pycache__
6+
node_modules
7+
out
8+
src
9+
!src/XCBBuildServiceProxy/dist
10+
dist/extension.js.map
11+
esbuild.js
12+
Gemfile
13+
Gemfile.lock
14+
make.sh
15+
tsconfig.json
16+
sourcekit_build.sh
17+
test
18+
HOW_TO_BUILD.md

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## 0.5.4 - 2024-11-11
4+
5+
### Added
6+
7+
- Release an extension as a single bundle which increases the speed of js code execution
8+
39
## 0.5.4 - 2024-11-8
410

511
### Added

esbuild.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const esbuild = require("esbuild");
2+
3+
const production = process.argv.includes("--production");
4+
const watch = process.argv.includes("--watch");
5+
6+
async function main() {
7+
const ctx = await esbuild.context({
8+
entryPoints: ["src/extension.ts"],
9+
bundle: true,
10+
format: "cjs",
11+
minify: production,
12+
sourcemap: !production,
13+
sourcesContent: false,
14+
platform: "node",
15+
outfile: "dist/extension.js",
16+
external: ["vscode"],
17+
logLevel: "silent",
18+
plugins: [
19+
/* add to the end of plugins array */
20+
esbuildProblemMatcherPlugin,
21+
],
22+
});
23+
if (watch) {
24+
await ctx.watch();
25+
} else {
26+
await ctx.rebuild();
27+
await ctx.dispose();
28+
}
29+
}
30+
31+
/**
32+
* @type {import('esbuild').Plugin}
33+
*/
34+
const esbuildProblemMatcherPlugin = {
35+
name: "esbuild-problem-matcher",
36+
37+
setup(build) {
38+
build.onStart(() => {
39+
console.log("[watch] build started");
40+
});
41+
build.onEnd(result => {
42+
result.errors.forEach(({ text, location }) => {
43+
console.error(`✘ [ERROR] ${text}`);
44+
console.error(` ${location.file}:${location.line}:${location.column}:`);
45+
});
46+
console.log("[watch] build finished");
47+
});
48+
},
49+
};
50+
51+
main().catch(e => {
52+
console.error(e);
53+
process.exit(1);
54+
});

package.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
"test",
4343
"coverage"
4444
],
45+
"recommendation": [
46+
"connor4312.esbuild-problem-matchers"
47+
],
4548
"version": "0.5.5",
4649
"os": [
4750
"darwin"
@@ -60,7 +63,7 @@
6063
"workspaceContains:**/*.xcodeproj/project.pbxproj",
6164
"onDebugResolve:xcode-lldb"
6265
],
63-
"main": "./out/src/extension.js",
66+
"main": "./dist/extension.js",
6467
"repository": {
6568
"url": "https://github.com/fireplusteam/ios_vs_code.git"
6669
},
@@ -433,10 +436,13 @@
433436
"ms-python.debugpy"
434437
],
435438
"scripts": {
436-
"vscode:prepublish": "npm run compile",
437-
"compile": "tsc -p ./",
438-
"watch": "tsc -watch -p ./",
439-
"pretest": "npm run compile",
439+
"compile": "npm run check-types && node esbuild.js",
440+
"check-types": "tsc --noEmit",
441+
"watch": "npm-run-all -p watch:*",
442+
"watch:esbuild": "node esbuild.js --watch",
443+
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
444+
"vscode:prepublish": "npm run package",
445+
"package": "npm run check-types && node esbuild.js --production",
440446
"test": "vscode-test",
441447
"lint": "eslint ./ --ext ts && tsc --noEmit",
442448
"lint:fix": "eslint --fix ./ --ext .ts",
@@ -451,8 +457,10 @@
451457
"@vscode/dts": "^0.4.0",
452458
"@vscode/test-cli": "^0.0.10",
453459
"@vscode/test-electron": "^2.4.1",
460+
"esbuild": "^0.24.0",
454461
"eslint": "^8.57.0",
455462
"eslint-config-prettier": "^9.1.0",
463+
"npm-run-all": "4.1.5",
456464
"prettier": "3.3.3",
457465
"typescript": "^5.6.2"
458466
},

src/env.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ export async function updateProject(projectEvn: ProjectEnv, projectPath: string)
246246

247247
export function getScriptPath(script: string | undefined = undefined) {
248248
if (script === undefined) {
249-
return path.join(__dirname, "..", "..", "resources");
249+
return path.join(__dirname, "..", "resources");
250250
}
251-
return path.join(__dirname, "..", "..", "resources", script);
251+
return path.join(__dirname, "..", "resources", script);
252252
}
253253

254254
export function getFilePathInWorkspace(fileName: string) {
@@ -318,11 +318,11 @@ export async function getProjectFolderPath() {
318318
}
319319

320320
export function getXCodeBuildServerPath() {
321-
return path.join(__dirname, "..", "..", "xcode-build-server", "xcode-build-server");
321+
return path.join(__dirname, "..", "xcode-build-server", "xcode-build-server");
322322
}
323323

324324
export function getXCBBuildServicePath() {
325-
return path.join(__dirname, "..", "..", "dist", "XCBBuildService");
325+
return path.join(__dirname, "..", "dist", "XCBBuildService");
326326
}
327327

328328
function readEnvFileToDict() {

0 commit comments

Comments
 (0)