Skip to content

Commit

Permalink
fix: 🐛 bundle with esbuild (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY authored Dec 26, 2024
1 parent 08e00bd commit 4b31f21
Show file tree
Hide file tree
Showing 8 changed files with 1,479 additions and 1,380 deletions.
4 changes: 0 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
"outFiles": [
"${workspaceRoot}/client/out/**/*.js"
],
"preLaunchTask": {
"type": "npm",
"script": "watch"
},
"env": {
"SERVER_PATH": "${workspaceRoot}/target/debug/nrs-language-server"
}
Expand Down
16 changes: 0 additions & 16 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@
"problemMatcher": [
"$tsc"
]
},
{
"type": "npm",
"script": "watch",
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [
"$tsc-watch"
]
}
]
}
6 changes: 4 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"engines": {
"vscode": "^1.85.0"
},
"dependencies": {},
"dependencies": {
"vscode-languageclient": "9.0.1"
},
"devDependencies": {
"@types/node": "^17.0.18",
"vscode-test": "^1.3.0",
"@types/vscode": "1.86.0"
"@types/vscode": "1.85.0"
}
}
58 changes: 53 additions & 5 deletions client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const esbuild = require('esbuild');

const production = process.argv.includes('--production');
const watch = process.argv.includes('--watch');

async function main() {
const ctx = await esbuild.context({
entryPoints: ['client/src/extension.ts'],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'node',
outfile: 'dist/extension.js',
external: ['vscode'],
logLevel: 'silent',
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin
]
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}

/**
* @type {import('esbuild').Plugin}
*/
const esbuildProblemMatcherPlugin = {
name: 'esbuild-problem-matcher',

setup(build) {
build.onStart(() => {
console.log('[watch] build started');
});
build.onEnd(result => {
result.errors.forEach(({ text, location }) => {
console.error(`✘ [ERROR] ${text}`);
console.error(` ${location.file}:${location.line}:${location.column}:`);
});
console.log('[watch] build finished');
});
}
};

main().catch(e => {
console.error(e);
process.exit(1);
});
169 changes: 82 additions & 87 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,89 +1,84 @@
{
"name": "nrs-language-server",
"description": "nano rust language server",
"license": "MIT",
"version": "1.5.0",
"categories": [],
"keywords": [
"language-server",
"tower-lsp"
],
"repository": {
"url": "https://github.com/IWANABETHATGUY/tower-lsp-boilerplate"
},
"engines": {
"vscode": "^1.66.0"
},
"enabledApiProposals": [],
"activationEvents": [
"onLanguage:nrs"
],
"main": "./dist/extension.js",
"contributes": {
"languages": [
{
"id": "nrs",
"extensions": [
".nrs"
]
}
],
"configuration": {
"type": "object",
"title": "nrs-language-server",
"properties": {
"nrs-language-server.trace.server": {
"type": "string",
"scope": "window",
"enum": [
"off",
"messages",
"verbose"
],
"enumDescriptions": [
"No traces",
"Error only",
"Full log"
],
"default": "off",
"description": "Traces the communication between VS Code and the language server."
}
}
}
},
"scripts": {
"postinstall": "cd client && pnpm i",
"test-compile": "tsc -p ./",
"compile": "cross-env NODE_ENV=production tsc -b",
"watch": "rm -rf dist && tsc -b -w",
"lint": "eslint src --ext ts",
"pretest": "npm run compile && npm run lint",
"test": "node ./out/test/runTest.js",
"build": "webpack --config webpack.config.js",
"package": "vsce package --no-dependencies",
"publish": "vsce publish --no-dependencies"
},
"devDependencies": {
"@types/glob": "^7.1.3",
"@types/mocha": "^8.0.0",
"@types/node": "^12.12.0",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"@vscode/vsce": "^3.2.1",
"cross-env": "^7.0.2",
"electron-rebuild": "^1.11.0",
"eslint": "^7.6.0",
"glob": "^7.1.7",
"mocha": "^8.0.1",
"ts-loader": "^9.5.1",
"typescript": "5.4.5",
"vscode-test": "^1.4.0",
"vscode-uri": "^3.0.2",
"webpack": "^5.82.1",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"vscode-languageclient": "9.0.1"
},
"packageManager": "[email protected]"
"name": "nrs-language-server",
"description": "nano rust language server",
"license": "MIT",
"version": "1.5.0",
"categories": [],
"keywords": [
"language-server",
"tower-lsp"
],
"repository": {
"url": "https://github.com/IWANABETHATGUY/tower-lsp-boilerplate"
},
"engines": {
"vscode": "^1.66.0"
},
"enabledApiProposals": [],
"activationEvents": [
"onLanguage:nrs"
],
"main": "./dist/extension.js",
"contributes": {
"languages": [
{
"id": "nrs",
"extensions": [
".nrs"
]
}
],
"configuration": {
"type": "object",
"title": "nrs-language-server",
"properties": {
"nrs-language-server.trace.server": {
"type": "string",
"scope": "window",
"enum": [
"off",
"messages",
"verbose"
],
"enumDescriptions": [
"No traces",
"Error only",
"Full log"
],
"default": "off",
"description": "Traces the communication between VS Code and the language server."
}
}
}
},
"scripts": {
"postinstall": "cd client && pnpm i",
"compile": "npm run check-types && node esbuild.js --production",
"check-types": "tsc --noEmit",
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"package": "vsce package --no-dependencies"
},
"devDependencies": {
"@types/glob": "8.1.0",
"@types/mocha": "10.0.10",
"@types/node": "22.10.2",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"@vscode/vsce": "^3.2.1",
"cross-env": "^7.0.2",
"esbuild": "^0.24.2",
"eslint": "9.17.0",
"glob": "11.0.0",
"mocha": "11.0.2",
"npm-run-all": "^4.1.5",
"ts-loader": "^9.5.1",
"typescript": "5.4.5",
"vscode-test": "^1.4.0",
"vscode-uri": "^3.0.2"
},
"dependencies": {
},
"packageManager": "[email protected]"
}
Loading

0 comments on commit 4b31f21

Please sign in to comment.