Skip to content

Commit dd36477

Browse files
committed
fix: Resolving directives, code transformation for directives
1 parent fdf3ffd commit dd36477

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/transform/directives.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import MagicString from 'magic-string'
2-
import { capitalize } from '../utils'
32
import { ModuleContext } from '../types'
43
import { useNuxt } from '@nuxt/kit'
54
import { 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

0 commit comments

Comments
 (0)