mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
upgrade swr and wouter
This commit is contained in:
@@ -1,13 +0,0 @@
|
|||||||
//import type { BkndConfig } from "./src";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
app: {
|
|
||||||
connection: {
|
|
||||||
type: "libsql",
|
|
||||||
config: {
|
|
||||||
//url: "http://localhost:8080"
|
|
||||||
url: ":memory:"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,257 +0,0 @@
|
|||||||
import { $, type Subprocess } from "bun";
|
|
||||||
import * as esbuild from "esbuild";
|
|
||||||
import postcss from "esbuild-postcss";
|
|
||||||
import { entryOutputMeta } from "./internal/esbuild.entry-output-meta.plugin";
|
|
||||||
import { guessMimeType } from "./src/media/storage/mime-types";
|
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
|
||||||
const watch = args.includes("--watch");
|
|
||||||
const minify = args.includes("--minify");
|
|
||||||
const types = args.includes("--types");
|
|
||||||
const sourcemap = args.includes("--sourcemap");
|
|
||||||
|
|
||||||
type BuildOptions = esbuild.BuildOptions & { name: string };
|
|
||||||
|
|
||||||
const baseOptions: Partial<Omit<esbuild.BuildOptions, "plugins">> & { plugins?: any[] } = {
|
|
||||||
minify,
|
|
||||||
sourcemap,
|
|
||||||
metafile: true,
|
|
||||||
format: "esm",
|
|
||||||
drop: ["console", "debugger"],
|
|
||||||
loader: {
|
|
||||||
".svg": "dataurl",
|
|
||||||
},
|
|
||||||
define: {
|
|
||||||
__isDev: "0",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
type BuildFn = (format?: "esm" | "cjs") => BuildOptions;
|
|
||||||
|
|
||||||
// build BE
|
|
||||||
const builds: Record<string, BuildFn> = {
|
|
||||||
backend: (format = "esm") => ({
|
|
||||||
...baseOptions,
|
|
||||||
name: `backend ${format}`,
|
|
||||||
entryPoints: [
|
|
||||||
"src/index.ts",
|
|
||||||
"src/data/index.ts",
|
|
||||||
"src/core/index.ts",
|
|
||||||
"src/core/utils/index.ts",
|
|
||||||
"src/ui/index.ts",
|
|
||||||
"src/ui/main.css",
|
|
||||||
],
|
|
||||||
outdir: "dist",
|
|
||||||
outExtension: { ".js": format === "esm" ? ".js" : ".cjs" },
|
|
||||||
platform: "browser",
|
|
||||||
splitting: false,
|
|
||||||
bundle: true,
|
|
||||||
plugins: [postcss()],
|
|
||||||
//target: "es2022",
|
|
||||||
format,
|
|
||||||
}),
|
|
||||||
/*components: (format = "esm") => ({
|
|
||||||
...baseOptions,
|
|
||||||
name: `components ${format}`,
|
|
||||||
entryPoints: ["src/ui/index.ts", "src/ui/main.css"],
|
|
||||||
outdir: "dist/ui",
|
|
||||||
outExtension: { ".js": format === "esm" ? ".js" : ".cjs" },
|
|
||||||
format,
|
|
||||||
platform: "browser",
|
|
||||||
splitting: false,
|
|
||||||
//target: "es2022",
|
|
||||||
bundle: true,
|
|
||||||
//external: ["react", "react-dom", "@tanstack/react-query-devtools"],
|
|
||||||
plugins: [postcss()],
|
|
||||||
loader: {
|
|
||||||
".svg": "dataurl",
|
|
||||||
".js": "jsx"
|
|
||||||
}
|
|
||||||
}),*/
|
|
||||||
static: (format = "esm") => ({
|
|
||||||
...baseOptions,
|
|
||||||
name: `static ${format}`,
|
|
||||||
entryPoints: ["src/ui/main.tsx", "src/ui/main.css"],
|
|
||||||
entryNames: "[dir]/[name]-[hash]",
|
|
||||||
outdir: "dist/static",
|
|
||||||
outExtension: { ".js": format === "esm" ? ".js" : ".cjs" },
|
|
||||||
platform: "browser",
|
|
||||||
bundle: true,
|
|
||||||
splitting: true,
|
|
||||||
inject: ["src/ui/inject.js"],
|
|
||||||
target: "es2022",
|
|
||||||
format,
|
|
||||||
loader: {
|
|
||||||
".svg": "dataurl",
|
|
||||||
".js": "jsx",
|
|
||||||
},
|
|
||||||
define: {
|
|
||||||
__isDev: "0",
|
|
||||||
"process.env.NODE_ENV": '"production"',
|
|
||||||
},
|
|
||||||
chunkNames: "chunks/[name]-[hash]",
|
|
||||||
plugins: [
|
|
||||||
postcss(),
|
|
||||||
entryOutputMeta(async (info) => {
|
|
||||||
const manifest: Record<string, object> = {};
|
|
||||||
const toAsset = (output: string) => {
|
|
||||||
const name = output.split("/").pop()!;
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
path: output,
|
|
||||||
mime: guessMimeType(name),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
for (const { output, meta } of info) {
|
|
||||||
manifest[meta.entryPoint as string] = toAsset(output);
|
|
||||||
if (meta.cssBundle) {
|
|
||||||
manifest["src/ui/main.css"] = toAsset(meta.cssBundle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const manifest_file = "dist/static/manifest.json";
|
|
||||||
await Bun.write(manifest_file, JSON.stringify(manifest, null, 2));
|
|
||||||
console.log(`Manifest written to ${manifest_file}`, manifest);
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
function adapter(adapter: string, overrides: Partial<esbuild.BuildOptions> = {}): BuildOptions {
|
|
||||||
return {
|
|
||||||
...baseOptions,
|
|
||||||
name: `adapter ${adapter} ${overrides?.format === "cjs" ? "cjs" : "esm"}`,
|
|
||||||
entryPoints: [`src/adapter/${adapter}`],
|
|
||||||
platform: "neutral",
|
|
||||||
outfile: `dist/adapter/${adapter}/index.${overrides?.format === "cjs" ? "cjs" : "js"}`,
|
|
||||||
external: [
|
|
||||||
"cloudflare:workers",
|
|
||||||
"@hono*",
|
|
||||||
"hono*",
|
|
||||||
"bknd*",
|
|
||||||
"*.html",
|
|
||||||
"node*",
|
|
||||||
"react*",
|
|
||||||
"next*",
|
|
||||||
"libsql",
|
|
||||||
"@libsql*",
|
|
||||||
],
|
|
||||||
splitting: false,
|
|
||||||
treeShaking: true,
|
|
||||||
bundle: true,
|
|
||||||
...overrides,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const adapters = [
|
|
||||||
adapter("vite", { platform: "node" }),
|
|
||||||
adapter("cloudflare"),
|
|
||||||
adapter("nextjs", { platform: "node", format: "esm" }),
|
|
||||||
adapter("nextjs", { platform: "node", format: "cjs" }),
|
|
||||||
adapter("remix", { format: "esm" }),
|
|
||||||
adapter("remix", { format: "cjs" }),
|
|
||||||
adapter("bun"),
|
|
||||||
adapter("node", { platform: "node", format: "esm" }),
|
|
||||||
adapter("node", { platform: "node", format: "cjs" }),
|
|
||||||
];
|
|
||||||
|
|
||||||
const collect = [
|
|
||||||
builds.static(),
|
|
||||||
builds.backend(),
|
|
||||||
//builds.components(),
|
|
||||||
builds.backend("cjs"),
|
|
||||||
//builds.components("cjs"),
|
|
||||||
...adapters,
|
|
||||||
];
|
|
||||||
|
|
||||||
if (watch) {
|
|
||||||
const _state: {
|
|
||||||
timeout: Timer | undefined;
|
|
||||||
cleanup: Subprocess | undefined;
|
|
||||||
building: Subprocess | undefined;
|
|
||||||
} = {
|
|
||||||
timeout: undefined,
|
|
||||||
cleanup: undefined,
|
|
||||||
building: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
async function rebuildTypes() {
|
|
||||||
if (!types) return;
|
|
||||||
if (_state.timeout) {
|
|
||||||
clearTimeout(_state.timeout);
|
|
||||||
if (_state.cleanup) _state.cleanup.kill();
|
|
||||||
if (_state.building) _state.building.kill();
|
|
||||||
}
|
|
||||||
_state.timeout = setTimeout(async () => {
|
|
||||||
_state.cleanup = Bun.spawn(["bun", "clean:types"], {
|
|
||||||
onExit: () => {
|
|
||||||
_state.cleanup = undefined;
|
|
||||||
_state.building = Bun.spawn(["bun", "build:types"], {
|
|
||||||
onExit: () => {
|
|
||||||
_state.building = undefined;
|
|
||||||
console.log("Types rebuilt");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const { name, ...build } of collect) {
|
|
||||||
const ctx = await esbuild.context({
|
|
||||||
...build,
|
|
||||||
plugins: [
|
|
||||||
...(build.plugins ?? []),
|
|
||||||
{
|
|
||||||
name: "rebuild-notify",
|
|
||||||
setup(build) {
|
|
||||||
build.onEnd((result) => {
|
|
||||||
console.log(`rebuilt ${name} with ${result.errors.length} errors`);
|
|
||||||
rebuildTypes();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
ctx.watch();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
await $`rm -rf dist`;
|
|
||||||
|
|
||||||
async function _build() {
|
|
||||||
let i = 0;
|
|
||||||
const count = collect.length;
|
|
||||||
for await (const { name, ...build } of collect) {
|
|
||||||
await esbuild.build({
|
|
||||||
...build,
|
|
||||||
plugins: [
|
|
||||||
...(build.plugins || []),
|
|
||||||
{
|
|
||||||
name: "progress",
|
|
||||||
setup(build) {
|
|
||||||
i++;
|
|
||||||
build.onEnd((result) => {
|
|
||||||
const errors = result.errors.length;
|
|
||||||
const from = String(i).padStart(String(count).length);
|
|
||||||
console.log(`[${from}/${count}] built ${name} with ${errors} errors`);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("All builds complete");
|
|
||||||
}
|
|
||||||
|
|
||||||
async function _buildtypes() {
|
|
||||||
if (!types) return;
|
|
||||||
Bun.spawn(["bun", "build:types"], {
|
|
||||||
onExit: () => {
|
|
||||||
console.log("Types rebuilt");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all([_build(), _buildtypes()]);
|
|
||||||
}
|
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
"object-path-immutable": "^4.1.2",
|
"object-path-immutable": "^4.1.2",
|
||||||
"picocolors": "^1.1.1",
|
"picocolors": "^1.1.1",
|
||||||
"radix-ui": "^1.1.3",
|
"radix-ui": "^1.1.3",
|
||||||
"swr": "^2.2.5"
|
"swr": "^2.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.758.0",
|
"@aws-sdk/client-s3": "^3.758.0",
|
||||||
@@ -80,7 +80,6 @@
|
|||||||
"autoprefixer": "^10.4.21",
|
"autoprefixer": "^10.4.21",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
"esbuild-postcss": "^0.0.4",
|
|
||||||
"jotai": "^2.10.1",
|
"jotai": "^2.10.1",
|
||||||
"kysely-d1": "^0.3.0",
|
"kysely-d1": "^0.3.0",
|
||||||
"open": "^10.1.0",
|
"open": "^10.1.0",
|
||||||
@@ -101,7 +100,7 @@
|
|||||||
"tsup": "^8.4.0",
|
"tsup": "^8.4.0",
|
||||||
"vite": "^6.2.1",
|
"vite": "^6.2.1",
|
||||||
"vite-tsconfig-paths": "^5.1.4",
|
"vite-tsconfig-paths": "^5.1.4",
|
||||||
"wouter": "^3.3.5"
|
"wouter": "^3.6.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@hono/node-server": "^1.13.8"
|
"@hono/node-server": "^1.13.8"
|
||||||
|
|||||||
11
bun.lock
11
bun.lock
@@ -56,7 +56,7 @@
|
|||||||
"object-path-immutable": "^4.1.2",
|
"object-path-immutable": "^4.1.2",
|
||||||
"picocolors": "^1.1.1",
|
"picocolors": "^1.1.1",
|
||||||
"radix-ui": "^1.1.3",
|
"radix-ui": "^1.1.3",
|
||||||
"swr": "^2.2.5",
|
"swr": "^2.3.3",
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.758.0",
|
"@aws-sdk/client-s3": "^3.758.0",
|
||||||
@@ -78,7 +78,6 @@
|
|||||||
"autoprefixer": "^10.4.21",
|
"autoprefixer": "^10.4.21",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
"esbuild-postcss": "^0.0.4",
|
|
||||||
"jotai": "^2.10.1",
|
"jotai": "^2.10.1",
|
||||||
"kysely-d1": "^0.3.0",
|
"kysely-d1": "^0.3.0",
|
||||||
"open": "^10.1.0",
|
"open": "^10.1.0",
|
||||||
@@ -99,7 +98,7 @@
|
|||||||
"tsup": "^8.4.0",
|
"tsup": "^8.4.0",
|
||||||
"vite": "^6.2.1",
|
"vite": "^6.2.1",
|
||||||
"vite-tsconfig-paths": "^5.1.4",
|
"vite-tsconfig-paths": "^5.1.4",
|
||||||
"wouter": "^3.3.5",
|
"wouter": "^3.6.0",
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@hono/node-server": "^1.13.8",
|
"@hono/node-server": "^1.13.8",
|
||||||
@@ -1716,8 +1715,6 @@
|
|||||||
|
|
||||||
"esbuild-plugin-tsc": ["esbuild-plugin-tsc@0.4.0", "", { "dependencies": { "strip-comments": "^2.0.1" }, "peerDependencies": { "typescript": "^4.0.0 || ^5.0.0" } }, "sha512-q9gWIovt1nkwchMLc2zhyksaiHOv3kDK4b0AUol8lkMCRhJ1zavgfb2fad6BKp7FT9rh/OHmEBXVjczLoi/0yw=="],
|
"esbuild-plugin-tsc": ["esbuild-plugin-tsc@0.4.0", "", { "dependencies": { "strip-comments": "^2.0.1" }, "peerDependencies": { "typescript": "^4.0.0 || ^5.0.0" } }, "sha512-q9gWIovt1nkwchMLc2zhyksaiHOv3kDK4b0AUol8lkMCRhJ1zavgfb2fad6BKp7FT9rh/OHmEBXVjczLoi/0yw=="],
|
||||||
|
|
||||||
"esbuild-postcss": ["esbuild-postcss@0.0.4", "", { "dependencies": { "postcss-load-config": "^3.1.0" }, "peerDependencies": { "esbuild": "*", "postcss": "^8.0.0" } }, "sha512-CKYibp+aCswskE+gBPnGZ0b9YyuY0n9w2dxyMaoLYEvGTwmjkRj5SV8l1zGJpw8KylqmcMTK0Gr349RnOLd+8A=="],
|
|
||||||
|
|
||||||
"escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
|
"escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
|
||||||
|
|
||||||
"escape-html": ["escape-html@1.0.3", "", {}, "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="],
|
"escape-html": ["escape-html@1.0.3", "", {}, "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="],
|
||||||
@@ -3664,8 +3661,6 @@
|
|||||||
|
|
||||||
"engine.io-client/ws": ["ws@8.17.1", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ=="],
|
"engine.io-client/ws": ["ws@8.17.1", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ=="],
|
||||||
|
|
||||||
"esbuild-postcss/postcss-load-config": ["postcss-load-config@3.1.4", "", { "dependencies": { "lilconfig": "^2.0.5", "yaml": "^1.10.2" }, "peerDependencies": { "postcss": ">=8.0.9", "ts-node": ">=9.0.0" }, "optionalPeers": ["postcss", "ts-node"] }, "sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg=="],
|
|
||||||
|
|
||||||
"escodegen/estraverse": ["estraverse@4.3.0", "", {}, "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw=="],
|
"escodegen/estraverse": ["estraverse@4.3.0", "", {}, "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw=="],
|
||||||
|
|
||||||
"escodegen/source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="],
|
"escodegen/source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="],
|
||||||
@@ -4196,8 +4191,6 @@
|
|||||||
|
|
||||||
"duplexify/readable-stream/string_decoder": ["string_decoder@1.3.0", "", { "dependencies": { "safe-buffer": "~5.2.0" } }, "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA=="],
|
"duplexify/readable-stream/string_decoder": ["string_decoder@1.3.0", "", { "dependencies": { "safe-buffer": "~5.2.0" } }, "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA=="],
|
||||||
|
|
||||||
"esbuild-postcss/postcss-load-config/lilconfig": ["lilconfig@2.1.0", "", {}, "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ=="],
|
|
||||||
|
|
||||||
"eslint-plugin-import/minimatch/brace-expansion": ["brace-expansion@1.1.11", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA=="],
|
"eslint-plugin-import/minimatch/brace-expansion": ["brace-expansion@1.1.11", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA=="],
|
||||||
|
|
||||||
"eslint-plugin-jsx-a11y/minimatch/brace-expansion": ["brace-expansion@1.1.11", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA=="],
|
"eslint-plugin-jsx-a11y/minimatch/brace-expansion": ["brace-expansion@1.1.11", "", { "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA=="],
|
||||||
|
|||||||
Reference in New Issue
Block a user