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

feat(mfe): inject local proxy #9356

Merged
merged 18 commits into from
Oct 31, 2024
Merged

Conversation

chris-olszewski
Copy link
Member

@chris-olszewski chris-olszewski commented Oct 30, 2024

Description

This PR adds all support necessary for starting a MFE local proxy:

  • Adds new CommandProvider to allow for multiple strategies for constructing a command depending on the type
  • Adds parsing logic for micro-frontends.jsonc
  • Parses all micro-frontends.jsonc found in the package graph*
  • Adding a task definition for the generated proxy task if MFE configs are found
  • Explicitly include the proxy tasks in engine building step if a MFE dev task is found in the product of the package --filter and the tasks specified in turbo run
  • Adds a CommandProvider that construct a command that invokes the MFE local proxy

⚠️ This currently only support MFE configs that are located in shared packages and doesn't respect a loose MFE configs.

Follow up work:

  • Handle configurable MFE config location

Testing Instructions

In a repository with MFE, run a dev task for one of the configured MFE. This should result in a #proxy task being injected for that MFE and correctly configured to route traffic to the dev tasks or a remote host.

Copy link

vercel bot commented Oct 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 31, 2024 7:13pm
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 7:13pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 7:13pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 7:13pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 7:13pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 7:13pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 7:13pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 7:13pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 7:13pm

Copy link
Member

@tknickman tknickman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, nothing blocking for now

Comment on lines +212 to +213
// TODO: leverage package manager to find the local proxy
let program = package_dir.join_components(&["node_modules", ".bin", "micro-frontends"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

crates/turborepo-lib/src/task_graph/visitor/mod.rs Outdated Show resolved Hide resolved
crates/turborepo-micro-frontend/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@NicholasLYang NicholasLYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, just a couple nits

pub struct CommandFactory<'a> {
providers: Vec<Box<dyn CommandProvider + 'a + Send>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to have more providers than this? It's a little general for two implementations

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we ever want to support additional tasks that don't come from package.json scripts (turbo.json, non-JS, etc) I expect this is where we would put those.

crates/turborepo-lib/src/turbo_json/loader.rs Outdated Show resolved Hide resolved
crates/turborepo-micro-frontend/src/lib.rs Show resolved Hide resolved
crates/turborepo-micro-frontend/src/error.rs Show resolved Hide resolved
@chris-olszewski chris-olszewski enabled auto-merge (squash) October 31, 2024 19:22
@chris-olszewski chris-olszewski merged commit e186685 into main Oct 31, 2024
40 checks passed
@chris-olszewski chris-olszewski deleted the olszewski/feat_mfe_local_proxy branch October 31, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants