mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-08 01:57:31 +01:00
perf(scripts): emit a server module beside the runtime bundle entry (#16765)
The runtime bundle now also has a server entry point, dist-runtime/server.mjs: the bundled dist/index.js without the argv shim. index.mjs loads it, so importing server.mjs loads the server code without starting it, and a compile cache warmed from it covers exactly the files a boot loads. bundleRuntime reports it as serverModule. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
c9669a6c22
commit
27709a99b1
2 files changed
+20
-2
No files matched your search
@@ -74,7 +74,7 @@ function externalizeThirdParty(isBundled, runtimeDir) {
|
||||
export async function bundleRuntime({ entry, outdir, isBundled = (specifier) => specifier.startsWith("@paperclipai/") }) {
|
||||
await rm(outdir, { recursive: true, force: true });
|
||||
const result = await build({
|
||||
entryPoints: { index: "paperclip-runtime-entry" },
|
||||
entryPoints: { index: "paperclip-runtime-entry", server: entry },
|
||||
outdir,
|
||||
outExtension: { ".js": ".mjs" },
|
||||
chunkNames: "chunk-[hash]",
|
||||
@@ -92,7 +92,12 @@ export async function bundleRuntime({ entry, outdir, isBundled = (specifier) =>
|
||||
plugins: [runtimeEntry(entry), keepModuleLocations, externalizeThirdParty(isBundled, dirname(entry))],
|
||||
});
|
||||
const outputs = Object.keys(result.metafile.outputs).filter((file) => file.endsWith(".mjs"));
|
||||
return { outfile: join(outdir, "index.mjs"), inputs: Object.keys(result.metafile.inputs).length, chunks: outputs.length };
|
||||
return {
|
||||
outfile: join(outdir, "index.mjs"),
|
||||
serverModule: join(outdir, "server.mjs"),
|
||||
inputs: Object.keys(result.metafile.inputs).length,
|
||||
chunks: outputs.length,
|
||||
};
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
||||
Reference in new issue
Block a user