Giter Club home page Giter Club logo

Comments (9)

gigabo avatar gigabo commented on May 2, 2024 1

YAWP

๐Ÿ˜† ... ๐Ÿ˜‚ ... ๐Ÿ˜ข

from react-server.

roblg avatar roblg commented on May 2, 2024

We actually implemented something like this internally that sounds similar to option 2. We have a roughly five line webpack plugin that outputs a file called assetsByChunkName.json that we use to tell the server about the entrypoints. For lazy-loaded JS bundles, webpack keeps its own mappings internally, and just knows what files to load. AFAIK, we don't use the assetsByChunkName.json file on the client at all. (cc @bartkusa, who worked on this originally)

from react-server.

aickin avatar aickin commented on May 2, 2024

Thanks, @roblg!

For lazy-loaded JS bundles, webpack keeps its own mappings internally, and just knows what files to load.

FYI, the Medium article I linked to above explains that this is not enough to keep the hashes constant from build to build; any change to any module changes all the hashes of all entry chunks, even if the entry chunk doesn't include that module. You have to use ChunkManifestPlugin as well; see the section on "Deterministic Hashes".

Any thoughts on using HTTP(S) to download a manifest when the client build is being served up by another server?

from react-server.

roblg avatar roblg commented on May 2, 2024

Interesting. We definitely expected to have issues w/ non-deterministic behavior, and looked for it, and didn't find it. Although I think we were worried about hashes changing for no reasons. Maybe they all change if any file changes? I don't recall if we checked for that (but @bartkusa may remember).

There's a comment from sokra on the issue linked in the blog post saying that occurrence order is the default. (And then some comments from people after that saying they're still experiencing the issue, though maybe in very particular circumstances.) So maybe it's fixed, maybe not? If we can get away with not adding a dependency on YAWP (Yet Another Webpack Plugin), that would be my preference. IME, the more plugins you have in the build, the more bugs you find in plugins in the build. :)

In any event, to answer your actual question: I don't think see a problem with downloading the file from the static content server at startup.

Alternatively, what's preventing us from just outputting the file in the frontend build, and then having that file copied into the server deploy tar or whatever as a step outside r-s-c? Just convenience?

from react-server.

aickin avatar aickin commented on May 2, 2024

Although I think we were worried about hashes changing for no reasons. Maybe they all change if any file changes?

Yeah, this issue is not about non-determinism from one build to the next when the code doesn't change. It's about a small code change changing all hashes for all chunks, including completely unrelated ones. To quote the article:

The problem with this is the same as before: whenever we change any part of the code, it will, even if the rest of its contents wasnโ€™t altered, update our entry chunk to include the new manifest.

The problem is that every entry chunk keeps a map of all chunk names, which of course includes the chunk hashes in the chunk names. So, when any chunk changes, its hash changes, which means that the chunk name map changes, which changes the text of the entry chunk, which changes the entry chunk's hash. Yay.

There's a comment from sokra on the issue linked in the blog post saying that occurrence order is the default. (And then some comments from people after that saying they're still experiencing the issue, though maybe in very particular circumstances.) So maybe it's fixed, maybe not?

Occurrence order is a different problem, which can cause hashes to change between different builds of the same codebase. You also need the OccurrenceOrderPlugin (which also is in the linked article).

In that thread, sokra says it's on by default in the next major version (i.e. webpack 2), which is confirmed in this webpack 2 feature list.

what's preventing us from just outputting the file in the frontend build, and then having that file copied into the server deploy tar or whatever as a step outside r-s-c?

I'm trying to decide what to do when react-server-cli is used to build the client code separately from starting up the HTML server, as described here in the docs. I suppose those instructions could be changed to say something like "step 2.5: Copy manifest.json to your server somewhere" and then "step 3: when you start up the HTML server, pass the manifest file in at the command line using --manifest=location/of/manifest.json along with jsUrl". Is that what you mean?

from react-server.

roblg avatar roblg commented on May 2, 2024

re: determinism - Le sigh. I suppose we probably have a bug to fix now internally as well.

I suppose those instructions could be changed to say something like "step 2.5: Copy manifest.json to your server somewhere" and then "step 3: when you start up the HTML server, pass the manifest file in at the command line using --manifest=location/of/manifest.json along with jsUrl".

Yep, that's what I was thinking. That's basically what we do today internally. I'm assuming that there should be another step somewhere in there that's like "copy your server code to <not the static file server>" as well, right? I would think it would go along with that.

from react-server.

gigabo avatar gigabo commented on May 2, 2024

@aickin - Was this covered by #96, or is there more you'd like to see done here?

from react-server.

aickin avatar aickin commented on May 2, 2024

Sorry, yeah, I think this is covered. Closing!

from react-server.

gigabo avatar gigabo commented on May 2, 2024

Thanks!

from react-server.

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.