Skip to content

Commit e52639b

Browse files
ScriptedAlchemygithub-actions[bot]jherrrenovate-botrenovate[bot]
authored
feat: Write Mode (#179)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jack Herrington <jherr@pobox.com> Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Zack Jackson <zackary.l.jackson@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Paul Damnhorns <pavel.chertorogov@gmail.com> Co-authored-by: Andrew James <13269277+andrew-t-james@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Justin Sunseri <jmsunseri@gmail.com> Co-authored-by: Yoav Ganbar <yoavganbar@gmail.com>
1 parent 91170b8 commit e52639b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+20245
-378
lines changed

Diff for: .changeset/beige-wasps-greet.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@module-federation/dashboard": minor
3+
"@module-federation/dashboard-plugin": minor
4+
---
5+
6+
Write mode and Active module management

Diff for: .changeset/nice-olives-switch.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@module-federation/dashboard": minor
3+
---
4+
5+
Enable Standalone mode

Diff for: .changeset/seven-cougars-drop.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@module-federation/dashboard": minor
3+
---
4+
5+
Adding Mongo Driver, Improving auth and SSO, fix cors and auth api endpoints

Diff for: .changeset/twenty-monkeys-drum.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@module-federation/dashboard": minor
3+
"@module-federation/dashboard-plugin": minor
4+
---
5+
6+
Plugin writes versioned remotes on its own. Fixed dashboard db delays on versioned modules reflecting in BE

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ npm-debug.log*
66
yarn-debug.log*
77
yarn-error.log*
88
lerna-debug.log*
9-
*.lock
109

1110
# Diagnostic reports (https://nodejs.org/api/report.html)
1211
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@@ -108,3 +107,6 @@ buildServer
108107
# TernJS port file
109108
.tern-port
110109
/streamed-federation/.s3rver/
110+
111+
# editors
112+
.vscode

Diff for: .npmignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
.npmrc
2-
.yarnrc
32
*.log

Diff for: dashboard-example/dsl/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
{
22
"name": "@dashboard/dsl",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"private": true,
55
"devDependencies": {
66
"@babel/core": "7.12.3",
77
"@babel/preset-react": "7.12.5",
88
"@module-federation/dashboard-plugin": "*",
99
"babel-loader": "8.2.1",
1010
"css-loader": "5.0.1",
11-
"html-webpack-plugin": "git://github.com/ScriptedAlchemy/html-webpack-plugin#master",
11+
"html-webpack-plugin": "4.5.0",
1212
"less-loader": "7.1.0",
1313
"less": "^3.12.2",
1414
"serve": "11.3.2",
1515
"style-loader": "2.0.0",
1616
"webpack": "5.5.1",
1717
"webpack-cli": "4.2.0",
18+
"@webpack-cli/serve": "1.1.0",
1819
"webpack-dev-server": "3.11.0"
1920
},
2021
"scripts": {
21-
"start": "webpack-dev-server --open --mode development --liveReload",
22+
"start": "node ../../node_modules/webpack-cli/bin/cli.js serve --open --liveReload",
2223
"build": "node ../../node_modules/webpack/bin/webpack.js --mode production",
2324
"serve": "serve dist -p 3002",
2425
"clean": "rm -rf dist"

Diff for: dashboard-example/dsl/src/Button.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React from "react";
2-
32
import { Button } from "antd";
4-
3+
console.log(
4+
"REMOTE FEDERATION MANAGEMENT: using remote version: " +
5+
require("../package.json").version
6+
);
57
const MyButton = ({ children }) => <Button primary>{children}</Button>;
68

79
export default MyButton;

Diff for: dashboard-example/dsl/src/Carousel.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from "react";
22
import { Carousel } from "antd";
3-
alert("this is another version");
43
const MyCarousel = ({ children, ...props }) => {
54
return <Carousel {...props}>{children}</Carousel>;
65
};

Diff for: dashboard-example/dsl/webpack.config.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ module.exports = {
1212
output: {
1313
filename: "[name].[contenthash].js",
1414
chunkFilename: "[name].[contenthash].js",
15-
publicPath: `http://localhost:3002/`,
15+
publicPath: `auto`,
16+
uniqueName: `dsl.${require("./package.json").version}`,
1617
},
1718
module: {
1819
rules: [
@@ -53,8 +54,8 @@ module.exports = {
5354
},
5455
plugins: [
5556
new ModuleFederationPlugin({
56-
name: "dsl",
57-
library: { type: "var", name: "dsl" },
57+
name: "dsl__REMOTE_VERSION__",
58+
library: { type: "var", name: "dsl__REMOTE_VERSION__" },
5859
filename: "remoteEntry.js",
5960
remotes: {},
6061
exposes: {
@@ -69,7 +70,7 @@ module.exports = {
6970
template: "./public/index.html",
7071
}),
7172
new DashboardPlugin({
72-
version: true,
73+
publishVersion: require("./package.json").version,
7374
filename: "dashboard.json",
7475
dashboardURL: "http://localhost:3000/api/update",
7576
metadata: {

Diff for: dashboard-example/home/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "@dashboard/home",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"private": true,
55
"devDependencies": {
66
"@babel/core": "7.12.3",
77
"@babel/preset-react": "7.12.5",
88
"@module-federation/dashboard-plugin": "*",
9+
"@webpack-cli/serve": "^1.1.0",
910
"babel-loader": "8.2.1",
1011
"css-loader": "5.0.1",
1112
"html-webpack-plugin": "^4.5.0",
@@ -18,7 +19,7 @@
1819
"webpack-dev-server": "3.11.0"
1920
},
2021
"scripts": {
21-
"start": "webpack-dev-server --open --mode development --liveReload",
22+
"start": "webpack-cli serve --open --liveReload",
2223
"build": "node ../../node_modules/webpack/bin/webpack.js --mode production",
2324
"serve": "serve dist -p 3001",
2425
"clean": "rm -rf dist"

Diff for: dashboard-example/home/src/index.js

+1-66
Original file line numberDiff line numberDiff line change
@@ -1,66 +1 @@
1-
console.log(process.CURRENT_HOST);
2-
const injectScript = function (d, s, id, override) {
3-
const promise = new Promise((resolve) => {
4-
var js,
5-
fjs = d.getElementsByTagName(s)[0];
6-
if (d.getElementById(id)) {
7-
return;
8-
}
9-
js = d.createElement(s);
10-
js.id = id;
11-
if (override && override.version) {
12-
window[`remote_${override.name}`] = override.version;
13-
}
14-
js.onload = function () {
15-
resolve();
16-
};
17-
const src =
18-
override && override.version
19-
? "http://localhost:3002/" + override.version + "/remoteEntry.js"
20-
: "http://localhost:3002/remoteEntry.js";
21-
js.src = src;
22-
fjs.parentNode.insertBefore(js, fjs);
23-
});
24-
25-
return promise;
26-
};
27-
28-
fetch("http://localhost:3000/api/graphql", {
29-
method: "POST",
30-
headers: {
31-
"Content-Type": "application/json",
32-
Accept: "application/json",
33-
},
34-
body: JSON.stringify({
35-
query: `query { # TODO: this query cannot be executed on current schema
36-
applications(name:"home") {
37-
versions {
38-
override {
39-
name
40-
version
41-
}
42-
}
43-
}
44-
}`,
45-
}),
46-
})
47-
.then((res) => res.json())
48-
.then(({ applications }) => {
49-
if (!applications.versions.override.length) {
50-
injectScript(document, "script", "federation-dynamic-remote").then(() => {
51-
import("./bootstrap");
52-
});
53-
return;
54-
}
55-
const allOverrides = applications.versions.override.map((override) => {
56-
return injectScript(
57-
document,
58-
"script",
59-
"federation-override-" + override.name,
60-
override
61-
);
62-
});
63-
Promise.all(allOverrides).then(() => {
64-
import("./bootstrap");
65-
});
66-
});
1+
import("./bootstrap");

Diff for: dashboard-example/home/webpack.config.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const HtmlWebpackPlugin = require("html-webpack-plugin");
22
const DashboardPlugin = require("@module-federation/dashboard-plugin");
3+
const clientVersion = require("@module-federation/dashboard-plugin/client-version");
34
const {
45
container: { ModuleFederationPlugin },
5-
DefinePlugin,
66
} = require("webpack");
77
const path = require("path");
88

@@ -16,7 +16,7 @@ module.exports = {
1616
output: {
1717
filename: "[name].[contenthash].js",
1818
chunkFilename: "[name].[contenthash].js",
19-
publicPath: `http://localhost:3001/`,
19+
publicPath: `auto`,
2020
},
2121
module: {
2222
rules: [
@@ -62,7 +62,11 @@ module.exports = {
6262
filename: "remoteEntry.js",
6363
remotes: {
6464
search: "search",
65-
dsl: "dsl",
65+
dsl: clientVersion({
66+
currentHost: "home",
67+
remoteName: "dsl",
68+
dashboardURL: "http://localhost:3000/api/graphql",
69+
}),
6670
nav: "nav",
6771
utils: "utils",
6872
},
@@ -77,7 +81,7 @@ module.exports = {
7781
template: "./public/index.html",
7882
}),
7983
new DashboardPlugin({
80-
version: true,
84+
publishVersion: require("./package.json").version,
8185
filename: "dashboard.json",
8286
dashboardURL: "http://localhost:3000/api/update",
8387
versionChangeWebhook: "http://cnn.com/",

Diff for: dashboard-example/nav/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
"@module-federation/dashboard-plugin": "*",
99
"babel-loader": "8.2.1",
1010
"css-loader": "5.0.1",
11-
"html-webpack-plugin": "git://github.com/ScriptedAlchemy/html-webpack-plugin#master",
11+
"html-webpack-plugin": "4.5.0",
1212
"less-loader": "7.1.0",
1313
"less": "^3.12.2",
1414
"serve": "11.3.2",
1515
"style-loader": "2.0.0",
1616
"webpack": "5.5.1",
1717
"webpack-cli": "4.2.0",
18+
"@webpack-cli/serve": "1.1.0",
1819
"webpack-dev-server": "3.11.0"
1920
},
2021
"scripts": {
21-
"start": "webpack-dev-server --open --mode development --liveReload",
22+
"start": "webpack-cli serve --open --liveReload",
2223
"build": "node ../../node_modules/webpack/bin/webpack.js --mode production",
2324
"serve": "serve dist -p 3003",
2425
"clean": "rm -rf dist"

Diff for: dashboard-example/nav/webpack.config.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const HtmlWebpackPlugin = require("html-webpack-plugin");
22
const DashboardPlugin = require("@module-federation/dashboard-plugin");
3+
const clientVersion = require("@module-federation/dashboard-plugin/client-version");
34
const { ModuleFederationPlugin } = require("webpack").container;
45
const path = require("path");
56

@@ -13,7 +14,7 @@ module.exports = {
1314
output: {
1415
filename: "[name].[contenthash].js",
1516
chunkFilename: "[name].[contenthash].js",
16-
publicPath: "http://localhost:3003/",
17+
publicPath: `auto`,
1718
},
1819
module: {
1920
rules: [
@@ -58,7 +59,11 @@ module.exports = {
5859
library: { type: "var", name: "nav" },
5960
filename: "remoteEntry.js",
6061
remotes: {
61-
dsl: "dsl",
62+
dsl: clientVersion({
63+
currentHost: "nav",
64+
remoteName: "dsl",
65+
dashboardURL: "http://localhost:3000/api/graphql",
66+
}),
6267
search: "search",
6368
utils: "utils",
6469
},
@@ -73,7 +78,7 @@ module.exports = {
7378
template: "./public/index.html",
7479
}),
7580
new DashboardPlugin({
76-
version: true,
81+
publishVersion: require("./package.json").version,
7782
filename: "dashboard.json",
7883
dashboardURL: "http://localhost:3000/api/update",
7984
metadata: {

Diff for: dashboard-example/search/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
"@module-federation/dashboard-plugin": "*",
99
"babel-loader": "8.2.1",
1010
"css-loader": "5.0.1",
11-
"html-webpack-plugin": "git://github.com/ScriptedAlchemy/html-webpack-plugin#master",
11+
"html-webpack-plugin": "^4.5.0",
1212
"less-loader": "7.1.0",
1313
"less": "^3.12.2",
1414
"serve": "11.3.2",
1515
"style-loader": "2.0.0",
1616
"webpack": "5.5.1",
1717
"webpack-cli": "4.2.0",
18-
"webpack-dev-server": "3.11.0"
18+
"webpack-dev-server": "3.11.0",
19+
"@webpack-cli/serve": "1.1.0"
1920
},
2021
"scripts": {
21-
"start": "webpack-dev-server --open --mode development --liveReload",
22+
"start": "webpack-cli serve --open --liveReload",
2223
"build": "webpack --mode production",
2324
"serve": "serve dist -p 3004",
2425
"clean": "rm -rf dist"

Diff for: dashboard-example/search/webpack.config.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const HtmlWebpackPlugin = require("html-webpack-plugin");
22
const DashboardPlugin = require("@module-federation/dashboard-plugin");
3+
const clientVersion = require("@module-federation/dashboard-plugin/client-version");
34

45
const { ModuleFederationPlugin } = require("webpack").container;
56
const path = require("path");
@@ -14,7 +15,7 @@ module.exports = {
1415
output: {
1516
filename: "[name].[contenthash].js",
1617
chunkFilename: "[name].[contenthash].js",
17-
publicPath: "http://localhost:3004/",
18+
publicPath: `auto`,
1819
},
1920
module: {
2021
rules: [
@@ -60,7 +61,11 @@ module.exports = {
6061
filename: "remoteEntry.js",
6162
remotes: {
6263
nav: "nav",
63-
dsl: "dsl",
64+
dsl: clientVersion({
65+
currentHost: "search",
66+
remoteName: "dsl",
67+
dashboardURL: "http://localhost:3000/api/graphql",
68+
}),
6469
home: "home",
6570
utils: "utils",
6671
},
@@ -74,7 +79,7 @@ module.exports = {
7479
template: "./public/index.html",
7580
}),
7681
new DashboardPlugin({
77-
version: true,
82+
publishVersion: require("./package.json").version,
7883
filename: "dashboard.json",
7984
dashboardURL: "http://localhost:3000/api/update",
8085
metadata: {

Diff for: dashboard-example/utils/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
"@babel/core": "7.12.3",
77
"@babel/preset-react": "7.12.5",
88
"@module-federation/dashboard-plugin": "*",
9+
"@webpack-cli/serve": "^1.1.0",
910
"babel-loader": "8.2.1",
1011
"serve": "11.3.2",
1112
"webpack": "5.5.1",
1213
"webpack-cli": "4.2.0",
1314
"webpack-dev-server": "3.11.0"
1415
},
1516
"scripts": {
16-
"start": "webpack-dev-server --open --mode development --liveReload",
17+
"start": "webpack-cli serve --open --liveReload",
1718
"build": "node ../../node_modules/webpack/bin/webpack.js --mode production",
1819
"serve": "serve dist -p 3005",
1920
"clean": "rm -rf dist"

0 commit comments

Comments
 (0)