/**
 * Platform build contract for every @platform-modules/* module.
 *
 * One place that fixes: ESM-only output, ES2022 target, emitted .d.ts,
 * tree-shaken bundles (matches `sideEffects: false`), clean dist per build.
 * Consumers pass only what differs per module:
 *   - `entry`       the subpath entrypoints (one for leaf modules, many for fan-out)
 *   - `neverBundle` peers + workspace deps the consumer must bring
 *
 * `deps.neverBundle` is set only when provided. Consumed raw (.ts) by
 * tsdown's config loader, so no tooling prebuild is required.
 */
export function tsdownBase(options) {
    return {
        entry: options.entry,
        format: ['esm'],
        target: 'es2022',
        fixedExtension: false,
        dts: true,
        clean: true,
        treeshake: true,
        ...(options.neverBundle
            ? { deps: { neverBundle: options.neverBundle } }
            : {}),
    };
}
