fix: skip optional bundled clusters in metadata copy

This aligns the filtering logic in copy-bundled-plugin-metadata.mjs with
tsdown.config.ts so skip optional bundled clusters that are not
included in the current build configuration.

This prevents the creation of dist/extensions/*/package.json files that
point to non-existent index.js files.
This commit is contained in:
Burlesque1 2026-03-19 14:53:49 +08:00
parent c5c2416ec2
commit 75217d645c

View File

@ -1,6 +1,7 @@
import fs from "node:fs";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { shouldBuildBundledCluster } from "./lib/optional-bundled-clusters.mjs";
import {
removeFileIfExists,
removePathIfExists,
@ -176,6 +177,11 @@ export function copyBundledPluginMetadata(params = {}) {
if (!dirent.isDirectory()) {
continue;
}
// Skip optional bundled clusters that are not included in this build.
// This matches the filtering logic in tsdown.config.ts.
if (!shouldBuildBundledCluster(dirent.name, process.env)) {
continue;
}
sourcePluginDirs.add(dirent.name);
const pluginDir = path.join(extensionsRoot, dirent.name);