Skip to content

Commit 65b37c0

Browse files
Samples refresh (microsoft#126)
Description of changes - Updates all extensions to the latest version of the toolkit - Changes all default extensions to use esbuild - Adds a hello-world-webpack sample that demonstrates how to use webpack - Updates all default extensions to use the toolkit component registration APIs
1 parent f28c8d4 commit 65b37c0

File tree

119 files changed

+18669
-9867
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+18669
-9867
lines changed
+16-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
{
2-
"root": true,
3-
"parser": "@typescript-eslint/parser",
4-
"parserOptions": {
5-
"ecmaVersion": 6,
6-
"sourceType": "module"
7-
},
8-
"plugins": [
9-
"@typescript-eslint"
10-
],
11-
"rules": {
12-
"@typescript-eslint/naming-convention": "warn",
13-
"@typescript-eslint/semi": "warn",
14-
"curly": "warn",
15-
"eqeqeq": "warn",
16-
"no-throw-literal": "warn",
17-
"semi": "off"
18-
}
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 6,
6+
"sourceType": "module"
7+
},
8+
"plugins": ["@typescript-eslint"],
9+
"rules": {
10+
"@typescript-eslint/naming-convention": "warn",
11+
"@typescript-eslint/semi": "warn",
12+
"curly": "warn",
13+
"eqeqeq": "warn",
14+
"no-throw-literal": "warn",
15+
"semi": "off"
16+
},
17+
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
1918
}

default/component-gallery/.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/coverage
88

99
# production
10+
/out
1011
/build
1112
/dist
1213

default/component-gallery/.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"bracketSpacing": true,
1111
"jsxBracketSameLine": true,
1212
"arrowParens": "always"
13-
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
// See http://go.microsoft.com/fwlink/?LinkId=827846
3-
// for the documentation about the extensions.json format
4-
"recommendations": [
5-
"dbaeumer.vscode-eslint"
6-
]
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": ["dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers"]
75
}

default/component-gallery/.vscode/launch.json

+11-28
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,15 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
{
6-
"version": "0.2.0",
7-
"configurations": [
8-
{
9-
"name": "Run Extension",
10-
"type": "extensionHost",
11-
"request": "launch",
12-
"args": [
13-
"--extensionDevelopmentPath=${workspaceFolder}"
14-
],
15-
"outFiles": [
16-
"${workspaceFolder}/out/**/*.js"
17-
],
18-
"preLaunchTask": "${defaultBuildTask}"
19-
},
20-
{
21-
"name": "Extension Tests",
22-
"type": "extensionHost",
23-
"request": "launch",
24-
"args": [
25-
"--extensionDevelopmentPath=${workspaceFolder}",
26-
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
27-
],
28-
"outFiles": [
29-
"${workspaceFolder}/out/test/**/*.js"
30-
],
31-
"preLaunchTask": "${defaultBuildTask}"
32-
}
33-
]
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Run Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
13+
"outFiles": ["${workspaceFolder}/out/**/*.js"],
14+
"preLaunchTask": "${defaultBuildTask}"
15+
}
16+
]
3417
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"files.exclude": {
4-
"out": false // set this to true to hide the "out" folder with the compiled JS files
5-
},
6-
"search.exclude": {
7-
"out": true // set this to false to include "out" folder in search results
8-
},
9-
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10-
"typescript.tsc.autoDetect": "off"
11-
}
3+
"files.exclude": {
4+
"out": false, // set this to true to hide the "out" folder with the compiled JS files
5+
},
6+
"search.exclude": {
7+
"out": true, // set this to false to include "out" folder in search results
8+
},
9+
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10+
"typescript.tsc.autoDetect": "off"
11+
}
+16-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
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-
]
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": "$esbuild-watch",
10+
"isBackground": true,
11+
"presentation": {
12+
"reveal": "never"
13+
},
14+
"group": {
15+
"kind": "build",
16+
"isDefault": true
17+
}
18+
}
19+
]
2020
}

default/component-gallery/.vscodeignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.vscode/**
22
.vscode-test/**
3-
out/test/**
3+
out/**
4+
node_modules/**
45
src/**
6+
esbuild.js
57
.gitignore
68
.yarnrc
79
vsc-extension-quickstart.md

default/component-gallery/esbuild.js

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
const { build } = require("esbuild");
2+
const { copy } = require("esbuild-plugin-copy");
3+
4+
//@ts-check
5+
/** @typedef {import('esbuild').BuildOptions} BuildOptions **/
6+
7+
/** @type BuildOptions */
8+
const baseConfig = {
9+
bundle: true,
10+
minify: process.env.NODE_ENV === "production",
11+
sourcemap: process.env.NODE_ENV !== "production",
12+
};
13+
14+
// Config for extension source code (to be run in a Node-based context)
15+
/** @type BuildOptions */
16+
const extensionConfig = {
17+
...baseConfig,
18+
platform: "node",
19+
format: "cjs",
20+
entryPoints: ["./src/extension.ts"],
21+
outfile: "./out/extension.js",
22+
external: ["vscode"],
23+
};
24+
25+
// Config for webview source code (to be run in a web-based context)
26+
/** @type BuildOptions */
27+
const webviewConfig = {
28+
...baseConfig,
29+
target: "es2020",
30+
format: "esm",
31+
entryPoints: ["./src/webview/main.ts"],
32+
outfile: "./out/webview.js",
33+
plugins: [
34+
// Copy webview css and ttf files to `out` directory unaltered
35+
copy({
36+
resolveFrom: "cwd",
37+
assets: {
38+
from: ["./src/webview/*.css", "./src/webview/*.ttf"],
39+
to: ["./out"],
40+
},
41+
}),
42+
],
43+
};
44+
45+
// This watch config adheres to the conventions of the esbuild-problem-matchers
46+
// extension (https://github.com/connor4312/esbuild-problem-matchers#esbuild-via-js)
47+
/** @type BuildOptions */
48+
const watchConfig = {
49+
watch: {
50+
onRebuild(error, result) {
51+
console.log("[watch] build started");
52+
if (error) {
53+
error.errors.forEach((error) =>
54+
console.error(
55+
`> ${error.location.file}:${error.location.line}:${error.location.column}: error: ${error.text}`
56+
)
57+
);
58+
} else {
59+
console.log("[watch] build finished");
60+
}
61+
},
62+
},
63+
};
64+
65+
// Build script
66+
(async () => {
67+
const args = process.argv.slice(2);
68+
try {
69+
if (args.includes("--watch")) {
70+
// Build and watch extension and webview code
71+
console.log("[watch] build started");
72+
await build({
73+
...extensionConfig,
74+
...watchConfig,
75+
});
76+
await build({
77+
...webviewConfig,
78+
...watchConfig,
79+
});
80+
console.log("[watch] build finished");
81+
} else {
82+
// Build extension and webview code
83+
await build(extensionConfig);
84+
await build(webviewConfig);
85+
console.log("build complete");
86+
}
87+
} catch (err) {
88+
process.stderr.write(err.stderr);
89+
process.exit(1);
90+
}
91+
})();

0 commit comments

Comments
 (0)