Skip to content

Commit

Permalink
Merge pull request #28 from module-federation/fix_build_order
Browse files Browse the repository at this point in the history
fixing missing paths on dist build
  • Loading branch information
ScriptedAlchemy authored Jun 21, 2022
2 parents a84dc1f + ac29c5d commit aae47ce
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,18 @@ const remotes = (isServer) => {
};

const nextConfig = {
// your original next.config.js export
// we attach next internals to share scope at runtime
// your original next.config.js export
// we attach next internals to share scope at runtime

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

return config;
}
return config;
},
};

module.exports = withPlugins(
Expand All @@ -225,7 +225,7 @@ module.exports = withPlugins(
"./sampleComponent": "./components/sampleComponent.js",
},
shared: {},
})
}),
],
nextConfig
);
Expand Down
22 changes: 9 additions & 13 deletions lib/with-federated-sidecar.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,22 +393,19 @@ const withModuleFederation =
log.warning(info.warnings);
}
const { chunks } = info;
const distPath = path.join(
compilation.options.context,
nextConfig.distDir
);
const distPath = nextConfig.distDir ? path.join(
compilation.options.context,
nextConfig.distDir
) : compilation.options.output.path

const hasStats = fs.existsSync(
path.join(distPath, "static/federated-stats.json")
);
const hasRemote = fs.existsSync(
path.join(distPath, "static/ssr/remoteEntry.js")
path.join(distPath, "static/ssr/remoteEntry.js")
);
if (hasRemote && hasStats && experiments.flushChunks) {
let remoteEntry = path.join(
distPath,
'static/ssr/remoteEntry.js'
);

let remoteEntry = path.join(distPath, "static/ssr/remoteEntry.js");

const statContent = require(path.join(
distPath,
Expand Down Expand Up @@ -460,7 +457,6 @@ const withModuleFederation =
`init: () => (init), chunkMap: () => (${JSON.stringify(
statContent
)}), hash: ()=>(${JSON.stringify(hash)})`

);

process.nextTick(() => {
Expand Down Expand Up @@ -507,8 +503,8 @@ const withModuleFederation =
* @returns {import("webpack").Configuration}
*/
webpack(config, options) {
if(!ssr && options.isServer) {
log('SSR Disabled')
if (!ssr && options.isServer) {
log("SSR Disabled");
if (typeof nextConfig.webpack === "function") {
return nextConfig.webpack(config, options);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"public": true,
"name": "@module-federation/nextjs-ssr",
"version": "0.2.0-rc.0",
"version": "0.2.0-rc.1",
"description": "Module Federation CSR & SSR Support for Next.js",
"main": "bundle.js",
"types": "index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions streaming/src/NodeModuleFederation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function buildRemotes(mfConf, webpack) {
const loadTemplate = ${template};
return loadTemplate(remoteConfig)
})`;

acc.buildTime[name] = `promise ${middleware}.then((remoteConfig)=>{
console.log('remoteConfig buildtime',remoteConfig);
global.REMOTE_CONFIG[${JSON.stringify(name)}] = remoteConfig;
Expand Down

0 comments on commit aae47ce

Please sign in to comment.