Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mfe): build either mfe package name #9494

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions crates/turborepo-lib/src/turbo_json/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use itertools::Itertools;
use tracing::debug;
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf};
use turborepo_errors::Spanned;
use turborepo_micro_frontend::MICRO_FRONTENDS_PACKAGE_INTERNAL;
use turborepo_micro_frontend::MICRO_FRONTENDS_PACKAGES;
use turborepo_repository::{
package_graph::{PackageInfo, PackageName},
package_json::PackageJson,
Expand Down Expand Up @@ -186,10 +186,15 @@ impl TurboJsonLoader {
Error::NoTurboJSON => Ok(TurboJson::default()),
err => Err(err),
})?;
let needs_proxy_build = packages
let mfe_package_name = packages
.keys()
.contains(&PackageName::from(MICRO_FRONTENDS_PACKAGE_INTERNAL));
turbo_json.with_proxy(needs_proxy_build);
.filter(|package| MICRO_FRONTENDS_PACKAGES.contains(&package.as_str()))
.map(|package| package.as_str())
// If multiple MFE packages are present in the graph, then be deterministic
// in which ones we select
.sorted()
.next();
turbo_json.with_proxy(mfe_package_name);
Ok(turbo_json)
} else {
turbo_json
Expand Down
7 changes: 3 additions & 4 deletions crates/turborepo-lib/src/turbo_json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use serde::{Deserialize, Serialize};
use struct_iterable::Iterable;
use turbopath::AbsoluteSystemPath;
use turborepo_errors::Spanned;
use turborepo_micro_frontend::MICRO_FRONTENDS_PACKAGE_INTERNAL;
use turborepo_repository::package_graph::ROOT_PKG_NAME;
use turborepo_unescape::UnescapedString;

Expand Down Expand Up @@ -611,7 +610,7 @@ impl TurboJson {
}

/// Adds a local proxy task to a workspace TurboJson
pub fn with_proxy(&mut self, needs_proxy_build: bool) {
pub fn with_proxy(&mut self, mfe_package_name: Option<&str>) {
if self.extends.is_empty() {
self.extends = Spanned::new(vec!["//".into()]);
}
Expand All @@ -620,9 +619,9 @@ impl TurboJson {
TaskName::from("proxy"),
Spanned::new(RawTaskDefinition {
cache: Some(Spanned::new(false)),
depends_on: needs_proxy_build.then(|| {
depends_on: mfe_package_name.map(|mfe_package_name| {
Spanned::new(vec![Spanned::new(UnescapedString::from(format!(
"{MICRO_FRONTENDS_PACKAGE_INTERNAL}#build"
"{mfe_package_name}#build"
)))])
}),
..Default::default()
Expand Down
Loading