vscode-extension: Fix web support

This commit is contained in:
Remko Tronçon 2022-11-19 21:43:18 +01:00
parent 4f154243b5
commit fcc610b0cd
5 changed files with 52 additions and 26 deletions

13
.vscode/launch.json vendored
View file

@ -12,6 +12,19 @@
"${workspaceFolder}/src/web/vscode-extension/examples" "${workspaceFolder}/src/web/vscode-extension/examples"
], ],
"outFiles": ["${workspaceFolder}/src/web/vscode-extension/dist/*.js"] "outFiles": ["${workspaceFolder}/src/web/vscode-extension/dist/*.js"]
},
{
"name": "Run VS Code Extension (Web)",
"type": "extensionHost",
"debugWebWorkerHost": true,
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/src/web/vscode-extension",
"--extensionDevelopmentKind=web",
"${workspaceFolder}/src/web/vscode-extension/examples"
],
"outFiles": ["${workspaceFolder}/src/web/vscode-extension/dist/*.js"]
} }
] ]
} }

View file

@ -8,9 +8,8 @@ install-deps:
.PHONY: prepackage .PHONY: prepackage
prepackage: all LICENSE.txt icon.png prepackage: all LICENSE.txt icon.png
.PHONY: package .PHONY: package
package: prepackage package:
vsce package vsce package
.PHONY: publish .PHONY: publish

View file

@ -8,7 +8,7 @@ Logo-like Forth Turtle graphics.
<div align="center"> <div align="center">
<div> <div>
<a href="https://mko.re/waforth/"><img src="https://raw.githubusercontent.com/remko/waforth/master/src/web/vscode-extension/doc/notebook.gif" alt="WAForth notebook"></a> <a href="https://github.dev/remko/waforth/blob/master/src/web/vscode-extension/examples/drawing-with-forth.wafnb"><img src="https://raw.githubusercontent.com/remko/waforth/master/src/web/vscode-extension/doc/notebook.gif" alt="WAForth notebook"></a>
</div> </div>
<figcaption><em><a href="https://mko.re/waforth/">WAForth notebook</a></em></figcaption> <figcaption><em><a href="https://github.dev/remko/waforth/blob/master/src/web/vscode-extension/examples/drawing-with-forth.wafnb">WAForth notebook</a></em></figcaption>
</div> </div>

View file

@ -15,22 +15,35 @@ for (const arg of process.argv.slice(2)) {
} }
} }
esbuild const config = {
.build({ bundle: true,
bundle: true, logLevel: "info",
logLevel: "info", entryPoints: [path.join(__dirname, "src/extension.ts")],
entryPoints: [path.join(__dirname, "src/extension.ts")], format: "cjs",
outfile: path.join(__dirname, "dist/extension.js"), minify: !dev,
format: "cjs", sourcemap: true,
minify: !dev, external: ["vscode"],
sourcemap: true, loader: {
platform: "node", ".wasm": "binary",
external: ["vscode"], ".fs": "text",
loader: { ".svg": "dataurl",
".wasm": "binary", },
".fs": "text", plugins: [wasmTextPlugin({ debug: true })],
".svg": "dataurl", };
},
plugins: [wasmTextPlugin({ debug: true })], (async () => {
}) try {
.catch(() => process.exit(1)); await esbuild.build({
...config,
outfile: path.join(__dirname, "dist/extension.js"),
platform: "node",
});
await esbuild.build({
...config,
outfile: path.join(__dirname, "dist/extension.web.js"),
platform: "browser",
});
} catch (e) {
process.exit(1);
}
})();

View file

@ -1,6 +1,6 @@
{ {
"name": "waforth-vscode-extension", "name": "waforth-vscode-extension",
"version": "0.1.3", "version": "0.1.5",
"displayName": "WAForth", "displayName": "WAForth",
"description": "WAForth interactive notebooks", "description": "WAForth interactive notebooks",
"categories": [ "categories": [
@ -8,14 +8,15 @@
"Notebooks" "Notebooks"
], ],
"keywords": [ "keywords": [
"forth" "forth",
"wafnb"
], ],
"publisher": "remko", "publisher": "remko",
"license": "MIT", "license": "MIT",
"repository": "github:remko/waforth", "repository": "github:remko/waforth",
"icon": "icon.png", "icon": "icon.png",
"main": "dist/extension.js", "main": "dist/extension.js",
"browser": "dist/extension.js", "browser": "dist/extension.web.js",
"engines": { "engines": {
"vscode": "^1.61.0" "vscode": "^1.61.0"
}, },