Skip to content

Commit

Permalink
feat(compiler): expose generateCodeFrame method
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 10, 2019
1 parent 5371617 commit a4ed58c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/vue-template-compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Note the returned function code uses `with` and thus cannot be used in strict mo

#### Options

- `outputSourceRange` *new in 2.6*
- Type: `boolean`
- Default: `false`

Set this to true will cause the `errors` returned in the compiled result become objects in the form of `{ msg, start, end }`. The `start` and `end` properties are numbers that mark the code range of the error source in the template. This can be passed on to the `compiler.generateCodeFrame` API to generate code frame for the error.

- `whitespace`
- Type: `string`
- Valid values: `'preserve' | 'condense'`
Expand Down Expand Up @@ -140,6 +146,12 @@ Same as `compiler.compileToFunction` but generates SSR-specific render function

Parse a SFC (single-file component, or `*.vue` file) into a descriptor (refer to the `SFCDescriptor` type in [flow declarations](https://github.com/vuejs/vue/blob/dev/flow/compiler.js)). This is used in SFC build tools like `vue-loader` and `vueify`.

---

### compiler.generateCodeFrame(template, start, end)

Generate a code frame that highlights the part in `template` defined by `start` and `end`. Useful for error reporting in higher-level tooling.

#### Options

#### `pad`
Expand Down
1 change: 1 addition & 0 deletions src/platforms/web/entry-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
export { parseComponent } from 'sfc/parser'
export { compile, compileToFunctions } from './compiler/index'
export { ssrCompile, ssrCompileToFunctions } from './server/compiler'
export { generateCodeFrame } from 'compiler/codeframe'
1 change: 1 addition & 0 deletions src/platforms/weex/entry-compiler.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { compile } from 'weex/compiler/index'
export { generateCodeFrame } from 'compiler/codeframe'

0 comments on commit a4ed58c

Please sign in to comment.