Skip to content

Commit

Permalink
vscode-ext: move to esbuild bundling, cleanup
Browse files Browse the repository at this point in the history
This removes node_modules from dependencies all together fixing long
time issue with yarn putting only a subset of dependencies in the
extension source tree.

It as well makes extension footprint 15x smaller. (down to 2.3Mb)

Kinda fixes quantified-uncertainty#1162? It actually un-patches vsce though — it really is not
an issue it should be solving :D
  • Loading branch information
cab404 committed Oct 8, 2022
1 parent d60792a commit 13a54f3
Show file tree
Hide file tree
Showing 14 changed files with 386 additions and 134 deletions.
1 change: 1 addition & 0 deletions packages/vscode-ext/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/server/out
/*.vsix
/syntaxes/*.json
dist
3 changes: 3 additions & 0 deletions packages/vscode-ext/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.vscode/**
.vscode-test/**
src/**
client
server
.gitignore
node_modules
.yarnrc
vsc-extension-quickstart.md
**/tsconfig.json
Expand Down
12 changes: 0 additions & 12 deletions packages/vscode-ext/client/tsconfig.json

This file was deleted.

17 changes: 9 additions & 8 deletions packages/vscode-ext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"onCustomEditor:squiggle.wysiwyg",
"onCommand:squiggle.preview"
],
"main": "./client/out/extension.js",
"main": "./dist/src/client/extension.js",
"contributes": {
"languages": [
{
Expand Down Expand Up @@ -114,25 +114,26 @@
}
},
"scripts": {
"vscode:prepublish": "yarn run compile",
"compile:tsc": "tsc -b",
"vscode:prepublish": "yarn run lint && yarn run compile",
"compile:grammar": "js-yaml syntaxes/squiggle.tmLanguage.yaml >syntaxes/squiggle.tmLanguage.json",
"compile:vendor": "(cd ../squiggle-lang && yarn run build) && (cd ../components && yarn run bundle && yarn run build:css) && mkdir -p media/vendor && cp ../components/dist/bundle.js media/vendor/components.js && cp ../components/dist/main.css media/vendor/components.css && cp ../../node_modules/react/umd/react.production.min.js media/vendor/react.js && cp ../../node_modules/react-dom/umd/react-dom.production.min.js media/vendor/react-dom.js && cp ../website/static/img/squiggle-logo.png media/vendor/icon.png",
"compile": "yarn run compile:vendor && yarn run compile:grammar && yarn run compile:tsc",
"watch": "tsc -b -watch",
"compile:bundle": "esbuild ./src/client/extension.ts ./src/server/server.ts --format=cjs --platform=node --sourcemap --minify --bundle --external:vscode --outdir=./dist",
"compile": "yarn run compile:vendor && yarn run compile:grammar && yarn run compile:bundle",
"watch": "yarn run compile:bundle --watch",
"pretest": "yarn run compile && yarn run lint",
"lint": "prettier --check .",
"lint": "tsc -noEmit && prettier --check .",
"format": "prettier --write .",
"package": "npx vsce package --yarn"
"package": "vsce package --yarn"
},
"devDependencies": {
"@types/glob": "^8.0.0",
"@types/node": "18.x",
"@types/vscode": "^1.70.0",
"esbuild": "^0.15.10",
"glob": "^8.0.3",
"js-yaml": "^4.1.0",
"typescript": "^4.8.4",
"vsce-yarn-patch": "^1.66.2"
"vsce": "^2.11.0"
},
"dependencies": {
"vscode-languageclient": "^8.0.2",
Expand Down
12 changes: 0 additions & 12 deletions packages/vscode-ext/server/tsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let client: LanguageClient;
export const startClient = (context: vscode.ExtensionContext) => {
// The server is implemented in node
let serverModule = context.asAbsolutePath(
path.join("server", "out", "server.js")
path.join("dist", "src", "server", "server.js")
);
// The debug options for the server
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 12 additions & 4 deletions packages/vscode-ext/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
"lib": ["es2020", "dom"],
"lib": [
"es2020",
"dom"
],
"outDir": "out",
"rootDir": "src",
"sourceMap": true
},
"include": ["src"],
"exclude": ["node_modules", ".vscode-test"],
"references": [{ "path": "./client" }, { "path": "./server" }]
"include": [
"src/server/server.ts",
"src/client/extension.ts"
],
"exclude": [
"node_modules",
".vscode-test"
],
}
Loading

0 comments on commit 13a54f3

Please sign in to comment.