Skip to content

Commit 049e47c

Browse files
authored
GLSP-1693: Switch to esbuild (#137)
Part-of: eclipse-glsp/glsp#1693
1 parent 3e32933 commit 049e47c

8 files changed

Lines changed: 272 additions & 669 deletions

File tree

client/.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
node_modules
22
lib
33

4-
**/app/bundle.js
5-
**/app/bundle.js.map
6-
**/app/*.bundle.js
7-
**/app/*.bundle.js.map
4+
**/app/*bundle.js
5+
**/app/*bundle.js.map
6+
**/app/*bundle.css
7+
**/app/*bundle.css.map
88

99
*.log
1010
*.ttf

client/examples/workflow-webapp/app/diagram.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5+
<!-- bundled app styles (extracted by esbuild from the imported CSS) -->
6+
<link rel="stylesheet" href="bundle.css" />
57
<style>
68
html,
79
body {
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/********************************************************************************
2+
* Copyright (c) 2026 EclipseSource and others.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the Eclipse
10+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
11+
* with the GNU Classpath Exception which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
********************************************************************************/
16+
// @ts-check
17+
const esbuild = require('esbuild');
18+
const path = require('path');
19+
20+
const appRoot = path.resolve(__dirname, 'app');
21+
22+
const args = process.argv.slice(2);
23+
const isWatch = args.includes('--watch');
24+
25+
/**
26+
* Reports the build progress and surfaces errors/warnings in a format that
27+
* VS Code's `$esbuild-watch` problem matcher can pick up.
28+
* @type {import('esbuild').Plugin}
29+
*/
30+
const esbuildProblemMatcherPlugin = {
31+
name: 'esbuild-problem-matcher',
32+
setup(build) {
33+
build.onStart(() => {
34+
console.log(`${isWatch ? '[watch] ' : ''}build started`);
35+
});
36+
build.onEnd(result => {
37+
result.errors.forEach(({ text, location }) => {
38+
console.error(`✘ [ERROR] ${text}`);
39+
if (location) {
40+
console.error(` ${location.file}:${location.line}:${location.column}:`);
41+
}
42+
});
43+
console.log(`${isWatch ? '[watch] ' : ''}build finished`);
44+
});
45+
}
46+
};
47+
48+
/** @type {import('esbuild').BuildOptions} */
49+
const buildOptions = {
50+
entryPoints: [path.resolve(__dirname, 'src', 'app.ts')],
51+
outdir: appRoot,
52+
entryNames: 'bundle', // -> app/bundle.js + app/bundle.css (extracted from the imported CSS)
53+
assetNames: '[name]-[hash]', // -> app/codicon-<hash>.ttf, referenced relatively from bundle.css
54+
bundle: true,
55+
minify: true,
56+
sourcemap: true, // emit .map files alongside the minified bundle so the original sources stay debuggable
57+
format: 'iife', // diagram.html loads bundle.js via a classic <script src>
58+
platform: 'browser',
59+
target: ['es2019'],
60+
logLevel: 'silent',
61+
loader: { '.ttf': 'file' },
62+
plugins: [esbuildProblemMatcherPlugin]
63+
};
64+
65+
async function main() {
66+
if (isWatch) {
67+
const ctx = await esbuild.context(buildOptions);
68+
await ctx.watch();
69+
} else {
70+
await esbuild.build(buildOptions);
71+
}
72+
}
73+
74+
main().catch(error => {
75+
console.error(error);
76+
process.exit(1);
77+
});

client/examples/workflow-webapp/package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"private": true,
55
"description": "GLSP-based webapp for the Workflow example",
66
"scripts": {
7-
"bundle": "yarn compile && webpack",
8-
"clean": "rimraf lib tsconfig.tsbuildinfo app/bundle.js app/bundle.js.map",
7+
"bundle": "yarn compile && node ./esbuild.js",
8+
"clean": "rimraf lib tsconfig.tsbuildinfo app/bundle.js app/bundle.js.map app/bundle.css app/bundle.css.map app/*.ttf",
99
"compile": "tsc -b",
1010
"lint": "eslint ./src",
1111
"test": "mocha --config ../../.mocharc.json \"./src/**/*.spec.?(ts|tsx)\"",
1212
"test:ci": "export JUNIT_REPORT_PATH=./report.xml && yarn test --reporter mocha-jenkins-reporter",
13-
"watch": "webpack -w",
13+
"watch": "node ./esbuild.js --watch",
1414
"watch:tsc": "tsc -w"
1515
},
1616
"dependencies": {
@@ -19,14 +19,8 @@
1919
},
2020
"devDependencies": {
2121
"@vscode/codicons": "^0.0.25",
22-
"css-loader": "^6.7.3",
23-
"file-loader": "^6.2.0",
22+
"esbuild": "^0.25.0",
2423
"reflect-metadata": "^0.1.13",
25-
"rimraf": "^3.0.2",
26-
"source-map-loader": "^4.0.1",
27-
"style-loader": "^3.3.1",
28-
"ts-loader": "^9.4.2",
29-
"webpack": "^5.75.0",
30-
"webpack-cli": "^5.0.1"
24+
"rimraf": "^3.0.2"
3125
}
3226
}

client/examples/workflow-webapp/webpack.config.js

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)