0

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?

tonitone120
  • 1,920
  • 3
  • 8
  • 25
  • 1
    https://webpack.js.org/concepts/entry-points/ take a look at the entry points, that's probably what you're looking for. – Daniel B. Chapman Oct 18 '20 at 22:44
  • 1
    Entry points is definitely what OP is looking for. Here's a question/set of answers for that topic: https://stackoverflow.com/questions/31907672/how-to-set-multiple-file-entry-and-output-in-project-with-webpack – Slbox Oct 18 '20 at 22:46

0 Answers0