diff --git a/.changeset/kind-plants-tap.md b/.changeset/kind-plants-tap.md new file mode 100644 index 0000000000..09f338c75a --- /dev/null +++ b/.changeset/kind-plants-tap.md @@ -0,0 +1,5 @@ +--- +"trigger.dev": patch +--- + +Fix externals from monorepo packages with scoped package names #1552 diff --git a/packages/cli-v3/src/build/externals.ts b/packages/cli-v3/src/build/externals.ts index 2442a40326..9d9554a91c 100644 --- a/packages/cli-v3/src/build/externals.ts +++ b/packages/cli-v3/src/build/externals.ts @@ -45,6 +45,27 @@ async function linkExternal(external: CollectedExternal, resolveDir: string, log external, }); + // For scoped packages, we need to ensure the scope directory exists + if (external.name.startsWith("@")) { + // Get the scope part (e.g., '@huggingface') + const scopeDir = external.name.split("/")[0]; + + if (scopeDir) { + const scopePath = join(destinationPath, scopeDir); + + logger.debug("[externals] Ensure scope directory exists", { + scopeDir, + scopePath, + }); + + await mkdir(scopePath, { recursive: true }); + } else { + logger.debug("[externals] Unable to get the scope directory", { + external, + }); + } + } + const symbolicLinkPath = join(destinationPath, external.name); // Make sure the symbolic link does not exist