diff --git a/src/index.js b/src/index.js index d64500e69..31f1eac17 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,7 @@ import { getSupportInfo as getSupportInfoWithoutPlugins, normalizeOptionSettings, } from "./main/support.js"; +import inferParserWithoutPlugins from "./utils/infer-parser.js"; import getFileInfoWithoutPlugins from "./common/get-file-info.js"; import { loadBuiltinPlugins, @@ -80,6 +81,10 @@ const getFileInfo = withPlugins(getFileInfoWithoutPlugins); /** @type {typeof getSupportInfoWithoutPlugins} */ const getSupportInfo = withPlugins(getSupportInfoWithoutPlugins, 0); +const inferParser = withPlugins((file, options) => + inferParserWithoutPlugins(options, { physicalFile: file }), +); + // Internal shared with cli const sharedWithCli = { errors, @@ -89,6 +94,8 @@ const sharedWithCli = { normalizeOptions, getSupportInfoWithoutPlugins, normalizeOptionSettings, + inferParser: (file, options) => + Promise.resolve(options?.parser ?? inferParser(file, options)), vnopts: { ChoiceSchema: vnopts.ChoiceSchema, apiDescriptor: vnopts.apiDescriptor,