This assessment is meant to test your skills and understanding of Module Federation in Vue3 using Webpack.
To get started, let's open a Shell
. You can find this in the Tools
in the bottom left corner of this workspace.
Let's install all of our dependencies:
pnpm bootstrap
TIP
: While this is running, continue through this README.
We have four Federated Modules:
shop-global-ui
: Contains global components used by all other modulesshop-category
: Hosts the Category Detail Pageshop-product
: Hosts the Product Detail Pageshop-cart
: Hosts the Cart Page
Each Federated Module has a number of components that it exposes, and others that it consumes:
Module | Exposes |
---|---|
shop-global-ui |
PageContainer |
shop-product |
ProductCard |
shop-product |
ProductListItem |
shop-cart |
CartDialog |
Notice how each component is related to its module. Then, modules that need to display or utilize functionality from those other modules borrow the Components from the respective modules.
Module | Uses |
---|---|
shop-global-ui |
shop_cart/CartDialog |
shop-category |
shop_global_ui/PageContainer |
shop-product |
shop_global_ui/PageContainer |
shop-cart |
shop_global_ui/PageContainer |
shop-category |
shop_product/ProductCard |
shop-cart |
shop_product/ProductListItem |
Let's start by opening a Shell
. You can find this in the Tools
in the bottom left corner of this workspace.
Inside, let's use pnpm
to start webpack for each of our Federated Modules:
pnpm start
Next, let's open up at least one Webview to view our modules.
This assessment is designed to progressively test your skills and understanding of Module Federation in Vue3 using Webpack. As you work through the levels, you’ll ramp up from basic UI updates to integrating APIs and solving complex problems. Ready? Let’s go!
We’ll begin with small but essential UI tweaks. These tasks will help you get comfortable with the codebase and start making meaningful improvements.
Let’s clean up the text in the header and footer to make them more concise.
- Header:
- Shorten
Women's Clothes
toWomen's
- Shorten
Men's Clothes
toMen's
- Shorten
- Footer:
- Remove
Women's
andMen's
from the beginning of each link in their respective categories.
- Remove
TIP
: Small improvements like these can make a big difference in how users interact with your site. You’re off to a great start!
Let’s improve the look and feel of the product cards. Add some hover states to buttons so users know they’re interactive.
You’re adding some nice polish here! Keep it up—your UI is already looking better.
Next, let’s dive into fixing existing components and making them more dynamic.
The Cart Dialog is currently broken and doesn’t open. Your first task is to fix the mechanism that triggers the dialog, so the user can open and close it properly.
HINT
: Double-check the event handling for theCart
button. Sometimes it’s just a small tweak that can get everything working again!
Now that the Cart Dialog can be opened, let’s make it more useful. Add some static components to simulate items in the cart.
- Use the
ProductListItem
component to display static products in the dialog. - At the bottom of the dialog, add a static "Subtotal" with a hardcoded price.
You’re building something functional now! Getting these components into the dialog is a key step toward a fully dynamic cart.
Now that the Cart Dialog is fixed and displays static data, let’s integrate some real API functionality.
Let’s use the available composables to implement the Add to Cart
functionality on the Product Page (:3002
). This task will involve sending a POST request to the cart API to add an item when a user clicks the Add to Cart
button on the product page.
TIP
: Check out the composables that are already available for working with the cart. This is where your backend integration starts!
Next, let’s take the static components from L2 and replace them with dynamic data. You’ll need to send a GET request to retrieve the items added to the cart and display them in the Cart Dialog.
HINT
: Look at the composables you have, and how the static components are structured, then update them to pull in real data from the API. You’re making the cart dynamic!
You’ve made great progress so far! Now, we’ll extend the API integration into other parts of the application.
Set up a simple API that will serve the navigation items. This will allow us to dynamically manage the items in our header and footer.
You’re building a flexible, API-driven navigation system—way to go!
Update the header and footer components to dynamically pull in navigation items from the API you just created. This will make your navigation scalable and easy to maintain.
PRO TIP
: Think about how the API responses map to the existing navigation structure. Keep the logic clean and simple.
This is where the challenge gets real! These tasks will test your ability to work with advanced features and tackle more intricate problems.
Add routing for both product pages and category pages. Ensure users can navigate between pages smoothly, just like in a real-world application.
CHALLENGE ACCEPTED!
: If you can master routing, you’re well on your way to building complete web applications.
Sharing state between federated modules is one of the more complex aspects of Module Federation. You’ll need to ensure that state (like cart data) can be shared across different modules to maintain a consistent user experience.
EXPERT MODE
: You’re almost at the finish line. If you’ve gotten this far, you’re tackling one of the hardest challenges in Module Federation!
Whether you completed L1 or made it all the way to L5, we’re seriously impressed by your progress. Each step you’ve taken has shown off your skills in design, development, and problem-solving.