Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

深入浅出webpack编译体系 #19

Open
slashhuang opened this issue Oct 8, 2017 · 0 comments
Open

深入浅出webpack编译体系 #19

slashhuang opened this issue Oct 8, 2017 · 0 comments

Comments

@slashhuang
Copy link
Owner

slashhuang commented Oct 8, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant