Skip to content

Instantly share code, notes, and snippets.

@mzgoddard
Created August 11, 2016 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzgoddard/1f85329e38c761414b52f9422bb4369f to your computer and use it in GitHub Desktop.
Save mzgoddard/1f85329e38c761414b52f9422bb4369f to your computer and use it in GitHub Desktop.
High level steps webpack takes
  • create a compiler
  • apply options / configuration
    • apply plugins listed in options
    • add all other plugins based on options / configuration
    • example plugin: commonjsplugin
      • define dependency module factories
      • define dependency templates
      • plugin parser to create commonjs dependencies
  • run the compiler
    • create module factories
    • create a Compilation
    • "make" the compilation
      • according to a plugin added when appling options add a chunk and entry module
        • build module
          • run loaders on original content
          • parse loader output
            • through commonjsplugin and other plugins, create dependencies
          • build a list of all dependencies for module
          • for each dependency
            • get a module factory for that dependency
            • create a module
              • add it to the compilation
              • build module
    • "seal" the compilation
      • assign ids to modules and chunks
      • most optimization plugins do work here
      • transform chunks into assets with the a chunk template
        • transform modules with the moduleTemplate
          • transform dependencies with their appropriate dependency template
    • emit assets to the file system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment