Browse Source

feat(compiler): expose generateCodeFrame method

dev
Evan You 6 years ago
parent
commit
a4ed58c076
  1. 12
      packages/vue-template-compiler/README.md
  2. 1
      src/platforms/web/entry-compiler.js
  3. 1
      src/platforms/weex/entry-compiler.js

12
packages/vue-template-compiler/README.md

@ -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'`
@ -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`

1
src/platforms/web/entry-compiler.js

@ -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
src/platforms/weex/entry-compiler.js

@ -1 +1,2 @@
export { compile } from 'weex/compiler/index'
export { generateCodeFrame } from 'compiler/codeframe'

Loading…
Cancel
Save