Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the website build time #3160

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
50 changes: 46 additions & 4 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"tsc-clean": "tsc --build --clean",
"build": "lerna exec --scope @ariakit/* -- npm run build",
"build-website": "npm run build --prefix website",
"build-website-code-cache": "npm run build-code-cache --prefix website",
"build-website-lite": "cross-env DISABLE_SHIKI=true npm run build-website",
"clean": "npm run clean -ws --if-present",
"changeset": "changeset",
Expand Down Expand Up @@ -152,6 +153,7 @@
"open-cli": "7.2.0",
"parse-numeric-range": "1.3.0",
"patch-package": "8.0.0",
"pkg-dir": "8.0.0",
"postcss": "8.4.32",
"postcss-combine-duplicated-selectors": "10.0.3",
"postcss-import": "15.1.0",
Expand All @@ -176,6 +178,7 @@
"rimraf": "5.0.5",
"sharp": "0.33.0",
"shiki": "0.14.5",
"sializer": "0.3.0",
"stripe": "14.7.0",
"stylelint": "15.11.0",
"stylelint-config-standard": "34.0.0",
Expand Down
Empty file added website/.code-cache/README.md
Empty file.
67 changes: 67 additions & 0 deletions website/.code-cache/cleanup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// see: website/utils/code-cache.ts

import fs from "node:fs/promises";
import path from "node:path";
import { packageDirectory } from "pkg-dir";
import { desia } from "sializer";

const ROOT_DIR = await packageDirectory({
cwd: new URL(import.meta.url).pathname,
});
if (!ROOT_DIR) throw new Error("Could not find root directory");
const CACHE_DIR = path.resolve(ROOT_DIR, ".code-cache");
const CACHE_DATA_PATH = path.resolve(CACHE_DIR, "data");
const CACHE_SEEN_PATH = path.resolve(CACHE_DATA_PATH, "seen");

async function getSeenKeys() {
const file = await fs.readFile(CACHE_SEEN_PATH, "utf8");
return file.split("\n").filter(Boolean);
}

async function getDataKeys() {
const files = await fs.readdir(CACHE_DATA_PATH);
return files.filter((file) => file !== "seen");
}

async function main() {
const seenKeys = await getSeenKeys();
const cacheKeys = await getDataKeys();

console.log("Cleaning up code cache...");

// remove not seen entries from the cache
let obsoleteEntryCount = 0;
const remainingKeys = [];
for (const key of cacheKeys) {
if (seenKeys.includes(key)) {
remainingKeys.push(key);
continue;
}
await fs.unlink(path.resolve(CACHE_DATA_PATH, key));
obsoleteEntryCount++;
}

// remove invalid entries from the cache
let invalidEntryCount = 0;
for (const key of remainingKeys) {
try {
desia(await fs.readFile(path.resolve(CACHE_DATA_PATH, key)));
} catch (error) {
console.log(`Invalid entry found: ${key}`);
console.log(error);
await fs.unlink(path.resolve(CACHE_DATA_PATH, key));
invalidEntryCount++;
}
}

await fs.unlink(CACHE_SEEN_PATH);

if (obsoleteEntryCount === 0 && invalidEntryCount === 0)
return console.log("ℹ️ No obsolete or invalid entries found.");

console.log(`ℹ️ Removed ${obsoleteEntryCount} obsolete entries from cache.`);
console.log(`ℹ️ Removed ${invalidEntryCount} invalid entries from cache.`);
console.log(`ℹ️ New cache size: ${cacheKeys.length - obsoleteEntryCount}.`);
}

await main();
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading