Skip to content

Commit

Permalink
feat: Adds new loader infra, pack structure, and removes excess lua
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobo committed Oct 26, 2024
1 parent d9ccbd8 commit 92d8e00
Show file tree
Hide file tree
Showing 28 changed files with 548 additions and 1,467 deletions.
8 changes: 8 additions & 0 deletions .changeset/afraid-toes-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@taskless/loader": patch
---

💥 (BREAKING) Changes to a non-transformative pipeline
The pipeline no longer has the ability to edit requests. This is a breaking change for any pipelines that relied on the functionality. The removal of this feature improves pipeline performance, as all steps can be done in parallel and not block the outgoing request. If we do bring hooks back for transformation, we'll likely add them as a specific hook type instead of co-opting the request watching functionality.

This also significantly decreases the Lua footprint. Most of the lua code was dedicated to a Promises/A+ implementation and co-run scripting sandboxes, which is no longer necessary. Instead, a single pack now receives its own Lua VM (300KB) executed in parallel.
36 changes: 27 additions & 9 deletions scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,34 @@ import { fileURLToPath } from "node:url";
import { TASKLESS_HOST } from "@~/constants.js";

const __dirname = dirname(fileURLToPath(import.meta.url));

const base = process.env.TASKLESS_HOST ?? `${TASKLESS_HOST}`;
const oapi = new URL(`${base}/.well-known/openapi.json`);

console.log(`Using OpenAPI at ${oapi.toString()}`);
await Promise.all([
(async () => {
// OpenAPI file
const oapi = new URL(`${base}/.well-known/openapi.json`);

console.log(`Using OpenAPI at ${oapi.toString()}`);

const file = await fetch(oapi.toString());
const contents = (await file.json()) as unknown;
const out =
`export default ${JSON.stringify(contents, null, 2)} as const;`.trim();

await writeFile(resolve(__dirname, "../src/__generated__/openapi.ts"), out);
})(),
(async () => {
// Default YAML (public)
const dyaml = new URL(`${base}/public/config`);

console.log(`Using YAML at ${dyaml.toString()}`);

const file = await fetch(oapi.toString());
const contents = (await file.json()) as unknown;
const out = `
export default ${JSON.stringify(contents, null, 2)} as const;
`;
const file = await fetch(dyaml.toString());
const contents = await file.text();

await writeFile(resolve(__dirname, "../src/__generated__/openapi.ts"), out);
await writeFile(
resolve(__dirname, "../src/__generated__/config.yaml"),
contents
);
})(),
]);
37 changes: 37 additions & 0 deletions src/__generated__/config.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 81 additions & 44 deletions src/__generated__/openapi.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions src/config/default.yaml

This file was deleted.

Loading

0 comments on commit 92d8e00

Please sign in to comment.