-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concepts - Bundle vs Chunk #970
Comments
I have also grappled with this in the past and came to about the same conclusion. It might be tough to enforce one or the other now as there are so many instances of @TheLarkInn maybe a glossary section somewhere under |
I think this is a good idea! I know it may sound easy to search for such terms but for those unfamiliar or new an easy index of all the keywords/domain specific words used around the web and this site itself could be useful to have if not just to link back to within posts on an automated path to hotlink the words during build process? I went ahead and started one with a few words but didn't get too far just in case it's not wanted by many haha. here is a screen of the glossary branch I've begun. It links all words to their respective pages with more detail. Thoughts? |
@rouzbeh84 I really like this idea and I think adding it under Feel free to PR whenever though, and close this issue (just make sure to include Bundle and Chunk definitions 😉 ). |
@skipjack it could be hot-linked throughout the docs and possibly the last item on the left list for easy access while going throughout? Would it be possible to do add some sort of grepping to the build process that generates all used words on the section and put them in a dropdown style link in the left nav like how most sections are populated now? |
Yeah, I was thinking about the bottom of the sidebar as well. That may be a good fit.
Anything's possible 😆 ... I'm a little confused as to what you mean by adding it to the sidebar. Maybe you can show me an example? I think what would be really cool is if we Let's keep it simple for now and revisit that second part ( Knock down remaining issue count (aka get content into a good place) => Doesn't have to be exactly synchronous like that, in fact @bebraw and I are working on a few non-content-related things currently, but I think in general that should be the plan. |
Sorry if I was unclear about the sidebar. I think we're on the same page as I basically meant adding the collected glossary values of current page to a nested list at the bottom like the other sections have. Possibly with a border above to denote it's a type of constant navigation feature? Probably not needed but this type of thing image of sidebar
This would be really cool!
For sure! I know I'm not too familiar with the build process of this site so just spitballing but will keep it simple for now to get something up and see if it's useful in the first place before altering any build steps. |
Yeah, no worries... I think it would fit in somewhere in the markdown processing but let's just get the page up and loop back to this down the road once the Let's just start by getting that page up, and maybe linking to it from a few places. Ping me once you have something ready for review. |
Nice to find this thread! 😃
@skipjack So they are actually the same, then? I've also been silently questioning this concept for the past 2 years and used to think that |
@dwiyatci Yes I believe they are the same. I had initially thought that "chunks" were analogous with child bundles (similar to your thought that "a bundle is a collection of chunks") but I've also heard the term "entry chunk" used which kind of voids that thought. I'm not an expert though, I would leave the final say to someone from the @webpack/core-team. |
gonna watch this deep dive into code splitting: under the hood by @TheLarkInn and after understanding will add to glossary. In the meantime, according to survivejs
|
@rouzbeh84 you should feel free to pr this page whenever. We can always do follow ups to add and clean up content, doesn't have to be perfect on the first pass. |
Ähmm.., sounds to me the @survivejs definition goes more to a direction of bundle ≈ asset 🙃 |
A bundle can consist of multiple assets especially if you inline some. |
started PR #1223 for this. definitely a help wanted one but should I create a new issue for it with |
@rouzbeh84 let's just leave the PR open for a bit to get feedback and possible additions. I think if we make sure it's visible people will inherently consider adding terms there... there may also be some other open issues that could be resolved using the new glossary. I'm really trying to knock the issue count down bit by bit, so I'm hesitant to open anything new right now as I'd like to keep the focus as much on cleaning up what we have and filling in the missing bits. Once we have things a bit more under control, then yeah opening an issue to discuss more terms might make sense, if that hasn't already happened naturally. I'm reviewing and sorting out some odd build/test errors on your pr now... |
@skipjack yep makes sense on both counts! Any idea why the builds failed? I don't think I saw any errors when submitting it unless I didn't wait long enough. Could it be that the file is new and on the root of |
Nope, the first was a JSON error during the |
I've checked the glossary and the question "bundle vs chunk" still remains for me. Example: Say I have well-known configuration that results in 3 output files ( Questions:
Both the definitions in the glossary don't mention the output files, that ultimately is our goal when building with Webpack, so I don't understand how both concepts map to the output files. |
@rafaeleyng very good questions... let's re-open and figure out a way to better answer those somewhere in the docs. @bebraw I think I have a rough idea on some of these but I'm interested in what you would say as well...
Just 1 -- the css file as it was extracted out of the main bundle. Even though it's still a bunch of css files concatenated I think it counts more as an asset in webpack's view than a bundle.
2 -- both the
Likely just 2 entry chunks but I think the correct answer here is that this is actually unknown. Chunks can be joined together so I think
I think this is answered above but basically the output js files are bundles. Chunks would be what you declared as your entry points and any children of those entry points. There is definitely some overlap there but I think the point is it's not always a direct mapping from chunk => bundle.
Answered above. Again, not sure if these are all on the money, just my current understanding. |
@skipjack Thanks a lot. So, as I see:
In my idea above of what a chunk is, is it possible to, looking only at the output code, identify the chunks inside the bundles? Is there some marking that separates one chunk from the other? |
Yes a chunk is a object oriented encapsulation of modules inside of the dependency graph. Really bundle was a term adopted by the community. Really a chunk takes all or a subtree of your modules in the deep graph. This allows chunkTemplate to render the wrapper around the modules when it is created and emitted to output directory. |
In this article by @sokra it says (highlights are mine):
So, we have "multiple chunks" (which I still don't know what are, at this moment, whether they are the files or just parts of the code inside the files). But the second highlight is even more confusing, because it says that every chunk will be loaded by multiple script-tags, so I understand from this that the same chunk might be splitted across several files (1 chunk in N files). With that, I give up trying to understand the relationship between chunks/bundles/files. To sum up, I suggest coming up with good, unequivocal definitions for these terms, and keep in mind that whoever reads the glossary knows very little about webpack internals, so is important not to assume previous knowledge or use terms that need themselves further definitions. |
I'm pretty sure he means a script tag is needed to load each of the multiple chunks he mentioned in the previous statement. I agree the wording is not perfect. I think your initial thought...
is correct. And the answer to:
is no. @TheLarkInn @sokra can you clarify?
Sure, let's see what the rest of the team says and then we can update the glossary definitions and potentially some concept pages to reflect this discussion. |
A couple of quick points:
Maybe the problem with the concept of chunk is that the term comes from webpack internals and the way it works. So unless you know what |
I'll try to paint this as clear as possible in the simplest explanation: A chunk is a bundle.Yes a chunk is a bundle. There are three classifications of
|
Thanks for the discussion guys, it did help to clarify the topic. |
@rafaeleyng so based on the discussion do you think the glossary descriptions (or any other piece of the docs) should be updated? If so, any ideas on how to alter those descriptions to clarify things? We'd definitely welcome a PR if you're interested in submitting one. |
@skipjack I would like to submit the PR, but to be honest, I still don't fully understand the difference. I just didn't want to push the discussion further. Didn't want to be too picky, you know. I think the only way for me to understand to the level that I would like is to study deeply the code, but I don't see that happening anytime soon. |
@rafaeleyng yea I totally understand, I think the discussion did help a bit but we definitely didn't reach a super-concise answer to this question. I'll discuss with the team a bit more and maybe take a stab at improving the definitions myself. |
I appreciate the discussion but there are literally conflicting responses in here - even from some of the webpack people themselves. TheLarkInn says a chunk is a bundle, while bebrawb says bundles contain chunks. Also, this post [https://github.com//issues/970#issuecomment-305216411 ] from TheLarkInn unfortunately confuses me further by bringing up new terminology and raises even more questions in my mind. I think it's easy for the people deep in webpack to lose sight of how confusing these "internal" terms are to people who just want to use the tool and don't live/breath/dream bundling. |
I too, agree not to understand, in case my understanding should somehow become 'an understanding'... or fail to become one. The fact that plugin writer's toss these terms about as well, but do so with more apparent assurance that this chain, indicates to me that chunk and bundle have an input/output relationship. But 'asset' merely 'is an instance', as in 'object is an instance'. However, an asset can appear to 'become' a chunk or a bundle if 'inlined', though it seems that an asset would be a trivial instance of one or the other. But yes... it's clear that 'bundle' has to exist as an output of a 'bundler' since it engages in 'bundling'. And webpack's existence makes bundling a first-class concept. Therefore a 'chunk', if it exists, must be the output of a 'chunker' that must be engaged in 'chunking'. And chunking is certainly a secondary operation, performed for a secondary reason, with secondary concerns. But an asset doesn't seem to be the output of anything, so it should be kept out of this confusion. So the missing context is process-orientation. If it is produced by bundling, its a bundle. So disambiguating 'chunks' requires only the agreeable definition of what 'chunking' is. When that is available, then we will know what a 'chunk' is. Until then, let's all agree that no one knows, and everyone is imagining. |
There is no definite definitions for the concepts
bundle
andchunk
in the documentation of both V1 and V2.After a learning for several days, I found that they guys use
bundle
andchunk
in the documentation alternately. As if there isn't a clear difference betweenbundle
andchunk
.Am I right?
If not, the effort for documentation improvement is needed.
If it is, I have two suggests:
chunk
instead ofbundle
everywhere, to avoid confusingchunk
as a noun whilebundle
as a verbThe text was updated successfully, but these errors were encountered: