File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import MagicString from 'magic-string'
2- import { capitalize } from '../utils'
32import { ModuleContext } from '../types'
43import { useNuxt } from '@nuxt/kit'
54import { createUnplugin } from 'unplugin'
@@ -20,19 +19,17 @@ export const transformDirectivesPlugin = createUnplugin((context: ModuleContext)
2019
2120 const s = new MagicString ( code )
2221 const directives : {
23- name : string ,
2422 alias : string ,
2523 path : string
2624 } [ ] = [ ]
2725
2826 let counter = 0
2927
3028 s . replace ( directivesRegExp , ( full , name ) => {
31- const directive = context . imports . directives . find ( d => d . name === name )
29+ const directive = context . imports . directives . find ( d => d . kebabCase === name )
3230 if ( directive ) {
3331 const alias = `__q_directive_${ counter ++ } `
3432 directives . push ( {
35- name : capitalize ( name ) ,
3633 alias,
3734 path : directive . path
3835 } )
@@ -45,8 +42,8 @@ export const transformDirectivesPlugin = createUnplugin((context: ModuleContext)
4542 if ( directives . length ) {
4643 s . prepend (
4744 directives
48- . map ( d => `import { ${ d . name } as ${ d . alias } } from ' ${ d . path } ' ` )
49- . join ( '\n' )
45+ . map ( d => `import ${ d . alias } from " ${ d . path } " ` )
46+ . join ( '\n' ) + '\n'
5047 )
5148 }
5249
You can’t perform that action at this time.
0 commit comments