ES6 Modules:
My understanding of ES6 modules is that it loads the 'leaf dependencies' (modules that don't import) first in order of their appearance in .html
. Then, it loads the rest of the files in such a way that a file is only loaded once the file it imports from is loaded. (I understand the rules that determine exactly how these files are loaded is too complicated to bother learning).
Webpack:
So far, I've understood that Webpack creates 1 'super' file from 1 js
script (let's call this script 'jsA') and all the other js
scripts jsA imports (via CommonJS).
Question:
Webpack relies on the idea that every js
file can be traced back to being imported by jsA
. What if we're in a situation like I described with ES6 modules where you have a file you want to run but it has nothing to do with jsA
- it cannot be traced back to being imported by jsA
. You simply want to execute it before or after jsA
. Does webpack have the ability to create multiple 'super' files? What's the done thing here?