Skip to content

Commit

Permalink
fix(mfe): build either mfe package name
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-olszewski committed Nov 22, 2024
1 parent c183599 commit 67b03b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 6 additions & 5 deletions crates/turborepo-lib/src/turbo_json/loader.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::collections::HashMap;

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 +185,12 @@ 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())
.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

0 comments on commit 67b03b1

Please sign in to comment.