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: add step 4 exercises, code and slides #27

Merged
merged 3 commits into from
Jul 20, 2023
Merged

Conversation

bredikhin
Copy link
Collaborator

No description provided.

@bredikhin bredikhin self-assigned this Jul 19, 2023

# Running Demo

Make sure that you have installed all dependencies by running `yarn install` from the **root folder of the workshop**!
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use plain npm instead of yarn?
Just to reduce the amount of software needed to run this workshop. Does it gives any benefit in this context?

Copy link
Collaborator

Choose a reason for hiding this comment

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

For now for easier handling of monorepo inside of monorepo cases as well as incremental approach of this workshop we should stick with yarn (it handles it a bit better) but I agree that down the line maybe we should try to simplify this and revert to plain npm at some point but that will take some additional work. At least we are not using docker in this workshop which makes it much lighter than some other ones.

shared: {
react: {
requiredVersion:
require('./package.json').dependencies.react,
Copy link
Contributor

Choose a reason for hiding this comment

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

can we require the package.json just once?

Copy link
Contributor

@ilteoood ilteoood Jul 19, 2023

Choose a reason for hiding this comment

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

maybe doing something like this on top of this file:

const packageJsonDependencies = require('./package.json').dependencies

}
return config
},
// your original next.config.js export
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this comment is useless now

@@ -754,6 +754,100 @@ module.exports = {

---

# Step 4: Setting up Shared Modules Example
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 planning to write somewhere that currently MF does not support Next's app directory structure?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

interesting, could you elaborate a little bit? is there a link I can take a look at?

const HtmlWebpackPlugin = require('html-webpack-plugin')
const ModuleFederationPlugin =
require('webpack').container.ModuleFederationPlugin
const deps = require('./package.json').dependencies
Copy link
Contributor

Choose a reason for hiding this comment

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

is this import used?

"lint": "next lint"
},
"dependencies": {
"@module-federation/nextjs-mf": "5.2.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

This version of the plugin is too old, the newest one is 7.0.6

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point. I tried 7.0.6 initially while working on a different exercise, but something wasn't working out of the box, so we used a different version in all the exercises. since the plugin is still somewhat experimental, I created a separate ticket to upgrade across all the exercises: #32

import LayoutBox from '../components/nextjs-layout-box'
import Table from '../components/nextjs-table'

const Nav = dynamic(() => import('remote/Nav'), {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for the future: next's dynamic should be replaced with plain react's dynamic import on the new versions of the plugin (I'm sure about this for v7, I don't remember if it's the same for v6)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good to know, thanks!

"version": "1.0.0",
"private": true,
"dependencies": {
"react": "18.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intended to use two different react versions? On next we are using version 18.2.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch! I changed it to test the singleton warning, but forgot to change back. 😬 thanks! 🙏

>
<ul>
{ links.map((link, i) => (
<li key={i} style={{display: "inline-block", padding: "10px 20px" }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

ok, this is just an example, but using an index as a key is not the best

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, but as noticed it is just for this example purposes.

shared: {
react: {
requiredVersion:
require('./package.json').dependencies.react,
Copy link
Contributor

Choose a reason for hiding this comment

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

import the package json only once pls

Copy link
Collaborator Author

@bredikhin bredikhin left a comment

Choose a reason for hiding this comment

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

@ilteoood huge thanks for the feedback 🙏 I hope everything is addressed now

"version": "1.0.0",
"private": true,
"dependencies": {
"react": "18.1.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch! I changed it to test the singleton warning, but forgot to change back. 😬 thanks! 🙏

import LayoutBox from '../components/nextjs-layout-box'
import Table from '../components/nextjs-table'

const Nav = dynamic(() => import('remote/Nav'), {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good to know, thanks!

@@ -754,6 +754,100 @@ module.exports = {

---

# Step 4: Setting up Shared Modules Example
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

interesting, could you elaborate a little bit? is there a link I can take a look at?

"lint": "next lint"
},
"dependencies": {
"@module-federation/nextjs-mf": "5.2.1",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point. I tried 7.0.6 initially while working on a different exercise, but something wasn't working out of the box, so we used a different version in all the exercises. since the plugin is still somewhat experimental, I created a separate ticket to upgrade across all the exercises: #32

Copy link
Collaborator

@mristic505 mristic505 left a comment

Choose a reason for hiding this comment

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

Thank you ilteoood for your feedback, it is greatly appreciated! And thank you bredikhin for addressing it!

LGTM now

@mristic505 mristic505 merged commit 8078937 into master Jul 20, 2023
@bredikhin bredikhin deleted the feat-step-4 branch July 20, 2023 20:15
@bredikhin bredikhin mentioned this pull request Jul 20, 2023
2 tasks
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.

3 participants