Skip to content

Commit 0e576d3

Browse files
feat: utilise a bundler for smaller builds and faster load times
1 parent b795201 commit 0e576d3

5 files changed

Lines changed: 208 additions & 30 deletions

File tree

‎.vscode/tasks.json‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,36 @@
88

99
// A task runner that calls a custom npm script that compiles the extension.
1010
{
11-
"version": "0.1.0",
11+
"version": "2.0.0",
1212

1313
// we want to run npm
1414
"command": "npm",
1515

16-
// the command is a shell script
17-
"isShellCommand": true,
18-
19-
// show the output window only if unrecognized errors occur.
20-
"showOutput": "silent",
21-
2216
// we run the custom script "compile" as defined in package.json
2317
"args": ["run", "compile", "--loglevel", "silent"],
2418

2519
// The tsc compiler is started in watching mode
2620
"isWatching": true,
2721

2822
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
29-
"problemMatcher": "$tsc-watch"
23+
"problemMatcher": "$tsc-watch",
24+
"tasks": [
25+
{
26+
"label": "npm",
27+
"type": "shell",
28+
"command": "npm",
29+
"args": [
30+
"run",
31+
"compile",
32+
"--loglevel",
33+
"silent"
34+
],
35+
"isBackground": true,
36+
"problemMatcher": "$tsc-watch",
37+
"group": {
38+
"_id": "build",
39+
"isDefault": false
40+
}
41+
}
42+
]
3043
}

‎build.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const production = process.argv[2] === "--production";
2+
const watch = process.argv[2] === "--watch";
3+
4+
require("esbuild")
5+
.build({
6+
entryPoints: ["./src/extension.ts"],
7+
bundle: true,
8+
outdir: "out",
9+
external: ["vscode"],
10+
format: "cjs",
11+
sourcemap: !production,
12+
minify: production,
13+
platform: "node",
14+
target: ["node12"],
15+
watch: watch && {
16+
onRebuild(error) {
17+
if (error) console.error("watch build failed:", error);
18+
else console.log("watch build succeeded");
19+
}
20+
}
21+
})
22+
.catch(e => {
23+
console.error(e);
24+
process.exit(1);
25+
});

‎package-lock.json‎

Lines changed: 144 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"version": "1.15.0",
77
"publisher": "sysoev",
88
"engines": {
9-
"vscode": "^1.18.0"
9+
"vscode": "^1.60.0"
1010
},
1111
"categories": [
1212
"Other"
@@ -24,7 +24,7 @@
2424
"url": "https://github.com/d4rkr00t/vscode-open-in-github.git"
2525
},
2626
"bugs": "https://github.com/d4rkr00t/vscode-open-in-github/issues",
27-
"main": "./out/src/extension",
27+
"main": "./out/extension",
2828
"icon": "assets/icon.jpg",
2929
"activationEvents": [
3030
"onCommand:openInGithub.openInGitHubFile",
@@ -113,21 +113,22 @@
113113
}
114114
},
115115
"scripts": {
116-
"vscode:prepublish": "./node_modules/.bin/tsc -p ./",
117-
"compile": "tsc -watch -p ./",
118-
"build": "tsc -p ./",
116+
"vscode:prepublish": "node ./build.js --production",
117+
"compile": "node ./build.js",
118+
"watch": "node ./build.js --watch",
119119
"lint:staged": "lint-staged --no-stash",
120120
"postinstall": "node ./node_modules/vscode/bin/install"
121121
},
122122
"devDependencies": {
123123
"@types/mocha": "^5.2.5",
124124
"@types/node": "^10.12.3",
125125
"@types/ramda": "^0.25.41",
126-
"typescript": "^3.1.6",
127-
"vscode": "^1.1.37",
126+
"esbuild": "^0.13.15",
128127
"lint-staged": "^10.1.3",
129128
"pre-commit": "^1.2.2",
130-
"prettier": "^1.19.1"
129+
"prettier": "^1.19.1",
130+
"typescript": "^3.1.6",
131+
"vscode": "^1.1.37"
131132
},
132133
"lint-staged": {
133134
"*.ts": [

‎tsconfig.json‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
{
2-
"compilerOptions": {
3-
"module": "commonjs",
4-
"target": "es6",
5-
"outDir": "out",
6-
"lib": [
7-
"es6"
8-
],
9-
"sourceMap": true,
10-
"rootDir": "."
11-
},
12-
"exclude": [
13-
"node_modules",
14-
".vscode-test"
15-
]
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "ES2020",
5+
"outDir": "out",
6+
"lib": ["ES2020"],
7+
"sourceMap": true,
8+
"rootDir": "."
9+
},
10+
"exclude": ["node_modules", ".vscode-test"]
1611
}

0 commit comments

Comments
 (0)