👷 build with pkg

This commit is contained in:
Nate Sesti 2024-02-14 23:14:29 -08:00
parent fb1d38436a
commit 756cb7fead
11 changed files with 2592 additions and 11 deletions

1
pkg/.continueignore Normal file
View file

@ -0,0 +1 @@
**/*

4
pkg/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
node_modules
bin
data
out

34
pkg/build.js Normal file
View file

@ -0,0 +1,34 @@
const esbuild = require("esbuild");
const { execSync } = require("child_process");
const esbuildOutputFile = "out/index.js";
(async () => {
// console.log("[info] Building with ncc...");
// execSync(`npx ncc build src/index.ts -o out`);
console.log("[info] Building with esbuild...");
// Bundles the extension into one file
await esbuild.build({
entryPoints: ["src/index.ts"],
bundle: true,
outfile: esbuildOutputFile,
external: ["esbuild"],
format: "cjs",
platform: "node",
sourcemap: true,
loader: {
// eslint-disable-next-line @typescript-eslint/naming-convention
".node": "file",
},
// To allow import.meta.path for transformers.js
// https://github.com/evanw/esbuild/issues/1492#issuecomment-893144483
inject: ["./importMetaUrl.js"],
define: { "import.meta.url": "importMetaUrl" },
});
console.log("[info] Building binary with pkg...");
execSync("npx pkg .");
console.log("[info] Done!");
})();

2
pkg/importMetaUrl.js Normal file
View file

@ -0,0 +1,2 @@
// https://github.com/evanw/esbuild/issues/1492#issuecomment-893144483
export var importMetaUrl = require("url").pathToFileURL(__filename);

2480
pkg/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

41
pkg/package.json Normal file
View file

@ -0,0 +1,41 @@
{
"name": "pkg",
"version": "1.0.0",
"description": "",
"main": "out/index.js",
"bin": "out/index.js",
"pkg": {
"scripts": [
"node_modules/axios/**/*"
],
"assets": [
"../core/node_modules/sqlite3/**/*",
"node_modules/@lancedb/**/*"
],
"targets": [
"node18-darwin-arm64"
],
"outputPath": "bin"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "node build.js",
"build:old": "ncc build src/index.ts -o out && pkg .",
"build:dev": "tsc"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/uuid": "^9.0.8",
"@vercel/ncc": "^0.38.1",
"esbuild": "^0.19.11",
"pkg": "^5.8.1",
"typescript": "^5.3.3"
},
"dependencies": {
"commander": "^12.0.0",
"core": "file:../core",
"uuid": "^9.0.1",
"vectordb": "^0.4.10"
}
}

View file

@ -1,4 +1,4 @@
import { Chunk, ContinueRcJson, IDE, Problem, Range } from "..";
import { Chunk, ContinueRcJson, IDE, Problem, Range } from "../../core";
import { IpcMessenger } from "./messenger";
export class IpcIde implements IDE {

View file

@ -1,12 +1,12 @@
import { ContextItemId, IDE } from "core";
import { ConfigHandler } from "core/config/handler";
import { addModel, addOpenAIKey, deleteModel } from "core/config/util";
import { indexDocs } from "core/indexing/docs";
import TransformersJsEmbeddingsProvider from "core/indexing/embeddings/TransformersJsEmbeddingsProvider";
import { CodebaseIndexer } from "core/indexing/indexCodebase";
import { logDevData } from "core/util/devdata";
import historyManager from "core/util/history";
import { v4 as uuidv4 } from "uuid";
import { ContextItemId, IDE } from "..";
import { ConfigHandler } from "../config/handler";
import { addModel, addOpenAIKey, deleteModel } from "../config/util";
import { indexDocs } from "../indexing/docs";
import TransformersJsEmbeddingsProvider from "../indexing/embeddings/TransformersJsEmbeddingsProvider";
import { CodebaseIndexer } from "../indexing/indexCodebase";
import { logDevData } from "../util/devdata";
import historyManager from "../util/history";
import { Messenger, Protocol } from "./messenger";
export class Core {

View file

@ -8,8 +8,8 @@ import {
RangeInFile,
SerializedContinueConfig,
SessionInfo,
} from "..";
import { Message } from "../util/messenger";
} from "../../core";
import { Message } from "../../core/util/messenger";
export abstract class Messenger {
abstract send(messageType: string, message: any, messageId?: string): string;

19
pkg/tsconfig.json Normal file
View file

@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"outDir": "out",
"lib": ["ES2020", "dom", "es6", "es5", "dom.iterable", "scripthost"],
"sourceMap": true,
"rootDirs": ["src", "../core"],
"allowJs": true,
"strict": true /* enable all strict type-checking options */,
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"resolveJsonModule": true /* Enable importing .json files */
},
"include": ["src/**/*"]
}