From 759b07d20667a24876d8c1c5b19f621071f4d2cf Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 12 Dec 2019 11:12:05 -0500 Subject: [PATCH] chore: add How It Workds to README [ci skip] --- README.md | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/README.md b/README.md index 5828ac012..35291c56a 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,79 @@ There are many cool features provided by `vue-loader`: - State-preserving hot-reloading during development. In a nutshell, the combination of webpack and `vue-loader` gives you a modern, flexible and extremely powerful front-end workflow for authoring Vue.js applications. + +## How It Works + +> The following section is for maintainers and contributors who are interested in the internal implementation details of `vue-loader`, and is **not** required knowledge for end users. + +`vue-loader` is not a simple source transform loader. It handles each language blocks inside an SFC with its own dedicated loader chain (you can think of each block as a "virtual module"), and finally assembles the blocks together into the final module. Here's a brief overview of how the whole thing works: + +1. `vue-loader` parses the SFC source code into an *SFC Descriptor* using `@vue/compiler-sfc`. It then generates an import for each language block so the actual returned module code looks like this: + + ``` js + // code returned from the main loader for 'source.vue' + + // import the