MCPcopy
hub / github.com/vuejs/core / resolveParserPlugins

Function resolveParserPlugins

packages/compiler-sfc/src/script/context.ts:167–207  ·  view source on GitHub ↗
(
  lang: string,
  userPlugins?: ParserPlugin[],
  dts = false,
)

Source from the content-addressed store, hash-verified

165}
166
167export function resolveParserPlugins(
168 lang: string,
169 userPlugins?: ParserPlugin[],
170 dts = false,
171): ParserPlugin[] {
172 const plugins: ParserPlugin[] = []
173 if (
174 !userPlugins ||
175 !userPlugins.some(
176 p =>
177 p === 'importAssertions' ||
178 p === 'importAttributes' ||
179 (isArray(p) && p[0] === 'importAttributes'),
180 )
181 ) {
182 plugins.push('importAttributes')
183 }
184 if (lang === 'jsx' || lang === 'tsx' || lang === 'mtsx') {
185 plugins.push('jsx')
186 } else if (userPlugins) {
187 // If don't match the case of adding jsx
188 // should remove the jsx from user options
189 userPlugins = userPlugins.filter(p => p !== 'jsx')
190 }
191 if (
192 lang === 'ts' ||
193 lang === 'mts' ||
194 lang === 'tsx' ||
195 lang === 'cts' ||
196 lang === 'mtsx'
197 ) {
198 plugins.push(['typescript', { dts }], 'explicitResourceManagement')
199 if (!userPlugins || !userPlugins.includes('decorators')) {
200 plugins.push('decorators-legacy')
201 }
202 }
203 if (userPlugins) {
204 plugins.push(...userPlugins)
205 }
206 return plugins
207}

Callers 3

rewriteDefaultFunction · 0.90
parseFileFunction · 0.90
constructorMethod · 0.85

Calls 3

someMethod · 0.80
pushMethod · 0.65
filterMethod · 0.65

Tested by

no test coverage detected