| 47 | |
| 48 | // Bundles the extension into one file |
| 49 | async function buildWithEsbuild() { |
| 50 | console.log("[info] Building with esbuild..."); |
| 51 | await esbuild.build({ |
| 52 | entryPoints: ["src/index.ts"], |
| 53 | bundle: true, |
| 54 | outfile: esbuildOutputFile, |
| 55 | external: [ |
| 56 | "esbuild", |
| 57 | "./xhr-sync-worker.js", |
| 58 | "llamaTokenizerWorkerPool.mjs", |
| 59 | "tiktokenWorkerPool.mjs", |
| 60 | "vscode", |
| 61 | "./index.node", |
| 62 | ], |
| 63 | format: "cjs", |
| 64 | platform: "node", |
| 65 | sourcemap: true, |
| 66 | minify: !esbuildOnly, |
| 67 | treeShaking: true, |
| 68 | loader: { |
| 69 | // eslint-disable-next-line @typescript-eslint/naming-convention |
| 70 | ".node": "file", |
| 71 | }, |
| 72 | |
| 73 | // To allow import.meta.path for transformers.js |
| 74 | // https://github.com/evanw/esbuild/issues/1492#issuecomment-893144483 |
| 75 | inject: ["./importMetaUrl.js"], |
| 76 | define: { "import.meta.url": "importMetaUrl" }, |
| 77 | }); |
| 78 | } |
| 79 | |
| 80 | (async () => { |
| 81 | if (esbuildOnly) { |