chore: update dependencies and migrate from tsup to tsdown in cli and plasmic packages
This commit is contained in:
+2
-2
@@ -107,7 +107,7 @@ bknd/
|
|||||||
index.ts # Main package exports
|
index.ts # Main package exports
|
||||||
__test__/ # Unit tests (mirrors src/ structure)
|
__test__/ # Unit tests (mirrors src/ structure)
|
||||||
e2e/ # End-to-end tests (Playwright)
|
e2e/ # End-to-end tests (Playwright)
|
||||||
build.ts # Build script (tsup/esbuild)
|
build.ts # Build script (tsdown/rolldown)
|
||||||
build.cli.ts # CLI build script
|
build.cli.ts # CLI build script
|
||||||
packages/ # Small satellite packages
|
packages/ # Small satellite packages
|
||||||
cli/ # Standalone CLI package (bknd-cli)
|
cli/ # Standalone CLI package (bknd-cli)
|
||||||
@@ -146,7 +146,7 @@ Plugins (in `app/src/plugins/`) hook into the app lifecycle via callbacks like `
|
|||||||
|
|
||||||
### Build System
|
### Build System
|
||||||
|
|
||||||
The build is handled by a custom `app/build.ts` script using tsup (esbuild under the hood). It builds four targets in parallel:
|
The build is handled by a custom `app/build.ts` script using tsdown (rolldown under the hood). It builds four targets in parallel:
|
||||||
|
|
||||||
- **API** -- the core backend
|
- **API** -- the core backend
|
||||||
- **UI** -- the admin interface
|
- **UI** -- the admin interface
|
||||||
|
|||||||
+317
-323
@@ -1,9 +1,9 @@
|
|||||||
import { $ } from "bun";
|
import { build, type UserConfig } from "tsdown";
|
||||||
import * as tsup from "tsup";
|
|
||||||
import pkg from "./package.json" with { type: "json" };
|
import pkg from "./package.json" with { type: "json" };
|
||||||
import c from "picocolors";
|
import c from "picocolors";
|
||||||
import { watch as fsWatch, readdirSync, rmSync } from "node:fs";
|
import { watch as fsWatch, readdirSync, rmSync } from "node:fs";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
import { buildTypes as runTypesBuild } from "./build.types";
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const watch = args.includes("--watch");
|
const watch = args.includes("--watch");
|
||||||
@@ -12,17 +12,17 @@ const types = args.includes("--types");
|
|||||||
const sourcemap = args.includes("--sourcemap");
|
const sourcemap = args.includes("--sourcemap");
|
||||||
const clean = args.includes("--clean");
|
const clean = args.includes("--clean");
|
||||||
|
|
||||||
// silence tsup
|
// silence tsdown
|
||||||
const oldConsole = {
|
const oldConsole = {
|
||||||
log: console.log,
|
log: console.log,
|
||||||
warn: console.warn,
|
warn: console.warn,
|
||||||
};
|
};
|
||||||
console.log = () => {};
|
console.log = () => {};
|
||||||
console.warn = () => {};
|
console.warn = () => {};
|
||||||
|
|
||||||
const define = {
|
const define = {
|
||||||
__isDev: "0",
|
__isDev: "0",
|
||||||
__version: JSON.stringify(pkg.version),
|
__version: JSON.stringify(pkg.version),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (clean) {
|
if (clean) {
|
||||||
@@ -36,156 +36,151 @@ if (clean) {
|
|||||||
const entryPath = join(distPath, entry);
|
const entryPath = join(distPath, entry);
|
||||||
rmSync(entryPath, { recursive: true, force: true });
|
rmSync(entryPath, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
// dist may not exist yet, ignore
|
// dist may not exist yet, ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let types_running = false;
|
let types_running = false;
|
||||||
function buildTypes() {
|
async function buildTypes() {
|
||||||
if (types_running || !types) return;
|
if (types_running || !types) return;
|
||||||
types_running = true;
|
types_running = true;
|
||||||
|
|
||||||
Bun.spawn(["bun", "build:types"], {
|
try {
|
||||||
stdout: "inherit",
|
await runTypesBuild();
|
||||||
onExit: () => {
|
|
||||||
oldConsole.log(c.cyan("[Types]"), c.green("built"));
|
oldConsole.log(c.cyan("[Types]"), c.green("built"));
|
||||||
Bun.spawn(["bun", "tsc-alias"], {
|
} finally {
|
||||||
stdout: "inherit",
|
types_running = false;
|
||||||
onExit: () => {
|
}
|
||||||
oldConsole.log(c.cyan("[Types]"), c.green("aliased"));
|
|
||||||
types_running = false;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (types && !watch) {
|
|
||||||
buildTypes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let watcher_timeout: any;
|
let watcher_timeout: any;
|
||||||
function delayTypes() {
|
function delayTypes() {
|
||||||
if (!watch || !types) return;
|
if (!watch || !types) return;
|
||||||
if (watcher_timeout) {
|
if (watcher_timeout) {
|
||||||
clearTimeout(watcher_timeout);
|
clearTimeout(watcher_timeout);
|
||||||
}
|
}
|
||||||
watcher_timeout = setTimeout(buildTypes, 1000);
|
watcher_timeout = setTimeout(() => {
|
||||||
|
void buildTypes().catch((error) => {
|
||||||
|
oldConsole.warn(c.cyan("[Types]"), c.red("build failed"), error);
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
const dependencies = Object.keys(pkg.dependencies);
|
const dependencies = Object.keys(pkg.dependencies);
|
||||||
|
|
||||||
// collection of always-external packages
|
// collection of always-neverBundle packages
|
||||||
const external = [
|
const neverBundle = [
|
||||||
...dependencies,
|
...dependencies,
|
||||||
"bun:test",
|
"bun:test",
|
||||||
"node:test",
|
"node:test",
|
||||||
"node:assert/strict",
|
"node:assert/strict",
|
||||||
"@libsql/client",
|
"@libsql/client",
|
||||||
"bknd",
|
"bknd",
|
||||||
/^bknd\/.*/,
|
/^bknd\/.*/,
|
||||||
"jsonv-ts",
|
"jsonv-ts",
|
||||||
/^jsonv-ts\/.*/,
|
/^jsonv-ts\/.*/,
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Building backend and general API
|
* Building backend and general API
|
||||||
*/
|
*/
|
||||||
async function buildApi() {
|
async function buildApi() {
|
||||||
await tsup.build({
|
await build({
|
||||||
minify,
|
minify,
|
||||||
sourcemap,
|
sourcemap,
|
||||||
// don't use tsup's broken watch, we'll handle it ourselves
|
// don't use tsdown's broken watch, we'll handle it ourselves
|
||||||
watch: false,
|
watch: false,
|
||||||
define,
|
define,
|
||||||
entry: [
|
entry: [
|
||||||
"src/index.ts",
|
"src/index.ts",
|
||||||
"src/core/utils/index.ts",
|
"src/core/utils/index.ts",
|
||||||
"src/plugins/index.ts",
|
// "src/plugins/index.ts",
|
||||||
"src/modes/index.ts",
|
"src/modes/index.ts",
|
||||||
],
|
],
|
||||||
outDir: "dist",
|
outDir: "dist",
|
||||||
external: [...external],
|
deps: {
|
||||||
metafile: true,
|
neverBundle: [...neverBundle],
|
||||||
target: "esnext",
|
},
|
||||||
platform: "browser",
|
|
||||||
removeNodeProtocol: false,
|
target: "esnext",
|
||||||
format: ["esm"],
|
platform: "browser",
|
||||||
splitting: false,
|
nodeProtocol: true,
|
||||||
loader: {
|
format: ["esm"],
|
||||||
".svg": "dataurl",
|
|
||||||
},
|
// plugins: [dtsPlugin],
|
||||||
onSuccess: async () => {
|
|
||||||
delayTypes();
|
loader: {
|
||||||
oldConsole.log(c.cyan("[API]"), c.green("built"));
|
".svg": "dataurl",
|
||||||
},
|
},
|
||||||
});
|
onSuccess: async () => {
|
||||||
|
delayTypes();
|
||||||
|
oldConsole.log(c.cyan("[API]"), c.green("built"));
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function rewriteClient(path: string) {
|
async function rewriteClient(path: string) {
|
||||||
const bundle = await Bun.file(path).text();
|
const bundle = await Bun.file(path).text();
|
||||||
await Bun.write(
|
await Bun.write(path, '"use client";\n' + bundle.replaceAll("ui/client", "bknd/client"));
|
||||||
path,
|
|
||||||
'"use client";\n' + bundle.replaceAll("ui/client", "bknd/client"),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Building UI for direct imports
|
* Building UI for direct imports
|
||||||
*/
|
*/
|
||||||
async function buildUi() {
|
async function buildUi() {
|
||||||
const base = {
|
const base = {
|
||||||
minify,
|
minify,
|
||||||
sourcemap,
|
sourcemap,
|
||||||
watch: false,
|
watch: false,
|
||||||
define,
|
define,
|
||||||
external: [
|
deps: {
|
||||||
...external,
|
neverBundle: [
|
||||||
"react",
|
...neverBundle,
|
||||||
"react-dom",
|
"react",
|
||||||
"react/jsx-runtime",
|
"react-dom",
|
||||||
"react/jsx-dev-runtime",
|
"react/jsx-runtime",
|
||||||
"use-sync-external-store",
|
"react/jsx-dev-runtime",
|
||||||
/codemirror/,
|
"use-sync-external-store",
|
||||||
"@xyflow/react",
|
/codemirror/,
|
||||||
"@mantine/core",
|
"@xyflow/react",
|
||||||
],
|
"@mantine/core",
|
||||||
metafile: true,
|
],
|
||||||
platform: "browser",
|
},
|
||||||
format: ["esm"],
|
devtools: false, // TODO: set true once tsdown's devtools performance is addressed
|
||||||
splitting: false,
|
platform: "browser",
|
||||||
bundle: true,
|
format: ["esm"],
|
||||||
treeshake: true,
|
bundle: true,
|
||||||
loader: {
|
treeshake: true,
|
||||||
".svg": "dataurl",
|
loader: {
|
||||||
},
|
".svg": "dataurl",
|
||||||
esbuildOptions: (options) => {
|
},
|
||||||
options.logLevel = "silent";
|
logLevel: "silent",
|
||||||
},
|
|
||||||
} satisfies tsup.Options;
|
|
||||||
|
|
||||||
await tsup.build({
|
// plugins: [dtsPlugin],
|
||||||
...base,
|
} satisfies UserConfig;
|
||||||
entry: ["src/ui/index.ts", "src/ui/main.css", "src/ui/styles.css"],
|
|
||||||
outDir: "dist/ui",
|
|
||||||
onSuccess: async () => {
|
|
||||||
await rewriteClient("./dist/ui/index.js");
|
|
||||||
delayTypes();
|
|
||||||
oldConsole.log(c.cyan("[UI]"), c.green("built"));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
await tsup.build({
|
await build({
|
||||||
...base,
|
...base,
|
||||||
entry: ["src/ui/client/index.ts"],
|
entry: ["src/ui/index.ts", "src/ui/main.css", "src/ui/styles.css"],
|
||||||
outDir: "dist/ui/client",
|
outDir: "dist/ui",
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
await rewriteClient("./dist/ui/client/index.js");
|
await rewriteClient("./dist/ui/index.js");
|
||||||
delayTypes();
|
delayTypes();
|
||||||
oldConsole.log(c.cyan("[UI]"), "Client", c.green("built"));
|
oldConsole.log(c.cyan("[UI]"), c.green("built"));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await build({
|
||||||
|
...base,
|
||||||
|
entry: ["src/ui/client/index.ts"],
|
||||||
|
outDir: "dist/ui/client",
|
||||||
|
onSuccess: async () => {
|
||||||
|
await rewriteClient("./dist/ui/client/index.js");
|
||||||
|
delayTypes();
|
||||||
|
oldConsole.log(c.cyan("[UI]"), "Client", c.green("built"));
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,238 +189,237 @@ async function buildUi() {
|
|||||||
* - ui/client is external, and after built replaced with "bknd/client"
|
* - ui/client is external, and after built replaced with "bknd/client"
|
||||||
*/
|
*/
|
||||||
async function buildUiElements() {
|
async function buildUiElements() {
|
||||||
await tsup.build({
|
await build({
|
||||||
minify,
|
minify,
|
||||||
sourcemap,
|
sourcemap,
|
||||||
watch: false,
|
watch: false,
|
||||||
define,
|
define,
|
||||||
entry: ["src/ui/elements/index.ts"],
|
entry: ["src/ui/elements/index.ts"],
|
||||||
outDir: "dist/ui/elements",
|
outDir: "dist/ui/elements",
|
||||||
external: [
|
deps: {
|
||||||
"ui/client",
|
neverBundle: [
|
||||||
"bknd",
|
"ui/client",
|
||||||
/^bknd\/.*/,
|
"bknd",
|
||||||
"wouter",
|
/^bknd\/.*/,
|
||||||
"react",
|
"wouter",
|
||||||
"react-dom",
|
"react",
|
||||||
"react/jsx-runtime",
|
"react-dom",
|
||||||
"react/jsx-dev-runtime",
|
"react/jsx-runtime",
|
||||||
"use-sync-external-store",
|
"react/jsx-dev-runtime",
|
||||||
],
|
"use-sync-external-store",
|
||||||
metafile: true,
|
],
|
||||||
platform: "browser",
|
},
|
||||||
format: ["esm"],
|
// plugins: [dtsPlugin],
|
||||||
splitting: false,
|
platform: "browser",
|
||||||
bundle: true,
|
format: ["esm"],
|
||||||
treeshake: true,
|
bundle: true,
|
||||||
loader: {
|
treeshake: true,
|
||||||
".svg": "dataurl",
|
loader: {
|
||||||
},
|
".svg": "dataurl",
|
||||||
esbuildOptions: (options) => {
|
},
|
||||||
options.alias = {
|
alias: {
|
||||||
// not important for elements, mock to reduce bundle
|
// not important for elements, mock to reduce bundle
|
||||||
"tailwind-merge": "./src/ui/elements/mocks/tailwind-merge.ts",
|
"tailwind-merge": "./src/ui/elements/mocks/tailwind-merge.ts",
|
||||||
};
|
},
|
||||||
},
|
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
await rewriteClient("./dist/ui/elements/index.js");
|
await rewriteClient("./dist/ui/elements/index.js");
|
||||||
delayTypes();
|
delayTypes();
|
||||||
oldConsole.log(c.cyan("[UI]"), "Elements", c.green("built"));
|
oldConsole.log(c.cyan("[UI]"), "Elements", c.green("built"));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Building adapters
|
* Building adapters
|
||||||
*/
|
*/
|
||||||
function baseConfig(
|
function baseConfig(adapter: string, overrides: Partial<UserConfig> = {}): UserConfig {
|
||||||
adapter: string,
|
return {
|
||||||
overrides: Partial<tsup.Options> = {},
|
minify,
|
||||||
): tsup.Options {
|
sourcemap,
|
||||||
return {
|
watch: false,
|
||||||
minify,
|
entry: [`src/adapter/${adapter}/index.ts`],
|
||||||
sourcemap,
|
format: ["esm"],
|
||||||
watch: false,
|
platform: "neutral",
|
||||||
entry: [`src/adapter/${adapter}/index.ts`],
|
outDir: `dist/adapter/${adapter}`,
|
||||||
format: ["esm"],
|
devtools: false, // TODO: set true once tsdown's devtools performance is addressed
|
||||||
platform: "neutral",
|
nodeProtocol: true,
|
||||||
outDir: `dist/adapter/${adapter}`,
|
// plugins: [dtsPlugin],
|
||||||
metafile: true,
|
onSuccess: async () => {
|
||||||
splitting: false,
|
delayTypes();
|
||||||
removeNodeProtocol: false,
|
oldConsole.log(c.cyan("[Adapter]"), adapter || "base", c.green("built"));
|
||||||
onSuccess: async () => {
|
},
|
||||||
delayTypes();
|
...overrides,
|
||||||
oldConsole.log(c.cyan("[Adapter]"), adapter || "base", c.green("built"));
|
define: {
|
||||||
},
|
...define,
|
||||||
...overrides,
|
...overrides.define,
|
||||||
define: {
|
},
|
||||||
...define,
|
deps: {
|
||||||
...overrides.define,
|
neverBundle: [
|
||||||
},
|
/^cloudflare*/,
|
||||||
external: [
|
/^@?hono.*?/,
|
||||||
/^cloudflare*/,
|
/^(bknd|react|next|node).*?/,
|
||||||
/^@?hono.*?/,
|
/.*\.(html)$/,
|
||||||
/^(bknd|react|next|node).*?/,
|
...neverBundle,
|
||||||
/.*\.(html)$/,
|
...(Array.isArray(overrides.deps?.neverBundle) ? overrides.deps.neverBundle : []),
|
||||||
...external,
|
],
|
||||||
...(Array.isArray(overrides.external) ? overrides.external : []),
|
},
|
||||||
],
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildAdapters() {
|
async function buildAdapters() {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
// base adapter handles
|
// base adapter handles
|
||||||
tsup.build({
|
build({
|
||||||
...baseConfig(""),
|
...baseConfig(""),
|
||||||
target: "esnext",
|
target: "esnext",
|
||||||
platform: "neutral",
|
platform: "neutral",
|
||||||
entry: ["src/adapter/index.ts"],
|
entry: ["src/adapter/index.ts"],
|
||||||
outDir: "dist/adapter",
|
outDir: "dist/adapter",
|
||||||
// only way to keep @vite-ignore comments
|
// only way to keep @vite-ignore comments
|
||||||
minify: false,
|
minify: false,
|
||||||
}),
|
|
||||||
|
|
||||||
// specific adatpers
|
|
||||||
tsup.build(baseConfig("react-router")),
|
|
||||||
tsup.build(
|
|
||||||
baseConfig("browser", {
|
|
||||||
external: [/^sqlocal\/?.*?/, "wouter"],
|
|
||||||
}),
|
}),
|
||||||
),
|
|
||||||
tsup.build(
|
// specific adatpers
|
||||||
baseConfig("bun", {
|
build(baseConfig("react-router")),
|
||||||
external: [/^bun\:.*/],
|
build(
|
||||||
|
baseConfig("browser", {
|
||||||
|
deps: {
|
||||||
|
neverBundle: [/^sqlocal\/?.*?/, "wouter"],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
build(
|
||||||
|
baseConfig("bun", {
|
||||||
|
deps: {
|
||||||
|
neverBundle: [/^bun:.*/],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
build(baseConfig("astro")),
|
||||||
|
build(baseConfig("aws")),
|
||||||
|
build(
|
||||||
|
baseConfig("cloudflare", {
|
||||||
|
deps: {
|
||||||
|
neverBundle: ["wrangler", "node:process", "miniflare"],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
build(
|
||||||
|
baseConfig("cloudflare/proxy", {
|
||||||
|
target: "esnext",
|
||||||
|
entry: ["src/adapter/cloudflare/proxy.ts"],
|
||||||
|
outDir: "dist/adapter/cloudflare",
|
||||||
|
devtools: false,
|
||||||
|
deps: {
|
||||||
|
neverBundle: [/bknd/, "wrangler", "node:process", "miniflare"],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
|
||||||
|
build({
|
||||||
|
...baseConfig("vite"),
|
||||||
|
platform: "node",
|
||||||
}),
|
}),
|
||||||
),
|
|
||||||
tsup.build(baseConfig("astro")),
|
build({
|
||||||
tsup.build(baseConfig("aws")),
|
...baseConfig("nextjs"),
|
||||||
tsup.build(
|
platform: "node",
|
||||||
baseConfig("cloudflare", {
|
|
||||||
external: ["wrangler", "node:process"],
|
|
||||||
}),
|
}),
|
||||||
),
|
|
||||||
tsup.build(
|
build({
|
||||||
baseConfig("cloudflare/proxy", {
|
...baseConfig("tanstack-start"),
|
||||||
target: "esnext",
|
platform: "node",
|
||||||
entry: ["src/adapter/cloudflare/proxy.ts"],
|
|
||||||
outDir: "dist/adapter/cloudflare",
|
|
||||||
metafile: false,
|
|
||||||
external: [/bknd/, "wrangler", "node:process"],
|
|
||||||
}),
|
}),
|
||||||
),
|
|
||||||
|
|
||||||
tsup.build({
|
build({
|
||||||
...baseConfig("vite"),
|
...baseConfig("sveltekit"),
|
||||||
platform: "node",
|
platform: "node",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
tsup.build({
|
build({
|
||||||
...baseConfig("nextjs"),
|
...baseConfig("nuxt"),
|
||||||
platform: "node",
|
platform: "node",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
tsup.build({
|
build({
|
||||||
...baseConfig("tanstack-start"),
|
...baseConfig("node"),
|
||||||
platform: "node",
|
platform: "node",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
tsup.build({
|
build({
|
||||||
...baseConfig("sveltekit"),
|
...baseConfig("sqlite/edge"),
|
||||||
platform: "node",
|
entry: ["src/adapter/sqlite/edge.ts"],
|
||||||
}),
|
outDir: "dist/adapter/sqlite",
|
||||||
|
devtools: false,
|
||||||
|
}),
|
||||||
|
|
||||||
tsup.build({
|
build({
|
||||||
...baseConfig("nuxt"),
|
...baseConfig("sqlite/node"),
|
||||||
platform: "node",
|
entry: ["src/adapter/sqlite/node.ts"],
|
||||||
}),
|
outDir: "dist/adapter/sqlite",
|
||||||
|
platform: "node",
|
||||||
|
devtools: false,
|
||||||
|
}),
|
||||||
|
|
||||||
tsup.build({
|
build({
|
||||||
...baseConfig("node"),
|
...baseConfig("sqlite/bun"),
|
||||||
platform: "node",
|
entry: ["src/adapter/sqlite/bun.ts"],
|
||||||
}),
|
outDir: "dist/adapter/sqlite",
|
||||||
|
devtools: false,
|
||||||
tsup.build({
|
deps: {
|
||||||
...baseConfig("sqlite/edge"),
|
neverBundle: [/^bun:.*/],
|
||||||
entry: ["src/adapter/sqlite/edge.ts"],
|
},
|
||||||
outDir: "dist/adapter/sqlite",
|
}),
|
||||||
metafile: false,
|
]);
|
||||||
}),
|
|
||||||
|
|
||||||
tsup.build({
|
|
||||||
...baseConfig("sqlite/node"),
|
|
||||||
entry: ["src/adapter/sqlite/node.ts"],
|
|
||||||
outDir: "dist/adapter/sqlite",
|
|
||||||
platform: "node",
|
|
||||||
metafile: false,
|
|
||||||
}),
|
|
||||||
|
|
||||||
tsup.build({
|
|
||||||
...baseConfig("sqlite/bun"),
|
|
||||||
entry: ["src/adapter/sqlite/bun.ts"],
|
|
||||||
outDir: "dist/adapter/sqlite",
|
|
||||||
metafile: false,
|
|
||||||
external: [/^bun\:.*/],
|
|
||||||
}),
|
|
||||||
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildAll() {
|
async function buildAll() {
|
||||||
await Promise.all([
|
await Promise.all([buildApi(), buildUi(), buildUiElements(), buildAdapters()]);
|
||||||
buildApi(),
|
|
||||||
buildUi(),
|
|
||||||
buildUiElements(),
|
|
||||||
buildAdapters(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initial build
|
// initial build
|
||||||
await buildAll();
|
await buildAll();
|
||||||
|
|
||||||
// custom watcher since tsup's watch is broken in 8.3.5+
|
if (types) {
|
||||||
|
await buildTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
// custom watcher since tsdown's watch is broken in 8.3.5+
|
||||||
if (watch) {
|
if (watch) {
|
||||||
oldConsole.log(c.cyan("[Watch]"), "watching for changes in src/...");
|
oldConsole.log(c.cyan("[Watch]"), "watching for changes in src/...");
|
||||||
|
|
||||||
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
let isBuilding = false;
|
let isBuilding = false;
|
||||||
|
|
||||||
const rebuild = async () => {
|
const rebuild = async () => {
|
||||||
if (isBuilding) return;
|
if (isBuilding) return;
|
||||||
isBuilding = true;
|
isBuilding = true;
|
||||||
oldConsole.log(c.cyan("[Watch]"), "rebuilding...");
|
oldConsole.log(c.cyan("[Watch]"), "rebuilding...");
|
||||||
try {
|
try {
|
||||||
await buildAll();
|
await buildAll();
|
||||||
oldConsole.log(c.cyan("[Watch]"), c.green("done"));
|
oldConsole.log(c.cyan("[Watch]"), c.green("done"));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
oldConsole.warn(c.cyan("[Watch]"), c.red("build failed"), e);
|
oldConsole.warn(c.cyan("[Watch]"), c.red("build failed"), e);
|
||||||
}
|
}
|
||||||
isBuilding = false;
|
isBuilding = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const debouncedRebuild = () => {
|
const debouncedRebuild = () => {
|
||||||
if (debounceTimer) clearTimeout(debounceTimer);
|
if (debounceTimer) clearTimeout(debounceTimer);
|
||||||
debounceTimer = setTimeout(rebuild, 100);
|
debounceTimer = setTimeout(rebuild, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
// watch src directory recursively
|
// watch src directory recursively
|
||||||
fsWatch(
|
fsWatch(join(import.meta.dir, "src"), { recursive: true }, (event, filename) => {
|
||||||
join(import.meta.dir, "src"),
|
|
||||||
{ recursive: true },
|
|
||||||
(event, filename) => {
|
|
||||||
if (!filename) return;
|
if (!filename) return;
|
||||||
// ignore non-source files
|
// ignore non-source files
|
||||||
if (
|
if (!filename.endsWith(".ts") && !filename.endsWith(".tsx") && !filename.endsWith(".css"))
|
||||||
!filename.endsWith(".ts") &&
|
return;
|
||||||
!filename.endsWith(".tsx") &&
|
|
||||||
!filename.endsWith(".css")
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
oldConsole.log(c.cyan("[Watch]"), c.dim(`${event}: ${filename}`));
|
oldConsole.log(c.cyan("[Watch]"), c.dim(`${event}: ${filename}`));
|
||||||
debouncedRebuild();
|
debouncedRebuild();
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// keep process alive
|
// keep process alive
|
||||||
await new Promise(() => {});
|
await new Promise(() => {});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { build } from "tsdown";
|
||||||
|
import c from "picocolors";
|
||||||
|
|
||||||
|
const typeEntryGroups = [
|
||||||
|
[
|
||||||
|
"src/index.ts",
|
||||||
|
"src/core/utils/index.ts",
|
||||||
|
"src/plugins/index.ts",
|
||||||
|
"src/modes/index.ts",
|
||||||
|
"src/cli/index.ts",
|
||||||
|
],
|
||||||
|
["src/ui/index.ts", "src/ui/client/index.ts", "src/ui/elements/index.ts"],
|
||||||
|
[
|
||||||
|
"src/adapter/index.ts",
|
||||||
|
"src/adapter/react-router/index.ts",
|
||||||
|
"src/adapter/browser/index.ts",
|
||||||
|
"src/adapter/bun/index.ts",
|
||||||
|
"src/adapter/astro/index.ts",
|
||||||
|
"src/adapter/aws/index.ts",
|
||||||
|
"src/adapter/cloudflare/index.ts",
|
||||||
|
"src/adapter/cloudflare/proxy.ts",
|
||||||
|
"src/adapter/vite/index.ts",
|
||||||
|
"src/adapter/nextjs/index.ts",
|
||||||
|
"src/adapter/tanstack-start/index.ts",
|
||||||
|
"src/adapter/sveltekit/index.ts",
|
||||||
|
"src/adapter/nuxt/index.ts",
|
||||||
|
"src/adapter/node/index.ts",
|
||||||
|
"src/adapter/sqlite/edge.ts",
|
||||||
|
"src/adapter/sqlite/node.ts",
|
||||||
|
"src/adapter/sqlite/bun.ts",
|
||||||
|
],
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export async function buildTypes() {
|
||||||
|
for (const entry of typeEntryGroups) {
|
||||||
|
await build({
|
||||||
|
entry: [...entry],
|
||||||
|
root: "src",
|
||||||
|
outDir: "dist/types",
|
||||||
|
format: ["esm"],
|
||||||
|
tsconfig: "tsconfig.build.json",
|
||||||
|
watch: false,
|
||||||
|
clean: true,
|
||||||
|
logLevel: "silent",
|
||||||
|
dts: {
|
||||||
|
emitDtsOnly: true,
|
||||||
|
resolver: "oxc",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (import.meta.main) {
|
||||||
|
try {
|
||||||
|
await buildTypes();
|
||||||
|
console.log(c.cyan("[Types]"), c.green("built"));
|
||||||
|
} catch (error) {
|
||||||
|
console.error(c.cyan("[Types]"), c.red("build failed"), error);
|
||||||
|
process.exitCode = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
+48
-21
@@ -23,11 +23,10 @@
|
|||||||
"build:all": "rm -rf dist && bun run build:static && NODE_ENV=production bun run build.ts --minify --types --clean && bun run build:cli",
|
"build:all": "rm -rf dist && bun run build:static && NODE_ENV=production bun run build.ts --minify --types --clean && bun run build:cli",
|
||||||
"build:ci": "mkdir -p dist/static/.vite && echo '{}' > dist/static/.vite/manifest.json && NODE_ENV=production bun run build.ts",
|
"build:ci": "mkdir -p dist/static/.vite && echo '{}' > dist/static/.vite/manifest.json && NODE_ENV=production bun run build.ts",
|
||||||
"build:cli": "bun run build.cli.ts",
|
"build:cli": "bun run build.cli.ts",
|
||||||
|
"build:types": "bun run build.types.ts",
|
||||||
"build:static": "vite build",
|
"build:static": "vite build",
|
||||||
"watch": "bun run build.ts --types --watch",
|
"watch": "bun run build.ts --types --watch",
|
||||||
"types": "bun tsc -p tsconfig.build.json --noEmit",
|
"types": "bun tsc -p tsconfig.build.json --noEmit",
|
||||||
"clean:types": "find ./dist -name '*.d.ts' -delete && rm -f ./dist/tsconfig.tsbuildinfo",
|
|
||||||
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly && tsc-alias",
|
|
||||||
"updater": "bun x npm-check-updates -ui",
|
"updater": "bun x npm-check-updates -ui",
|
||||||
"cli": "LOCAL=1 bun src/cli/index.ts",
|
"cli": "LOCAL=1 bun src/cli/index.ts",
|
||||||
"prepublishOnly": "bun run types && bun run test && bun run test:node && NODE_NO_WARNINGS=1 VITE_DB_URL=:memory: bun run test:e2e && bun run build:all && cp ../README.md ./",
|
"prepublishOnly": "bun run types && bun run test && bun run test:node && NODE_NO_WARNINGS=1 VITE_DB_URL=:memory: bun run test:e2e && bun run build:all && cp ../README.md ./",
|
||||||
@@ -98,6 +97,7 @@
|
|||||||
"@tanstack/react-store": "^0.8.0",
|
"@tanstack/react-store": "^0.8.0",
|
||||||
"@testing-library/jest-dom": "^6.6.3",
|
"@testing-library/jest-dom": "^6.6.3",
|
||||||
"@testing-library/react": "^16.2.0",
|
"@testing-library/react": "^16.2.0",
|
||||||
|
"@tsdown/css": "^0.21.7",
|
||||||
"@types/node": "^24.10.0",
|
"@types/node": "^24.10.0",
|
||||||
"@types/pg": "^8.15.6",
|
"@types/pg": "^8.15.6",
|
||||||
"@types/react": "^19.0.10",
|
"@types/react": "^19.0.10",
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
"kysely-postgres-js": "^2.0.0",
|
"kysely-postgres-js": "^2.0.0",
|
||||||
"libsql": "^0.5.22",
|
"libsql": "^0.5.22",
|
||||||
"libsql-stateless-easy": "^1.8.0",
|
"libsql-stateless-easy": "^1.8.0",
|
||||||
"miniflare": "^4.20251011.2",
|
"miniflare": "^4.20260317.3",
|
||||||
"open": "^10.2.0",
|
"open": "^10.2.0",
|
||||||
"openapi-types": "^12.1.3",
|
"openapi-types": "^12.1.3",
|
||||||
"pg": "^8.16.3",
|
"pg": "^8.16.3",
|
||||||
@@ -133,16 +133,15 @@
|
|||||||
"tailwind-merge": "^3.0.2",
|
"tailwind-merge": "^3.0.2",
|
||||||
"tailwindcss": "^4.1.16",
|
"tailwindcss": "^4.1.16",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"tsc-alias": "^1.8.16",
|
"tsdown": "^0.21.7",
|
||||||
"tsup": "^8.5.0",
|
|
||||||
"tsx": "^4.20.6",
|
"tsx": "^4.20.6",
|
||||||
"uuid": "^13.0.0",
|
"uuid": "^13.0.0",
|
||||||
"vite": "^7.1.12",
|
"vite": "^7.3.1",
|
||||||
"vite-plugin-circular-dependency": "^0.5.0",
|
"vite-plugin-circular-dependency": "^0.5.0",
|
||||||
"vite-tsconfig-paths": "^5.1.4",
|
"vite-tsconfig-paths": "^5.1.4",
|
||||||
"vitest": "3.0.9",
|
"vitest": "3.0.9",
|
||||||
"wouter": "^3.7.1",
|
"wouter": "^3.7.1",
|
||||||
"wrangler": "^4.45.4"
|
"wrangler": "^4.78.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@hono/node-server": "^1.19.6"
|
"@hono/node-server": "^1.19.6"
|
||||||
@@ -285,20 +284,48 @@
|
|||||||
},
|
},
|
||||||
"typesVersions": {
|
"typesVersions": {
|
||||||
"*": {
|
"*": {
|
||||||
"utils": ["./dist/types/core/utils/index.d.ts"],
|
"utils": [
|
||||||
"cli": ["./dist/types/cli/index.d.ts"],
|
"./dist/types/core/utils/index.d.ts"
|
||||||
"plugins": ["./dist/types/plugins/index.d.ts"],
|
],
|
||||||
"adapter": ["./dist/types/adapter/index.d.ts"],
|
"cli": [
|
||||||
"adapter/cloudflare": ["./dist/types/adapter/cloudflare/index.d.ts"],
|
"./dist/types/cli/index.d.ts"
|
||||||
"adapter/vite": ["./dist/types/adapter/vite/index.d.ts"],
|
],
|
||||||
"adapter/nextjs": ["./dist/types/adapter/nextjs/index.d.ts"],
|
"plugins": [
|
||||||
"adapter/nuxt": ["./dist/types/adapter/nuxt/index.d.ts"],
|
"./dist/types/plugins/index.d.ts"
|
||||||
"adapter/react-router": ["./dist/types/adapter/react-router/index.d.ts"],
|
],
|
||||||
"adapter/bun": ["./dist/types/adapter/bun/index.d.ts"],
|
"adapter": [
|
||||||
"adapter/node": ["./dist/types/adapter/node/index.d.ts"],
|
"./dist/types/adapter/index.d.ts"
|
||||||
"adapter/sveltekit": ["./dist/types/adapter/sveltekit/index.d.ts"],
|
],
|
||||||
"adapter/tanstack-start": ["./dist/types/adapter/tanstack-start/index.d.ts"],
|
"adapter/cloudflare": [
|
||||||
"adapter/sqlite": ["./dist/types/adapter/sqlite/edge.d.ts"]
|
"./dist/types/adapter/cloudflare/index.d.ts"
|
||||||
|
],
|
||||||
|
"adapter/vite": [
|
||||||
|
"./dist/types/adapter/vite/index.d.ts"
|
||||||
|
],
|
||||||
|
"adapter/nextjs": [
|
||||||
|
"./dist/types/adapter/nextjs/index.d.ts"
|
||||||
|
],
|
||||||
|
"adapter/nuxt": [
|
||||||
|
"./dist/types/adapter/nuxt/index.d.ts"
|
||||||
|
],
|
||||||
|
"adapter/react-router": [
|
||||||
|
"./dist/types/adapter/react-router/index.d.ts"
|
||||||
|
],
|
||||||
|
"adapter/bun": [
|
||||||
|
"./dist/types/adapter/bun/index.d.ts"
|
||||||
|
],
|
||||||
|
"adapter/node": [
|
||||||
|
"./dist/types/adapter/node/index.d.ts"
|
||||||
|
],
|
||||||
|
"adapter/sveltekit": [
|
||||||
|
"./dist/types/adapter/sveltekit/index.d.ts"
|
||||||
|
],
|
||||||
|
"adapter/tanstack-start": [
|
||||||
|
"./dist/types/adapter/tanstack-start/index.d.ts"
|
||||||
|
],
|
||||||
|
"adapter/sqlite": [
|
||||||
|
"./dist/types/adapter/sqlite/edge.d.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
|||||||
+4
-3
@@ -102,9 +102,10 @@ body,
|
|||||||
/* Chrome, Edge, and Safari */
|
/* Chrome, Edge, and Safari */
|
||||||
& *::-webkit-scrollbar {
|
& *::-webkit-scrollbar {
|
||||||
@apply w-1;
|
@apply w-1;
|
||||||
&:horizontal {
|
}
|
||||||
@apply h-px;
|
|
||||||
}
|
& *::-webkit-scrollbar:horizontal {
|
||||||
|
@apply h-px;
|
||||||
}
|
}
|
||||||
|
|
||||||
& *::-webkit-scrollbar-track {
|
& *::-webkit-scrollbar-track {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist/types",
|
"outDir": "./dist/types",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"baseUrl": ".",
|
|
||||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
|
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
|
||||||
|
|||||||
+1
-2
@@ -6,7 +6,7 @@
|
|||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"allowImportingTsExtensions": false,
|
"allowImportingTsExtensions": false,
|
||||||
"target": "ES2022",
|
"target": "es2023",
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"verbatimModuleSyntax": true,
|
"verbatimModuleSyntax": true,
|
||||||
@@ -26,7 +26,6 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"baseUrl": ".",
|
|
||||||
"outDir": "./dist/types",
|
"outDir": "./dist/types",
|
||||||
"paths": {
|
"paths": {
|
||||||
"*": ["./src/*"],
|
"*": ["./src/*"],
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@
|
|||||||
"files": {
|
"files": {
|
||||||
"includes": [
|
"includes": [
|
||||||
"**",
|
"**",
|
||||||
"!!**/.tsup",
|
"!!**/.tsdown",
|
||||||
"!!**/node_modules",
|
"!!**/node_modules",
|
||||||
"!!**/.cache",
|
"!!**/.cache",
|
||||||
"!!**/.wrangler",
|
"!!**/.wrangler",
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@libsql/client": "^0.14.0",
|
"@libsql/client": "^0.17.2",
|
||||||
"hono": "^4.6.7"
|
"hono": "^4.6.7"
|
||||||
},
|
},
|
||||||
"tsup": {
|
"tsdown": {
|
||||||
"entry": [
|
"entry": [
|
||||||
"src/index.ts"
|
"src/index.ts"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -4,14 +4,15 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rm -rf dist && bun tsup && bun run build:types",
|
"build": "rm -rf dist && bun tsdown && bun run build:types",
|
||||||
"watch": "bun tsup --watch --onSuccess 'bun run build:types'",
|
"watch": "bun tsdown --watch --onSuccess 'bun run build:types'",
|
||||||
"build:only": "rm -rf dist && bun tsup",
|
"build:only": "rm -rf dist && bun tsdown",
|
||||||
"types": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
|
"types": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
|
||||||
"build:types": "bun tsc --emitDeclarationOnly",
|
"build:types": "bun tsc --emitDeclarationOnly",
|
||||||
"updater": "bun x npm-check-updates -ui",
|
"updater": "bun x npm-check-updates -ui",
|
||||||
"pack": "rm -rf *.tgz && npm pack && mv *.tgz latest.tgz",
|
"pack": "rm -rf *.tgz && npm pack && mv *.tgz latest.tgz",
|
||||||
"prepublishOnly": "bun run build"
|
"prepublishOnly": "bun run build",
|
||||||
|
"tsdown": "bunx tsdown"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
@@ -33,7 +34,7 @@
|
|||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@plasmicapp/loader-nextjs": "^1.0.0"
|
"@plasmicapp/loader-nextjs": "^1.0.0"
|
||||||
},
|
},
|
||||||
"tsup": {
|
"tsdown": {
|
||||||
"entry": [
|
"entry": [
|
||||||
"src/index.ts",
|
"src/index.ts",
|
||||||
"src/nextjs/index.tsx"
|
"src/nextjs/index.tsx"
|
||||||
|
|||||||
Reference in New Issue
Block a user