mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-06-09 17:31:19 +00:00
* ⚡️ refactor: Migrate @librechat/api build to tsdown Replace Rollup with tsdown (rolldown + oxc isolated-declarations) for the @librechat/api package build, mirroring the merged data-schemas migration. - Add tsdown.config.mjs (cjs output, oxc dts, externalize all bare deps, bundle first-party `~/` + relative imports) - Annotate exports for isolatedDeclarations (codefix-driven). Collapse the tokens.ts model->token maps to Record<string, Record<string, number>> and switch validation.ts's runtime `files` field from z.any() to z.unknown() so no explicit `any` is introduced - Repoint package.json main/types/exports to tsdown's .cjs/.d.cts output - Add src/telemetry.ts entry shim so the two index.ts entries don't collide in oxc's flat dts output (stable dist/telemetry.{cjs,d.cts}) - Delete rollup.config.js Build time ~36s -> ~0.5s. No runtime behavior change: 5712 unit tests pass, both entries load via require(), legacy /api consumes them unchanged. * 👷 ci: Hash packages/api/tsdown.config.mjs in build-api cache keys The build-api cache keys hashed `packages/api/server-rollup.config.js`, which never existed (api used `rollup.config.js`, now removed) — a copy-paste artifact from the data-provider key that matched no file. Replace it with the new `packages/api/tsdown.config.mjs` so edits to the build config (entry, format, externals) bust the api build cache, matching the data-schemas key.
20 lines
905 B
JavaScript
20 lines
905 B
JavaScript
import { defineConfig } from 'tsdown';
|
|
|
|
export default defineConfig({
|
|
// The telemetry entry is a thin shim (`src/telemetry.ts`) rather than the
|
|
// `src/telemetry/index.ts` barrel: oxc emits declarations flat into outDir keyed
|
|
// by source basename, so two `index.ts` entries would collide (index.d.cts +
|
|
// index2.d.cts). Distinct basenames yield stable `index.*` / `telemetry.*` output.
|
|
entry: ['src/index.ts', 'src/telemetry.ts'],
|
|
format: ['cjs'],
|
|
platform: 'node',
|
|
dts: { oxc: true },
|
|
outDir: 'dist',
|
|
sourcemap: true,
|
|
// Externalize every third-party dependency (consumers provide the peers) and bundle
|
|
// only first-party code: relative imports and the `~/*` tsconfig alias (-> src).
|
|
// `neverBundle` is the 0.22 replacement for the deprecated `external` option.
|
|
deps: {
|
|
neverBundle: (id) => !id.startsWith('.') && !id.startsWith('~') && !id.startsWith('/'),
|
|
},
|
|
});
|