|
1 | 1 | import { camelize } from '@vue/shared'; |
2 | 2 | import { posix as path } from 'path-browserify'; |
| 3 | +import picomatch from 'picomatch'; |
3 | 4 | import type * as ts from 'typescript'; |
4 | 5 | import type { RawPlugin, RawVueCompilerOptions, VueCompilerOptions, VueLanguagePlugin } from './types'; |
5 | 6 | import { hyphenateTag } from './utils/shared'; |
@@ -200,6 +201,9 @@ export class CompilerOptionsResolver { |
200 | 201 | ).map(([k, v]) => [camelize(k), v]), |
201 | 202 | ), |
202 | 203 | }; |
| 204 | + // Compiling a glob costs far more than testing it, and codegen tests every prop against these |
| 205 | + resolvedOptions.isDataAttribute = picomatch(resolvedOptions.dataAttributes); |
| 206 | + resolvedOptions.isHtmlAttribute = picomatch(resolvedOptions.htmlAttributes); |
203 | 207 |
|
204 | 208 | return resolvedOptions; |
205 | 209 | } |
@@ -257,6 +261,9 @@ export function getDefaultCompilerOptions( |
257 | 261 | ? path.join(__dirname.replace(/\\/g, '/'), '..', 'types') |
258 | 262 | : '@vue/language-core/types', |
259 | 263 | ): VueCompilerOptions { |
| 264 | + const dataAttributes: string[] = []; |
| 265 | + const htmlAttributes = ['aria-*']; |
| 266 | + |
260 | 267 | return { |
261 | 268 | target, |
262 | 269 | lib, |
@@ -289,8 +296,10 @@ export function getDefaultCompilerOptions( |
289 | 296 | 'Teleport', |
290 | 297 | 'Suspense', |
291 | 298 | ], |
292 | | - dataAttributes: [], |
293 | | - htmlAttributes: ['aria-*'], |
| 299 | + dataAttributes, |
| 300 | + htmlAttributes, |
| 301 | + isDataAttribute: picomatch(dataAttributes), |
| 302 | + isHtmlAttribute: picomatch(htmlAttributes), |
294 | 303 | optionsWrapper: [`(await import('${lib}')).defineComponent(`, `)`], |
295 | 304 | macros: { |
296 | 305 | defineProps: ['defineProps'], |
|
0 commit comments