From 58227e88e949ef9ee13d9e3ea5bc9635af9f69c0 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 20 Nov 2020 11:02:10 -0500 Subject: [PATCH] chore: more readme info for compiler-sfc --- packages/compiler-sfc/README.md | 80 +++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 8 deletions(-) diff --git a/packages/compiler-sfc/README.md b/packages/compiler-sfc/README.md index cc7b6cc05..2a855122c 100644 --- a/packages/compiler-sfc/README.md +++ b/packages/compiler-sfc/README.md @@ -1,19 +1,83 @@ # @vue/compiler-sfc -> Lower level utilities for compiling Vue single file components +> Lower level utilities for compiling Vue Single File Components -This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue single file components into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader), [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue) and [vite](https://github.com/vitejs/vite). - -The API is intentionally low-level, because different toolings have different constraints on how much context is shared between the transformation of each block in an SFC. For example, the template sub-loader in `vue-loader` may not have access to the full SFC and its descriptor. +This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader), [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue) and [vite](https://github.com/vitejs/vite). ## Browser Build Notes The browser build relies on a browser-bundled build of `postcss` to be available under the global `postcss` (since it can't be properly bundled by Rollup). -## Usage Example +## API -```js -// TODO +The API is intentionally low-level due to the various considerations when integrating Vue SFCs in a build system: + +- Separate hot-module replacement (HMR) for script, template and styles + - template updates should not reset component state + - style updates should be performed without component re-render + +- Leveraging the tool's plugin system for pre-processor handling. e.g. `