Skip to content

Commit aae47ce

Browse files
Merge pull request #28 from module-federation/fix_build_order
fixing missing paths on dist build
2 parents a84dc1f + ac29c5d commit aae47ce

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,18 @@ const remotes = (isServer) => {
201201
};
202202

203203
const nextConfig = {
204-
// your original next.config.js export
205-
// we attach next internals to share scope at runtime
204+
// your original next.config.js export
205+
// we attach next internals to share scope at runtime
206206

207-
webpack(config, options) {
208-
const {webpack, isServer} = options;
209-
config.module.rules.push({
210-
test: [/_app.[jt]sx?/, /_document.[jt]sx?/],
211-
loader: "@module-federation/nextjs-ssr/lib/federation-loader.js",
212-
});
207+
webpack(config, options) {
208+
const { webpack, isServer } = options;
209+
config.module.rules.push({
210+
test: [/_app.[jt]sx?/, /_document.[jt]sx?/],
211+
loader: "@module-federation/nextjs-ssr/lib/federation-loader.js",
212+
});
213213

214-
return config;
215-
}
214+
return config;
215+
},
216216
};
217217

218218
module.exports = withPlugins(
@@ -225,7 +225,7 @@ module.exports = withPlugins(
225225
"./sampleComponent": "./components/sampleComponent.js",
226226
},
227227
shared: {},
228-
})
228+
}),
229229
],
230230
nextConfig
231231
);

lib/with-federated-sidecar.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -393,22 +393,19 @@ const withModuleFederation =
393393
log.warning(info.warnings);
394394
}
395395
const { chunks } = info;
396-
const distPath = path.join(
397-
compilation.options.context,
398-
nextConfig.distDir
399-
);
396+
const distPath = nextConfig.distDir ? path.join(
397+
compilation.options.context,
398+
nextConfig.distDir
399+
) : compilation.options.output.path
400+
400401
const hasStats = fs.existsSync(
401402
path.join(distPath, "static/federated-stats.json")
402403
);
403404
const hasRemote = fs.existsSync(
404-
path.join(distPath, "static/ssr/remoteEntry.js")
405+
path.join(distPath, "static/ssr/remoteEntry.js")
405406
);
406407
if (hasRemote && hasStats && experiments.flushChunks) {
407-
let remoteEntry = path.join(
408-
distPath,
409-
'static/ssr/remoteEntry.js'
410-
);
411-
408+
let remoteEntry = path.join(distPath, "static/ssr/remoteEntry.js");
412409

413410
const statContent = require(path.join(
414411
distPath,
@@ -460,7 +457,6 @@ const withModuleFederation =
460457
`init: () => (init), chunkMap: () => (${JSON.stringify(
461458
statContent
462459
)}), hash: ()=>(${JSON.stringify(hash)})`
463-
464460
);
465461

466462
process.nextTick(() => {
@@ -507,8 +503,8 @@ const withModuleFederation =
507503
* @returns {import("webpack").Configuration}
508504
*/
509505
webpack(config, options) {
510-
if(!ssr && options.isServer) {
511-
log('SSR Disabled')
506+
if (!ssr && options.isServer) {
507+
log("SSR Disabled");
512508
if (typeof nextConfig.webpack === "function") {
513509
return nextConfig.webpack(config, options);
514510
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"public": true,
33
"name": "@module-federation/nextjs-ssr",
4-
"version": "0.2.0-rc.0",
4+
"version": "0.2.0-rc.1",
55
"description": "Module Federation CSR & SSR Support for Next.js",
66
"main": "bundle.js",
77
"types": "index.d.ts",

streaming/src/NodeModuleFederation/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function buildRemotes(mfConf, webpack) {
114114
const loadTemplate = ${template};
115115
return loadTemplate(remoteConfig)
116116
})`;
117+
117118
acc.buildTime[name] = `promise ${middleware}.then((remoteConfig)=>{
118119
console.log('remoteConfig buildtime',remoteConfig);
119120
global.REMOTE_CONFIG[${JSON.stringify(name)}] = remoteConfig;

0 commit comments

Comments
 (0)