Giter Club home page Giter Club logo

Comments (7)

alexander-akait avatar alexander-akait commented on September 27, 2024 1

I can accept a PR to allow to use hotUpdateGlobal: (chunk) => { return "myOwnName" + chunk.id }

from webpack.

MarioCadenas avatar MarioCadenas commented on September 27, 2024 1

ready #18672

from webpack.

alexander-akait avatar alexander-akait commented on September 27, 2024

Expected, you have multile runtimes on the same page, but the one HMR updating function, your patch doesn't fix the problem really, just workaround for your case (and will break HMR for another cases, when you split your chunks), please use optimization: { runtimeChunk: 'single' }. When you have multiple chunks with own runtime on the same page, you always need to use runtimeChunk: 'single' for HMR.

Feel free to feedback

from webpack.

MarioCadenas avatar MarioCadenas commented on September 27, 2024

Hey @alexander-akait , in our case the problem is that optimization: { runtimeChunk: 'single' } doesn't fit the needs, so that's why I went for that approach. The idea is not that is mandatory or anything, is simply to have the ability to add something in case you have multiple runtimes in the same page (which can be very valid specifically in micro frontend architectures), and in that case having the ability to differentiate the runtimes.

For normal cases it would simply work as it has been working. The patch of course is just a workaround to validate that was the problem, but the idea is being able to maybe provide that way of differentiating the runtimes (even if they are in the same page), that's why I was proposing the usage of [name] or [id] as options that could be provided in output.hotUpdateGlobal or maybe allowing the usage of a function in output.hotUpdateGlobal that can receive the chunk.

Maybe it was wrong to open a bug because this might be more like asking for a feature instead?

Let me know what you think, thanks!

from webpack.

alexander-akait avatar alexander-akait commented on September 27, 2024

Using chunks ids is a bad idea and wrong here, not each chunk has runtime, technical we can allow to setup hotUpdateGlobal: "webpackHotUpdate[unique-name][runtime]" and get the runtime value from https://webpack.js.org/concepts/entry-points/#entrydescription-object

from webpack.

alexander-akait avatar alexander-akait commented on September 27, 2024

But there is a question about entries without runtime, which HMR functions they should be use...

from webpack.

MarioCadenas avatar MarioCadenas commented on September 27, 2024

I see, what can be done to maybe elaborate this a bit more? I would be happy to contribute, I simply lack a lot of the context and cases that need to be covered since webpack is quite a complex tool and covers many cases, but with a bit of guidance/requirements I would be happy to put together a proposal/poc or whatever you think is best, if you think we can try and move this forward of course 😄

Thank you!

from webpack.

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.