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): factor in configs to hashes #9582

Merged

Conversation

chris-olszewski
Copy link
Member

Description

Start factoring in any MFE configs found into task hashes so changes to the config will invalidate any applications that are a part of a MFE setup.

⚠️ We achieve this by adding this to the global cache. This is sub-optimal as it means tasks unrelated to MFEs get invalidated, but we make this temporary trade off in favor of correctness. See TODO for the planned path forward.

Testing Instructions

Added unit tests, verified that changing a MFE config file will now invalidates all MFE apps:

[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/front $ turbo_dev --skip-infer microfrontends-example-docs#build --output-logs=hash-only
turbo 2.3.4-canary.1

• Running microfrontends-example-docs#build in 84 packages
• Remote caching enabled
@vercel/microfrontends:build: cache hit (outputs already on disk), suppressing logs ea832ad348202d61
microfrontends-example-docs:build: cache hit (outputs already on disk), suppressing logs 2775f59cd3c9f808

 Tasks:    2 successful, 2 total
Cached:    2 cached, 2 total
  Time:    563ms >>> FULL TURBO

[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/front $ vim apps/microfrontends-example-web/microfrontends.json 
[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/front $ git diff
diff --git a/apps/microfrontends-example-web/microfrontends.json b/apps/microfrontends-example-web/microfrontends.json
index 0a6883bfc62..13d73b0d47c 100644
--- a/apps/microfrontends-example-web/microfrontends.json
+++ b/apps/microfrontends-example-web/microfrontends.json
@@ -28,7 +28,7 @@
         },
         {
           "group": "docs",
-          "paths": ["/docs"]
+          "paths": ["/docs", "/other"]
         }
       ]
     }
[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/front $ turbo_dev --skip-infer microfrontends-example-docs#build --output-logs=hash-only
turbo 2.3.4-canary.1

• Running microfrontends-example-docs#build in 84 packages
• Remote caching enabled
@vercel/microfrontends:build: cache hit, suppressing logs 51679cdd0650be9f
microfrontends-example-docs:build: cache miss, executing b0641267d9eb8cef

 Tasks:    2 successful, 2 total
Cached:    1 cached, 2 total
  Time:    8.936s 


Copy link

vercel bot commented Dec 6, 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 Dec 6, 2024 7:02pm
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Dec 6, 2024 7:02pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Dec 6, 2024 7:02pm
examples-gatsby-web ⬜️ Ignored (Inspect) Dec 6, 2024 7:02pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Dec 6, 2024 7:02pm
examples-native-web ⬜️ Ignored (Inspect) Dec 6, 2024 7:02pm
examples-svelte-web ⬜️ Ignored (Inspect) Dec 6, 2024 7:02pm
examples-tailwind-web ⬜️ Ignored (Inspect) Dec 6, 2024 7:02pm
examples-vite-web ⬜️ Ignored (Inspect) Dec 6, 2024 7:02pm

@chris-olszewski chris-olszewski marked this pull request as ready for review December 6, 2024 19:02
@chris-olszewski chris-olszewski requested a review from a team as a code owner December 6, 2024 19:02
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.

Looks good, there may be even more changes here so this is a good approach to unblock for now.

@chris-olszewski chris-olszewski merged commit f55f520 into main Dec 9, 2024
36 checks passed
@chris-olszewski chris-olszewski deleted the olszewski/feat_mfe_invalidate_on_config_change branch December 9, 2024 18:54
chris-olszewski added a commit that referenced this pull request Dec 12, 2024
### Description

We had a bug where if there were multiple MFE configs that contained the
same application we would defer to config name ordering for which config
would get selected. This PR makes it so we now select the newest
versioned configuration.

⚠️ Fix a bug I introduced in
#9582 where I cast the relative
unix path to a basic `str` and I then misused it with `join_component`.

### Testing Instructions

Updated and added unit tests. Tested on a repo with multiple overlapping
configs with different versions.
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.

2 participants