Skip to content

Commit

Permalink
Support VS Code For Web
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwilliams committed Jan 23, 2024
1 parent 30182a3 commit d002439
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 48 deletions.
14 changes: 10 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
},
{
"name": "Run Extension (Web)",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentKind=web", "--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
},
{
"name": "Extension Tests",
Expand All @@ -23,8 +30,7 @@
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
"outFiles": ["${workspaceFolder}/out/test/**/*.js"]
}
]
}
8 changes: 0 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
{
"type": "npm",
"script": "watch",
"problemMatcher": {
"base": "$tsc-watch",
"background": {
"activeOnStart": true,
"beginsPattern": "building",
"endsPattern": "build finished"
}
},
"isBackground": true,
"presentation": {
"reveal": "never"
Expand Down
65 changes: 31 additions & 34 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
const production = process.argv[2] === '--production';
import esbuild from 'esbuild';

const production = process.argv[2] === '--production';
const watch = process.argv[2] === '--watch';
const context = await esbuild
.context({
entryPoints: ['./src/index.ts'],
bundle: true,
outdir: 'dist',
external: ['vscode'],
format: 'cjs',
sourcemap: !production,
minify: production,
platform: 'node',
target: 'ES2022',
plugins: [
{
name: 'watch',
setup(build) {
build.onEnd(() => {
if (watch) console.log('build finished');
});
build.onStart(() => {
if (watch) console.log('building');
});
},
},
],
})
.catch((e) => {
console.error(e);
process.exit(1);
});
let desktopContext, browserContext;

// This is the base config that will be used by both web and desktop versions of the extension
const baseConfig = {
entryPoints: ['./src/index.ts'],
bundle: true,
external: ['vscode'],
sourcemap: !production,
minify: production,
target: 'ES2022',
format: 'cjs',
};

try {
[desktopContext, browserContext] = await Promise.all([
// https://esbuild.github.io/getting-started/#bundling-for-node
esbuild.context({ ...baseConfig, outfile: './dist/index.js', platform: 'node' }),
// https://esbuild.github.io/getting-started/#bundling-for-the-browser
esbuild.context({ ...baseConfig, outfile: './dist/browser.js', platform: 'browser' }),
]);
} catch (e) {
console.error(e);
process.exit(1);
}

if (watch) {
await context.watch();
await desktopContext.watch();
await browserContext.watch();
} else {
context.rebuild();
context.dispose();
desktopContext.rebuild();
browserContext.rebuild();
desktopContext.dispose();
browserContext.dispose();
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-helix-emulation",
"version": "0.5.6",
"version": "0.5.7",
"displayName": "Helix For VS Code",
"description": "Helix emulation for Visual Studio Code",
"publisher": "jasew",
Expand All @@ -24,6 +24,7 @@
"Keymaps"
],
"main": "./dist/index.js",
"browser": "./dist/browser.js",
"icon": "docs/img/helixLogo.png",
"files": [
"dist"
Expand All @@ -32,7 +33,7 @@
"vscode": "^1.83.1"
},
"activationEvents": [
"*"
"onStartupFinished"
],
"contributes": {
"commands": [
Expand Down

0 comments on commit d002439

Please sign in to comment.