29 Star 20 Fork 14

openKylin/native-debug

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
esbuild.js 2.21 KB
一键复制 编辑 原始数据 按行查看 历史
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');
const production = process.argv.includes('--production');
const watch = process.argv.includes('--watch');
function fileChanged(srcPath, destPath) {
const srcStat = fs.statSync(srcPath);
const destStat = fs.statSync(destPath);
// 比较最后修改时间
return srcStat.mtime > destStat.mtime;
}
/**
* @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');
});
}
};
const extensionCtx = esbuild.context({
entryPoints: ['src/frontend/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,
]
});
const daCtx = esbuild.context({
entryPoints: [
'src/gdb.ts',
'src/lldb.ts',
'src/mago.ts',
],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'node',
outdir: 'dist',
logLevel: 'silent',
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin
],
external: ['*.node'],
});
async function main() {
await fs.promises.rm('dist', { recursive: true, force: true });
const ctxes = await Promise.all([extensionCtx, daCtx]);
if (watch) {
await Promise.all(ctxes.map(ctx => ctx.watch()));
} else {
await Promise.all(ctxes.map(ctx => ctx.rebuild()));
await Promise.all(ctxes.map(ctx => ctx.dispose()));
}
}
main().catch(e => {
console.error(e);
process.exit(1);
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openkylin/native-debug.git
[email protected]:openkylin/native-debug.git
openkylin
native-debug
native-debug
main

搜索帮助