blog icon indicating copy to clipboard operation
blog copied to clipboard

深入浅出webpack编译体系

Open slashhuang opened this issue 6 years ago • 0 comments

7 important tapable instances

  1. compiler: exosed via node api + central dispatch start/stop
  const webpack = require('webpack');
  const compiler = webpack(options);
  1. compilation: created by the compiler, contain dependency graph algorithm.

  2. resolver make sure file/folder/path exist

  3. module factory takes successfully resolved requests collects source for that file, creates a module object

  4. parser takes a module object, turns into AST and parse. find all dependency statements(require/import etc).

  5. template dataBinding for your modules, creates the code in your bundles.

   1. main template
   2. module template
   3. dependency template

核心思想:

  1. every instance can be plugged into.

compiler ==options==> compilation -->

--> resolver(make sure entry point exist) == moduleFactory --> modules -->

== Loaders or Rules --> parser |--------------------->|

==> AST statements(requie/import etc)

==> attach to Modules(dependency graph)

==> recursively flow for dependency

inspired by https://www.youtube.com/watch?v=NHI_PhoykVU @reactRally

slashhuang avatar Oct 08 '17 15:10 slashhuang