improved Start Core Dev Server
This commit is contained in:
parent
51d046e2cf
commit
7aed0b8c3e
|
@ -9,17 +9,20 @@ const {
|
|||
autodetectPlatformAndArch,
|
||||
} = require("../scripts/util");
|
||||
|
||||
// Clean slate
|
||||
const bin = path.join(__dirname, "bin");
|
||||
const out = path.join(__dirname, "out");
|
||||
const build = path.join(__dirname, "build");
|
||||
rimrafSync(bin);
|
||||
rimrafSync(out);
|
||||
rimrafSync(build);
|
||||
rimrafSync(path.join(__dirname, "tmp"));
|
||||
fs.mkdirSync(bin);
|
||||
fs.mkdirSync(out);
|
||||
fs.mkdirSync(build);
|
||||
|
||||
function cleanSlate() {
|
||||
// Clean slate
|
||||
rimrafSync(bin);
|
||||
rimrafSync(out);
|
||||
rimrafSync(build);
|
||||
rimrafSync(path.join(__dirname, "tmp"));
|
||||
fs.mkdirSync(bin);
|
||||
fs.mkdirSync(out);
|
||||
fs.mkdirSync(build);
|
||||
}
|
||||
|
||||
const esbuildOutputFile = "out/index.js";
|
||||
let targets = [
|
||||
|
@ -56,6 +59,39 @@ const targetToLanceDb = {
|
|||
"win32-arm64": "@lancedb/vectordb-win32-arm64-msvc",
|
||||
};
|
||||
|
||||
// Bundles the extension into one file
|
||||
async function buildWithEsbuild() {
|
||||
console.log("[info] Building with esbuild...");
|
||||
await esbuild.build({
|
||||
entryPoints: ["src/index.ts"],
|
||||
bundle: true,
|
||||
outfile: esbuildOutputFile,
|
||||
external: [
|
||||
"esbuild",
|
||||
"./xhr-sync-worker.js",
|
||||
"llamaTokenizerWorkerPool.mjs",
|
||||
"tiktokenWorkerPool.mjs",
|
||||
"vscode",
|
||||
"./index.node",
|
||||
],
|
||||
format: "cjs",
|
||||
platform: "node",
|
||||
sourcemap: true,
|
||||
minify: true,
|
||||
treeShaking: 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" },
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
||||
console.log(`Copying ${packageName} to ${toCopy}`);
|
||||
// This is a way to install only one package without npm trying to install all the dependencies
|
||||
|
@ -118,6 +154,13 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
}
|
||||
|
||||
(async () => {
|
||||
if (esbuildOnly) {
|
||||
await buildWithEsbuild();
|
||||
return;
|
||||
}
|
||||
|
||||
cleanSlate()
|
||||
|
||||
// Informs of where to look for node_sqlite3.node https://www.npmjs.com/package/bindings#:~:text=The%20searching%20for,file%20is%20found
|
||||
// This is only needed for our `pkg` command at build time
|
||||
fs.writeFileSync(
|
||||
|
@ -192,35 +235,7 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
fs.rmSync(assetPath, { force: true });
|
||||
}
|
||||
|
||||
// Bundles the extension into one file
|
||||
console.log("[info] Building with esbuild...");
|
||||
await esbuild.build({
|
||||
entryPoints: ["src/index.ts"],
|
||||
bundle: true,
|
||||
outfile: esbuildOutputFile,
|
||||
external: [
|
||||
"esbuild",
|
||||
"./xhr-sync-worker.js",
|
||||
"llamaTokenizerWorkerPool.mjs",
|
||||
"tiktokenWorkerPool.mjs",
|
||||
"vscode",
|
||||
"./index.node",
|
||||
],
|
||||
format: "cjs",
|
||||
platform: "node",
|
||||
sourcemap: true,
|
||||
minify: true,
|
||||
treeShaking: 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" },
|
||||
});
|
||||
await buildWithEsbuild();
|
||||
|
||||
// Copy over any worker files
|
||||
fs.cpSync(
|
||||
|
@ -233,10 +248,6 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
"out/llamaTokenizerWorkerPool.mjs",
|
||||
);
|
||||
|
||||
if (esbuildOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("[info] Building binaries with pkg...");
|
||||
for (const target of targets) {
|
||||
const targetDir = `bin/${target}`;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
"scripts": {
|
||||
"test": "jest",
|
||||
"build": "node build.js",
|
||||
"rebuild": "node build.js --esbuild-only",
|
||||
"build:darwin-x64": "node build.js --os darwin-x64"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
|
|
|
@ -4,6 +4,16 @@
|
|||
<env name="CONTINUE_DEVELOPMENT" value="true" />
|
||||
<env name="CONTINUE_GLOBAL_DIR" value="$PROJECT_DIR$/extensions/.continue-debug" />
|
||||
</envs>
|
||||
<method v="2" />
|
||||
<method v="2">
|
||||
<option name="NpmBeforeRunTask" enabled="true">
|
||||
<package-json value="$PROJECT_DIR$/binary/package.json" />
|
||||
<command value="run" />
|
||||
<scripts>
|
||||
<script value="rebuild" />
|
||||
</scripts>
|
||||
<node-interpreter value="project" />
|
||||
<envs />
|
||||
</option>
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
Loading…
Reference in New Issue