Skip to content

Commit

Permalink
chore: switched to esbuild for the build to speed up building a bit.
Browse files Browse the repository at this point in the history
chore: fixed type errors and removed svd tests as this functionality no longer works.
  • Loading branch information
jortbmd committed Dec 23, 2024
1 parent 39237f0 commit 3722de0
Show file tree
Hide file tree
Showing 8 changed files with 9,224 additions and 8,737 deletions.
68 changes: 68 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const esbuild = require('esbuild');
const fs = require('fs');

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

async function main() {
const options = {
entryPoints: ['src/extension.ts'],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
metafile: !watch,
platform: 'node',
outfile: 'dist/extension.js',
external: ['vscode'],
logLevel: 'silent',
}
const ctx = await esbuild.context({
...options,
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin
]
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
if(analysis) {
const res = await esbuild.build(options);
const metafileAnalysis = await esbuild.analyzeMetafile(res.metafile, {
});
console.log(metafileAnalysis);
fs.writeFileSync('dist/meta.json', JSON.stringify(res.metafile));
}

}

/**
* @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 3722de0

Please sign in to comment.