minipack icon indicating copy to clipboard operation
minipack copied to clipboard

Question on code comment: 'This loop will terminate when the queue is empty.'

Open conradlo opened this issue 7 years ago • 1 comments

Thanks so much for this simple example! It really revealed the 'magic' behind javascript bundler for me.

There is a point I'm not quite understand though.

Regarding the for .. of loop in the createGraph function https://github.com/ronami/minipack/blob/ce3b1b58427f89db1b7cecaa7c030fc7d4eb2e55/src/minipack.js#L115-L117

To my understanding, the loop will terminate when

  1. there are no more child asset being pushed to the end of query
  2. the code reached the end of query

which also means the the dependency graph was completed. Hence the query will never be empty (there is at least one asset: the entry/main asset) Or did I misunderstand something here?

conradlo avatar Jul 30 '18 15:07 conradlo

Yes, you are totally right. The loop will only stop when it reachs the leaf of the tree, in a better scenario, it has only main.js. In the worst scenario it has to go through all the tree

matheus1lva avatar Aug 18 '18 18:08 matheus1lva