diff --git a/.vscodeignore b/.vscodeignore index 19bbe78..d7c1b96 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,3 +1,7 @@ +.tangled/** .vscode/** .vscode-test/** .gitignore +src +node_modules +**/*.map diff --git a/esbuild.js b/esbuild.js new file mode 100644 index 0000000..f508faf --- /dev/null +++ b/esbuild.js @@ -0,0 +1,64 @@ +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: [ + { + in: 'src/extension.ts', + out: 'extension', + }, + { + in: 'src/server/server.ts', + out: 'server/server', + }, + ], + outdir: 'out', + bundle: true, + format: 'cjs', + minify: true, + sourcemap: false, + sourcesContent: false, + platform: 'node', + external: ['vscode'], + logLevel: 'warning', + 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}`); + if (location == null) return; + console.error(` ${location.file}:${location.line}:${location.column}:`); + }); + console.log('[watch] build finished'); + }); + }, +}; + +main().catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/package.json b/package.json index 9dd12f3..416e323 100644 --- a/package.json +++ b/package.json @@ -57,11 +57,15 @@ ] }, "scripts": { - "compile": "tsc -p ./", + "compile": "npm run check-types && node esbuild.js", + "check-types": "tsc --noEmit", + "vscode:prepublish": "npm run package", "publish": "vsce publish", "publish:prerelease": "vsce publish --pre-release", - "package": "vsce package", - "watch": "tsc -watch -p ./" + "package": "npm run check-types && node esbuild.js --production", + "watch": "npm-run-all -p watch:*", + "watch:esbuild": "node esbuild.js --watch", + "watch:tsc": "tsc --noEmit --watch --project tsconfig.json" }, "dependencies": { "@pinc-official/pincfmt": "0.0.2", @@ -73,6 +77,7 @@ "@types/node": "25.6.0", "@types/vscode": "1.118.0", "@vscode/vsce": "3.9.1", + "esbuild": "^0.28.1", "typescript": "6.0.3" } }