if((__ESM_BROWSER__||__GLOBAL__)&&preprocessLang&&!preprocessCustomRequire){thrownewError(`[@vue/compiler-sfc] Template preprocessing in the browser build must `+`provide the \`preprocessCustomRequire\` option to return the in-browser `+`version of the preprocessor in the shape of { render(): string }.`)}constpreprocessor=preprocessLang?preprocessCustomRequire?preprocessCustomRequire(preprocessLang):__ESM_BROWSER__?undefined:consolidate[preprocessLangaskeyoftypeofconsolidate]:false
// resolve parser plugins
constplugins: ParserPlugin[]=[]if(!isTS||scriptLang==='tsx'||scriptSetupLang==='tsx'){plugins.push('jsx')}else{// If don't match the case of adding jsx, should remove the jsx from the babelParserPlugins
if(options.babelParserPlugins)options.babelParserPlugins=options.babelParserPlugins.filter(n=>n!=='jsx')}if(options.babelParserPlugins)plugins.push(...options.babelParserPlugins)if(isTS){plugins.push('typescript')if(!plugins.includes('decorators')){plugins.push('decorators-legacy')}}
constplugins=(postcssPlugins||[]).slice()plugins.unshift(cssVarsPlugin({id: shortId,isProd}))if(trim){plugins.push(trimPlugin())}if(scoped){plugins.push(scopedPlugin(longId))}letcssModules: Record<string,string>|undefinedif(modules){if(__GLOBAL__||__ESM_BROWSER__){thrownewError('[@vue/compiler-sfc] `modules` option is not supported in the browser build.')}if(!options.isAsync){thrownewError('[@vue/compiler-sfc] `modules` option can only be used with compileStyleAsync().')}plugins.push(postcssModules({...modulesOptions,getJSON:(_cssFileName: string,json: Record<string,string>)=>{cssModules=json}}))}
try{result=postcss(plugins).process(source,postCSSOptions)// In async mode, return a promise.
if(options.isAsync){returnresult.then(result=>({code: result.css||'',map: result.map&&result.map.toJSON(),errors,modules:cssModules,rawResult: result,dependencies: recordPlainCssDependencies(result.messages)})).catch(error=>({code:'',map: undefined,errors:[...errors,error],rawResult: undefined,dependencies}))}recordPlainCssDependencies(result.messages)// force synchronous transform (we know we only have sync plugins)
code=result.cssoutMap=result.map}catch(e: any){errors.push(e)}