From 66a1d70a27cc2f0f80a9483595f705f2e4415894 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Wed, 1 Sep 2021 18:11:34 +0900 Subject: [PATCH 1/3] Change to determine parser by extension when parsing non-vue files using multiple parser --- src/common/parser-options.ts | 44 +++++++++++++++++------------------- src/html/parser.ts | 16 +++++++++---- src/index.ts | 17 ++++++++++---- test/fixtures/typed.ts | 9 ++++++++ test/index.js | 21 +++++++++++++++++ 5 files changed, 76 insertions(+), 31 deletions(-) create mode 100644 test/fixtures/typed.ts diff --git a/src/common/parser-options.ts b/src/common/parser-options.ts index 48613210..fd88e645 100644 --- a/src/common/parser-options.ts +++ b/src/common/parser-options.ts @@ -47,23 +47,22 @@ export function isSFCFile(parserOptions: ParserOptions) { } /** - * Gets the script parser name from the given SFC document fragment. + * Gets the script parser name from the given parser lang. */ export function getScriptParser( parser: boolean | string | Record | undefined, - doc: VDocumentFragment | null, - block: "script" | "template", + getParserLang: () => string | null | Iterable, ): string | undefined { if (parser && typeof parser === "object") { - if (block === "template") { - const parserForTemplate = parser["