Comments (6)
I came here to raise an issue but I'm glad I found this one already here :)
I can confirm @ScriptedAlchemy's suggestion (to use [contenthash]) works perfectly fine, as it slightly changes the remoteEntry.js
file to point to the new hashed chunk, causing the revalidate
to detect the changes. 🎉
I will submit a PR to include this detail in the revalidate documentation on https://www.npmjs.com/package/@module-federation/node.
from universe.
Had exactly the same issue. With nextJs, I solved this problem by prepending all of our SSR remoteEntry.js files with a timestamp, for each federated module. Physically in the file, and not with webpack. I achieved this by running a node script on the pipeline after the nextjs build. That was the only way for us to get revalidate working. This is similar to what @ScriptedAlchemy suggests above, but since I'm not sure how to update the plugin without understanding the MF internal code, this was the approach I opted for.
@beratbayram this approach might help you ^^^
edit: nodeJs pipeline script that fixed it for me:
const fs = require('fs');
const filePath = process.argv[2];
const timestamp = Date.now();
const content = `//Timestamp: ${timestamp}\n`;
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error(`Error reading file: ${err}`);
return;
}
const updatedContent = content + data;
fs.writeFile(filePath, updatedContent, err => {
if (err) {
console.error(`Error writing file: ${err}`);
return;
}
Docker:
RUN node update-timestamp.js /app/dist/apps/${APP_NAME}/.next/static/ssr/remoteEntry.js
from universe.
this is a little hacky, but absolutely plausible workaround.
Im likely a week or two away from releasing the v7 plugin interation, and ill ensure theres a solid hashing/busting solution cooked directly into the webpack runtime. in v7 i have my own runtime modules so we can easily write something like this into the remote without patching the asset after the fact (one way i did it before was more or less a webpack plugin equivalent of the code you have demoed)
if youre open to testing out the new major release, its on npm under the "next" tag - this is a major rewrite with almost all the code thrown out and rebuilt. getting some feedback ahead of making v7 the stable release would be helpful as its a large change.
most of the requests im holding to implement in v7 - one unknown is the backward compatibility or interop between 6 and 7.
from universe.
remote hashing should work though. Since all chunks are content hashed, so any change to a module = new chunk hash = detectable change to remote.
Are you using [contenthash] on your chunks?
the other option here is i can adjust the plugin slightly and add some runtime module / comment to the remote container that basically acts like a timestamp, every deploy would have a new hash then, always, even if no change exists
from universe.
I should add that with my SSR-less workaround below there is no problem anymore. In root it still requires a manual page refresh but it is clean and errorless.
from universe.
Stale issue message
from universe.
Related Issues (20)
- @module-federation/runtime loadRemote - Cannot define property Symbol(mf_module_id) HOT 5
- When modifying files (occasionally) or rsbuild.config.ts (must be), the generated product has problems HOT 2
- file not found error HOT 1
- Optimizing the problem of overly long identifiers of the container entry module of the issuerPath in the stats.json file HOT 2
- @module-federation/native-federation-typescript - support destination folder, loadRemote typings and other improvements HOT 7
- Type file missing when using vue-tsc HOT 1
- remote component error in react when this version different HOT 5
- Add documentation / example for including module federation runtime via CDN in browser script tag HOT 4
- Module Federation not working with Content Security Policy (CSP) HOT 9
- getPublicPath or publicPath is not part of ModuleFederationPluginOptions HOT 5
- @mf-types. expose typings for shared modules HOT 1
- Infer shared modules based from the host's manifest file. HOT 2
- Duplicate network request for chunk from multiple entryfiles HOT 4
- Module Federation SSR is incompatible with webpack-node-externals HOT 2
- The remote module is missing on the Window when running in the sandbox of the micro-frontend framework micro-app. HOT 1
- i try to use init() and app cant find module HOT 2
- Using the `revalidate` method to trigger hot reload can cause service crashes
- dts for entries exposed with aliases are not emitting
- Can't create Error Fallback when any Remote fails. HOT 1
- Chrome Extension is not working due to empty `moduleInfo` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from universe.