Skip to content

Commit 15da1b1

Browse files
committed
Bundle distribution
1 parent a6af8a4 commit 15da1b1

File tree

8 files changed

+5850
-2360
lines changed

8 files changed

+5850
-2360
lines changed

.vscode/launch.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
1313
"outFiles": ["${workspaceFolder}/out/**/*.js"],
1414
"preLaunchTask": "${defaultBuildTask}"
15-
},
16-
{
17-
"name": "Extension Tests",
18-
"type": "extensionHost",
19-
"request": "launch",
20-
"args": [
21-
"--extensionDevelopmentPath=${workspaceFolder}",
22-
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
23-
],
24-
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
25-
"preLaunchTask": "${defaultBuildTask}"
2615
}
2716
]
2817
}

.vscodeignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
.github/
22
.husky/
33
.vscode/
4+
node_modules/
45
src/
56
.gitignore
67
.nvmrc
78
.prettierignore
89
.prettierrc
10+
esbuild.js
911
eslint.config.mts
1012
tsconfig*.json

esbuild.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import esbuild from "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: "out/extension.js",
16+
external: ["vscode"],
17+
logLevel: "warning",
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+
// eslint-disable-next-line no-console
40+
console.log("[watch] build started");
41+
});
42+
build.onEnd((result) => {
43+
result.errors.forEach(({ text, location }) => {
44+
// eslint-disable-next-line no-console
45+
console.error(`✘ [ERROR] ${text}`);
46+
if (location == null) {
47+
return;
48+
}
49+
// eslint-disable-next-line no-console
50+
console.error(
51+
` ${location.file}:${location.line}:${location.column}:`
52+
);
53+
});
54+
// eslint-disable-next-line no-console
55+
console.log("[watch] build finished");
56+
});
57+
}
58+
};
59+
60+
main().catch((e) => {
61+
// eslint-disable-next-line no-console
62+
console.error(e);
63+
process.exit(1);
64+
});

eslint.config.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import eslint from "@eslint/js";
22
import eslintConfigPrettier from "eslint-config-prettier/flat";
3+
import globals from "globals";
34
import tseslint from "typescript-eslint";
45

56
export default tseslint.config(
@@ -15,6 +16,9 @@ export default tseslint.config(
1516
project: "./tsconfig.eslint.json",
1617
tsconfigRootDir: import.meta.dirname,
1718
ecmaVersion: 2023
19+
},
20+
globals: {
21+
...globals.node
1822
}
1923
},
2024
rules: {

0 commit comments

Comments
 (0)