LibreChat/packages/data-provider/tsdown.config.mjs
Lacy dea71c8396
🪟 fix: Cross-Platform Absolute-Path Check in tsdown neverBundle Predicates (#13700)
The deps.neverBundle predicates in the four package tsdown configs detect
first-party (resolved) module ids with !id.startsWith('/'). On Windows,
resolved ids are absolute paths like C:\..., which never match, so every
project module is externalized. Builds still exit 0 but emit near-empty
bundles — e.g. packages/client dist/index.mjs drops from ~276 kB to
~2.7 kB and dist/style.css is never produced, breaking the client dev
server with "Failed to resolve import @librechat/client/style.css".

Replace the startsWith('/') check with path.isAbsolute(id), which is
behavior-identical on POSIX and correct on Windows.

Co-authored-by: phoenixtekk <phoenixtekk@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-13 11:04:46 -04:00

36 lines
1.3 KiB
JavaScript

import path from 'node:path';
import { createRequire } from 'node:module';
import replace from '@rollup/plugin-replace';
import { defineConfig } from 'tsdown';
const require = createRequire(import.meta.url);
const rootPkg = require('../../package.json');
export default defineConfig({
entry: ['src/index.ts', 'src/react-query/index.ts'],
format: ['cjs', 'esm'],
platform: 'neutral',
// Declarations are emitted separately by `tsc -p tsconfig.build.json` (see the
// `build` script). This package's zod schemas aren't `isolatedDeclarations`-clean,
// so oxc/bundled-dts isn't viable; plain tsc keeps the rich types and is the only
// slow step (~2s), while rolldown bundles the JS in ~0.2s.
dts: false,
outDir: 'dist',
sourcemap: true,
deps: {
// Match the prior Rollup build: bundle nothing third-party. Externalize every
// bare import (deps, peers, and node built-ins like `crypto`); bundle only the
// package's own relative/aliased modules.
neverBundle: (id) => !id.startsWith('.') && !path.isAbsolute(id) && !id.startsWith('src/'),
onlyBundle: false,
},
plugins: [
replace({
preventAssignment: true,
values: {
__IS_DEV__: process.env.NODE_ENV === 'development',
__LIBRECHAT_VERSION__: rootPkg.version,
},
}),
],
});