Giter Club home page Giter Club logo

Comments (6)

brunocabral88 avatar brunocabral88 commented on June 27, 2024 1

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.

stevebrowndotco avatar stevebrowndotco commented on June 27, 2024 1

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.

ScriptedAlchemy avatar ScriptedAlchemy commented on June 27, 2024 1

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.

ScriptedAlchemy avatar ScriptedAlchemy commented on June 27, 2024

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.

beratbayram avatar beratbayram commented on June 27, 2024

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.

#1102 (comment)

from universe.

github-actions avatar github-actions commented on June 27, 2024

Stale issue message

from universe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.