Skip to content

Commit

Permalink
Use esbuild to bundle dependencies (#57)
Browse files Browse the repository at this point in the history
* Use esbuild to bundle dependencies

* Change compile and test tasks

* Bump version
  • Loading branch information
MarkusAmshove authored Jan 31, 2025
1 parent c0724d0 commit c99f506
Show file tree
Hide file tree
Showing 4 changed files with 533 additions and 13 deletions.
4 changes: 0 additions & 4 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ vsc-extension-quickstart.md
**/*.map
**/*.ts
node_modules/**
!node_modules/vscode-jsonrpc/**
!node_modules/vscode-languageclient/**
!node_modules/vscode-languageserver-protocol/**
!node_modules/vscode-languageserver-types/**
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: ['src/extension.ts'],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'node',
outfile: 'out/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);
});
Loading

0 comments on commit c99f506

Please sign in to comment.