Skip to content

Commit 38716c8

Browse files
committed
fix: #7
1 parent 3590955 commit 38716c8

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
],
1919
"scripts": {
2020
"dev": "npm run build -- --watch",
21+
"fixture:dev": "npm -C test/fixture run dev",
22+
"fixture:build": "npm -C test/fixture run build",
2123
"build": "tsup src/index.ts --dts --format cjs,esm",
2224
"prepublish": "npm run build",
2325
"release": "standard-version && npm publish && git push"

src/context.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class Context {
3838

3939
addComponents(paths: string | string[]) {
4040
const size = this._componentPaths.size
41-
toArray(paths).forEach(p => this._componentPaths.add(`/${p}`))
41+
toArray(paths).forEach(p => this._componentPaths.add(p))
4242
if (this._componentPaths.size !== size) {
4343
this.updateComponentNameMap()
4444
return true
@@ -48,7 +48,7 @@ export class Context {
4848

4949
removeComponents(paths: string | string[]) {
5050
const size = this._componentPaths.size
51-
toArray(paths).forEach(p => this._componentPaths.delete(`/${p}`))
51+
toArray(paths).forEach(p => this._componentPaths.delete(p))
5252
if (this._componentPaths.size !== size) {
5353
this.updateComponentNameMap()
5454
return true
@@ -83,6 +83,7 @@ export class Context {
8383
return names
8484
.map((name) => {
8585
const info = this._componentNameMap[name]
86+
console.log('info', info, excludePaths)
8687
if (info && !excludePaths.includes(info.path))
8788
return info
8889
return undefined

src/generator/resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function generateResolver(ctx: Context, reqPath: string) {
1818
debug('using', names, 'imported', components.map(i => i.name))
1919

2020
return `
21-
${components.map(({ name, path }) => `import ${name} from "${path}"`).join('\n')}
21+
${components.map(({ name, path }) => `import ${name} from "/${path}"`).join('\n')}
2222
2323
export default (components) => {
2424
return Object.assign({}, { ${components.map(i => i.name).join(', ')} }, components)

test/fixture/src/App.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,17 @@
22
<ComponentA msg="a" />
33
<component-b msg="b" />
44
<ComponentC msg="c" />
5+
<recursive :data="tree" />
56
</template>
7+
8+
<script setup lang='ts'>
9+
import { ref } from 'vue'
10+
11+
export const tree = ref({
12+
label: 'Top Level',
13+
children: [
14+
{ label: 'First Level' },
15+
{ label: 'First Level', children: [{ label: 'Second Level' }] },
16+
],
17+
})
18+
</script>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template>
2+
<div>
3+
<div>{{ data.label }}</div>
4+
<div class="child">
5+
<recursive v-for="item in data.children" :data="item" />
6+
</div>
7+
</div>
8+
</template>
9+
10+
<script lang="ts">
11+
export default {
12+
name: 'Recursive',
13+
props: {
14+
data: Object,
15+
},
16+
}
17+
</script>
18+
19+
<style>
20+
.child {
21+
margin-left: 2rem;
22+
}
23+
</style>

0 commit comments

Comments
 (0)