Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(component): Add support for better naming of /index.vue components #1994

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/app-backend-vue3/src/components/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { classify } from '@vue-devtools/shared-utils'
import { basename } from '../util'
import { classify, basename } from '@vue-devtools/shared-utils'
import { ComponentInstance, App } from '@vue/devtools-api'
import { BackendContext } from '@vue-devtools/app-backend-api'

Expand Down
9 changes: 0 additions & 9 deletions packages/app-backend-vue3/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ export function flatten (items) {
}, [])
}

// Use a custom basename functions instead of the shimed version
// because it doesn't work on Windows
export function basename (filename, ext) {
return path.basename(
filename.replace(/^[a-zA-Z]:/, '').replace(/\\/g, '/'),
ext,
)
}

export function returnError (cb: () => any) {
try {
return cb()
Expand Down
8 changes: 6 additions & 2 deletions packages/shared-utils/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,13 @@ export function reviveSet (val) {

// Use a custom basename functions instead of the shimed version
// because it doesn't work on Windows
function basename (filename, ext) {
export function basename (filename, ext) {
filename = filename.replace(/\\/g, '/')
if (filename.includes(`/index${ext}`)) {
filename = filename.replace(`/index${ext}`, ext)
}
return path.basename(
filename.replace(/^[a-zA-Z]:/, '').replace(/\\/g, '/'),
filename.replace(/^[a-zA-Z]:/, ''),
ext,
)
}
Expand Down
3 changes: 3 additions & 0 deletions packages/shell-dev-vue3/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import SetupScript from './SetupScript.vue'
import SetupDataLike from './SetupDataLike.vue'
import SetupTSScriptProps from './SetupTSScriptProps.vue'
import DomOrder from './DomOrder.vue'
import IndexComponent from './IndexComponent/index.vue'

import { h, createApp } from 'vue'
import SimplePlugin from './devtools-plugin/simple'
Expand Down Expand Up @@ -51,6 +52,7 @@ export default {
SetupDataLike,
SetupTSScriptProps,
DomOrder,
IndexComponent,
inline: {
render: () => h('h3', 'Inline component definition'),
},
Expand Down Expand Up @@ -114,6 +116,7 @@ export default {
</div>

<Child question="Life" />
<IndexComponent />
<NestedMore />
<NativeTypes ref="nativeTypes" />
<EventEmit />
Expand Down
3 changes: 3 additions & 0 deletions packages/shell-dev-vue3/src/IndexComponent/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<h2>Index component</h2>
</template>