Subscribe on changes!

Allow `parser` function (@vue/compiler-sfc) passing parserOptions to the parser

avatar
Mar 26th 2021

What problem does this feature solve?

Currently the parse function of @vue/compiler-sfc doesn't have the ability to passing parse options to the parser.

https://github.com/vuejs/vue-next/blob/e2469fd01434a75b80e350201c60bcaad5e392ba/packages/compiler-sfc/src/parse.ts#L88

What does the proposed API look like?

function parse(
  source: string,
  {
    sourceMap = true,
    filename = 'anonymous.vue',
    sourceRoot = '',
    pad = false,
    compiler = CompilerDOM
    compilerOptions = {}
  }: SFCParseOptions = {}
): SFCParseResult
avatar
Mar 27th 2021

The SFC parser is opinionated, can you put your use case here?

avatar
Mar 29th 2021

I just want to use the isNativeTag option so I can determine which tag is a component or not.

avatar
Mar 31st 2021

The SFC parser is for SFC files, which is opinionated and does not mean letting users customize their behavior. But you can use a lower-level API to manually implement your needs