Skip to content

Fix react 18 example #3125

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

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jobs:
- name: Create matrix
id: set-matrix
run: |
npm install lerna -g
matrix="$(node checkChangedWorkspaces.js)"
echo "matrix=$matrix" >> $GITHUB_OUTPUT

Expand Down Expand Up @@ -135,7 +136,7 @@ jobs:
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ env.CACHE_PATH }}
path: ${{ env.CACHE_PATH }}
key: e2e-cache-${{ steps.yarn-hash.outputs.yarnHash }}

- name: Check disk space before install
Expand Down Expand Up @@ -194,7 +195,7 @@ jobs:
restore-keys: |
e2e-cache-
e2e-

- name: Install deps
if: steps.yarn-cache.outputs.cache-hit != 'true'
env:
Expand Down
5 changes: 2 additions & 3 deletions checkChangedWorkspaces.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const { exec } = require("child_process");
exec("yarn list:all", (error, stdout, stderr) => {
exec("npx lerna ls --all --json", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
console.log('ou', stdout);
try {
const allPackages = JSON.parse(stdout);
exec("yarn list:changed", (error, stdout, stderr) => {
exec("npx lerna ls --all --since=origin/master --json", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
Expand Down
3 changes: 1 addition & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"version": "0.0.0",
"npmClient": "yarn",
"useWorkspaces": true
"npmClient": "yarn"
}
12 changes: 3 additions & 9 deletions react-18-ssr/remote1/config/module-federation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const deps = require('../package.json').dependencies;
const { ModuleFederationPlugin } = require('webpack').container;
const { NodeFederationPlugin, StreamingTargetPlugin } = require('@module-federation/node');
const { UniversalFederationPlugin } = require('@module-federation/node');

module.exports = {
client: new ModuleFederationPlugin({
Expand All @@ -25,10 +25,11 @@ module.exports = {
},
}),
server: [
new NodeFederationPlugin({
new UniversalFederationPlugin({
name: 'remote1',
filename: 'remoteEntry.js',
library: { type: 'commonjs-module' },
isServer: true,
remotes: {
remote2: 'remote2@http://localhost:3002/server/remoteEntry.js',
},
Expand All @@ -47,12 +48,5 @@ module.exports = {
},
},
}),
new StreamingTargetPlugin({
name: 'remote1',
library: { type: 'commonjs-module' },
remotes: {
remote2: 'remote2@http://localhost:3002/server/remoteEntry.js',
},
}),
],
};
2 changes: 1 addition & 1 deletion react-18-ssr/remote1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@babel/preset-env": "7.21.4",
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "7.21.4",
"@module-federation/node": "0.12.2",
"@module-federation/node": "1.0.5",
"@types/react": "18.0.38",
"@types/react-dom": "18.0.11",
"babel-loader": "8.2.5",
Expand Down
10 changes: 3 additions & 7 deletions react-18-ssr/remote2/config/module-federation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const deps = require('../package.json').dependencies;
const { ModuleFederationPlugin } = require('webpack').container;
const { NodeFederationPlugin, StreamingTargetPlugin } = require('@module-federation/node');
const {UniversalFederationPlugin } = require('@module-federation/node');

module.exports = {
client: new ModuleFederationPlugin({
Expand All @@ -23,8 +23,9 @@ module.exports = {
},
}),
server: [
new NodeFederationPlugin({
new UniversalFederationPlugin({
name: 'remote2',
isServer: true,
filename: 'remoteEntry.js',
library: { type: 'commonjs-module' },
remotes: {},
Expand All @@ -43,10 +44,5 @@ module.exports = {
},
},
}),
new StreamingTargetPlugin({
name: 'remote2',
library: { type: 'commonjs-module' },
remotes: {},
}),
],
};
2 changes: 1 addition & 1 deletion react-18-ssr/remote2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@babel/preset-env": "7.21.4",
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "7.21.4",
"@module-federation/node": "0.12.2",
"@module-federation/node": "1.0.5",
"@types/react": "18.0.38",
"@types/react-dom": "18.0.11",
"babel-loader": "8.2.5",
Expand Down
12 changes: 3 additions & 9 deletions react-18-ssr/shell/config/module-federation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const deps = require('../package.json').dependencies;
const { ModuleFederationPlugin } = require('webpack').container;
const { NodeFederationPlugin, StreamingTargetPlugin } = require('@module-federation/node');
const { UniversalFederationPlugin } = require('@module-federation/node');

module.exports = {
client: new ModuleFederationPlugin({
Expand All @@ -12,21 +12,15 @@ module.exports = {
shared: [{ react: deps.react, 'react-dom': deps['react-dom'] }],
}),
server: [
new NodeFederationPlugin({
new UniversalFederationPlugin({
name: 'shell',
isServer: true,
library: { type: 'commonjs-module' },
filename: 'remoteEntry.js',
remotes: {
remote1: 'remote1@http://localhost:3001/server/remoteEntry.js',
},
shared: [{ react: deps.react, 'react-dom': deps['react-dom'] }],
}),
new StreamingTargetPlugin({
name: 'shell',
library: { type: 'commonjs-module' },
remotes: {
remote1: 'remote1@http://localhost:3001/server/remoteEntry.js',
},
}),
],
};
2 changes: 1 addition & 1 deletion react-18-ssr/shell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@babel/preset-env": "7.21.4",
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "7.21.4",
"@module-federation/node": "0.12.2",
"@module-federation/node": "1.0.5",
"@types/express": "4.17.14",
"@types/react": "18.0.38",
"@types/react-dom": "18.0.11",
Expand Down
31 changes: 17 additions & 14 deletions react-18-ssr/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1954,19 +1954,22 @@
npmlog "^4.1.2"
write-file-atomic "^2.3.0"

"@module-federation/node@0.12.2":
version "0.12.2"
resolved "https://registry.yarnpkg.com/@module-federation/node/-/node-0.12.2.tgz#9abf138ef579692ffd316e0b44e7bd69bb512fd2"
integrity sha512-eh2hq5cx92S7S1Y9Vp/OVpbzEmWhiBIcSWaUf9kUqyjNpH5pzMgh9cX6Etp2hn63OFv2SaYvZ84h0rqrf/C7VA==
"@module-federation/node@1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@module-federation/node/-/node-1.0.5.tgz#29cbb4a1128da2e26609bec6c857a3d5b78a2ec4"
integrity sha512-9NH9GE3uEIcL5laJKJgdyCk1n1mvn2ROFE3HdmHvQNfSsBDHKW3yBjYk0aOSvW0gelhEMVeltpFWqhXy7Q3exg==
dependencies:
"@module-federation/utilities" "1.4.0"
encoding "0.1.13"
node-fetch "2.6.7"
"@module-federation/utilities" "2.0.4"
encoding "^0.1.13"
node-fetch "^2.6.7"
webpack-sources "3.2.3"

"@module-federation/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@module-federation/utilities/-/utilities-1.4.0.tgz#c7b8c6e08262af6377714d94557929a3df67e64e"
integrity sha512-J4KISJvLmFhZEgBhdntn6MWqElWU6vMC/JuQT7MdNe8Apc8qoYis0FKGp4gp8YkIPPhplkQExy2vS14+3KxoJA==
"@module-federation/[email protected]":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@module-federation/utilities/-/utilities-2.0.4.tgz#5fc673101ebfb6f7e8befee0bbbac95170a5b364"
integrity sha512-2youICrL7FWSGGPe+GwZTr5IsNZMdUv6kFRrH+gXV1/TfR1zeQ0y0ixRJUFskOt22nSeH6fOEhiCuqIWD1dQGQ==
dependencies:
webpack-sources "3.2.3"

"@mrmlnc/readdir-enhanced@^2.2.1":
version "2.2.1"
Expand Down Expand Up @@ -3685,7 +3688,7 @@ encodeurl@~1.0.2:
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59"
integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==

[email protected].13, encoding@^0.1.11:
encoding@^0.1.11, encoding@^0.1.13:
version "0.1.13"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9"
integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==
Expand Down Expand Up @@ -5806,7 +5809,7 @@ node-fetch-npm@^2.0.2:
json-parse-better-errors "^1.0.0"
safe-buffer "^5.1.1"

node-fetch@2.6.7, node-fetch@^2.5.0, node-fetch@^2.6.7:
node-fetch@^2.5.0, node-fetch@^2.6.7:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
Expand Down Expand Up @@ -8074,7 +8077,7 @@ [email protected], webpack-merge@^5.7.3:
clone-deep "^4.0.1"
wildcard "^2.0.0"

webpack-sources@^3.2.3:
webpack-sources@3.2.3, webpack-sources@^3.2.3:
version "3.2.3"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==
Expand Down