Skip to content

Commit 9187b5c

Browse files
fix: stabilize federated-css e2e (#4391)
* fix: stabilize federated-css e2e * merge: bring branch up to date with mass-conversion; regen lockfiles
1 parent f223568 commit 9187b5c

Some content is hidden

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

53 files changed

+623
-56
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './combined-pages';

federated-css/consumers-nextjs/any-combination/mf-plugin.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ module.exports = {
1616
requiredVersion: false,
1717
singleton: true,
1818
},
19-
},
20-
extraOptions: {
21-
skipSharingNextInternals: true,
19+
'react-dom': {
20+
requiredVersion: false,
21+
singleton: true,
22+
},
2223
},
2324
};

federated-css/consumers-nextjs/any-combination/next.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const NextFederationPlugin = require('@module-federation/nextjs-mf/lib/NextFederationPlugin');
1+
const { NextFederationPlugin } = require('@module-federation/nextjs-mf');
22
const mfConfig = require('./mf-plugin.config');
33

44
module.exports = {
@@ -8,8 +8,13 @@ module.exports = {
88
test: /\.css$/,
99
use: ['style-loader', 'css-loader'],
1010
});
11+
1112
config.plugins.push(new NextFederationPlugin(mfConfig));
13+
} else {
14+
config.externals = config.externals || [];
15+
config.externals.push(/^expose_/);
1216
}
17+
1318
return config;
1419
},
1520
// your original next.config.js export

federated-css/consumers-nextjs/any-combination/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "@federated-css/next-any-combination",
33
"version": "0.1.0",
44
"scripts": {
5-
"build": "next build",
6-
"start": "next dev -p 8080",
5+
"build": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next build",
6+
"start": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next dev -p 8080",
77
"lint": "next lint"
88
},
99
"dependencies": {
@@ -17,6 +17,7 @@
1717
"devDependencies": {
1818
"@types/react": "18.3.3",
1919
"eslint": "9.6.0",
20-
"eslint-config-next": "14.2.4"
20+
"eslint-config-next": "14.2.4",
21+
"cross-env": "7.0.3"
2122
}
22-
}
23+
}

federated-css/consumers-nextjs/any-combination/pages/_app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import '../utils/ensureNmdPolyfill';
12
import '../styles/globals.css';
23

34
function MyApp({ Component, pageProps }) {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const runtimeNmd = (module) => {
2+
module.paths = module.paths || [];
3+
if (!module.children) {
4+
module.children = [];
5+
}
6+
return module;
7+
};
8+
9+
export const ensureNmdPolyfill = () => {
10+
const runtimes = [];
11+
12+
if (typeof __webpack_require__ === 'function') {
13+
runtimes.push(__webpack_require__);
14+
}
15+
16+
if (
17+
typeof globalThis !== 'undefined' &&
18+
typeof globalThis.__webpack_require__ === 'function'
19+
) {
20+
runtimes.push(globalThis.__webpack_require__);
21+
}
22+
23+
if (typeof Function.prototype.nmd !== 'function') {
24+
Function.prototype.nmd = runtimeNmd;
25+
}
26+
27+
for (const runtime of runtimes) {
28+
if (typeof runtime.nmd !== 'function') {
29+
runtime.nmd = runtimeNmd;
30+
}
31+
}
32+
33+
if (
34+
typeof globalThis !== 'undefined' &&
35+
typeof globalThis.__webpack_require__ !== 'function' &&
36+
runtimes.length > 0
37+
) {
38+
globalThis.__webpack_require__ = runtimes[0];
39+
}
40+
};
41+
42+
ensureNmdPolyfill();
43+
44+
export default ensureNmdPolyfill;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './combined-pages';

federated-css/consumers-nextjs/combination-of-4/mf-plugin.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ module.exports = {
1818
requiredVersion: false,
1919
singleton: true,
2020
},
21-
},
22-
extraOptions: {
23-
skipSharingNextInternals: true,
21+
'react-dom': {
22+
requiredVersion: false,
23+
singleton: true,
24+
},
2425
},
2526
};

federated-css/consumers-nextjs/combination-of-4/next.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const NextFederationPlugin = require('@module-federation/nextjs-mf/lib/NextFederationPlugin');
1+
const { NextFederationPlugin } = require('@module-federation/nextjs-mf');
22
const mfConfig = require('./mf-plugin.config');
33

44
module.exports = {
@@ -8,8 +8,13 @@ module.exports = {
88
test: /\.css$/,
99
use: ['style-loader', 'css-loader'],
1010
});
11+
1112
config.plugins.push(new NextFederationPlugin(mfConfig));
13+
} else {
14+
config.externals = config.externals || [];
15+
config.externals.push(/^expose_/);
1216
}
17+
1318
return config;
1419
},
1520
// your original next.config.js export

federated-css/consumers-nextjs/combination-of-4/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "@federated-css/next-combination-of-4",
33
"version": "0.1.0",
44
"scripts": {
5-
"build": "next build",
6-
"start": "next dev -p 8081",
5+
"build": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next build",
6+
"start": "cross-env NEXT_PRIVATE_LOCAL_WEBPACK=true next dev -p 8081",
77
"lint": "next lint"
88
},
99
"dependencies": {
@@ -17,6 +17,7 @@
1717
"devDependencies": {
1818
"@types/react": "18.3.3",
1919
"eslint": "9.6.0",
20-
"eslint-config-next": "14.2.4"
20+
"eslint-config-next": "14.2.4",
21+
"cross-env": "7.0.3"
2122
}
22-
}
23+
}

0 commit comments

Comments
 (0)