You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vueDirectives: directive imports are skipped after an earlier transform leaves a directive unresolved #578
Expected: both calls return the same code, with import _directive_awesome_directive from './directives/awesome-directive.ts' and no _resolveDirective("awesome-directive") line.
Actual: the second call returns the input unchanged, so const _directive_awesome_directive = _resolveDirective("awesome-directive") stays and Vue cannot resolve the directive.
A different file transformed afterwards can end up worse. With a second preset { from: './directives/focus.ts', imports: [{ name: 'vFocus', meta: { vueDirective: true } }] }, transforming <div v-awesome-directive v-focus></div> after the file above gives:
resolveDirective is no longer imported but is still called, so rendering throws _resolveDirective is not defined.
RE_DIRECTIVE in src/addons/vue-directives.ts has the g flag, and the "any directive left?" check uses RE_DIRECTIVE.test(s.toString()) (it was .match() before 62a9ede). test() leaves lastIndex set, and the next s.original.matchAll(RE_DIRECTIVE) starts from that offset.
Additional context
The current inline snapshots for "single named directive" and "single mixed directives" in test/vue-directives.test.ts record this output (they changed in 429d84a). Running vitest run test/vue-directives.test.ts -t "single named directive" on its own fails its snapshot because the import is then injected correctly.
Activity