fix(plugins): fall back to src plugin-sdk aliases

This commit is contained in:
Peter Steinberger
2026-03-08 00:18:37 +00:00
parent 4e07bdbdfd
commit bda035768f
2 changed files with 22 additions and 10 deletions

View File

@@ -55,19 +55,15 @@ const resolvePluginSdkAliasFile = (params: {
try {
const modulePath = params.modulePath ?? fileURLToPath(import.meta.url);
const isProduction = process.env.NODE_ENV === "production";
const isTest = process.env.VITEST || process.env.NODE_ENV === "test";
const normalizedModulePath = modulePath.replace(/\\/g, "/");
const isDistRuntime = normalizedModulePath.includes("/dist/");
let cursor = path.dirname(modulePath);
for (let i = 0; i < 6; i += 1) {
const srcCandidate = path.join(cursor, "src", "plugin-sdk", params.srcFile);
const distCandidate = path.join(cursor, "dist", "plugin-sdk", params.distFile);
const orderedCandidates = isDistRuntime
? [distCandidate, srcCandidate]
: isProduction
? isTest
? [distCandidate, srcCandidate]
: [distCandidate]
const orderedCandidates =
isDistRuntime || isProduction
? [distCandidate, srcCandidate]
: [srcCandidate, distCandidate];
for (const candidate of orderedCandidates) {
if (fs.existsSync(candidate)) {