Skip to content

Commit 95e9ca2

Browse files
authored
feat(resolvers): add bootstrap-vue-next resolver (#587)
1 parent 5df0c0e commit 95e9ca2

File tree

3 files changed

+58
-40
lines changed

3 files changed

+58
-40
lines changed

src/core/resolvers/bootstrap-vue-3.ts

-38
This file was deleted.

src/core/resolvers/bootstrap-vue.ts

+58-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const COMPONENT_ALIASES: Record<string, string> = {
5454
*
5555
* @link https://github.com/bootstrap-vue/bootstrap-vue
5656
*/
57-
export function BootstrapVueResolver(_options: BootstrapVueResolverOptions = {}): ComponentResolver[] {
57+
export const BootstrapVueResolver = (_options: BootstrapVueResolverOptions = {}): ComponentResolver[] => {
5858
const options = { directives: true, ..._options }
5959
const resolvers: ComponentResolver[] = [{
6060
type: 'component',
@@ -84,3 +84,60 @@ export function BootstrapVueResolver(_options: BootstrapVueResolverOptions = {})
8484

8585
return resolvers
8686
}
87+
88+
/**
89+
* Resolver for BootstrapVueNext
90+
*
91+
* @link https://github.com/bootstrap-vue/bootstrap-vue-next
92+
*/
93+
export const BootstrapVueNextResolver = (_options: BootstrapVueResolverOptions = {}): Array<ComponentResolver> => {
94+
const options = { directives: true, ..._options }
95+
const resolvers: Array<ComponentResolver> = [{
96+
type: 'component',
97+
resolve: (name) => {
98+
if (name.match(/^B[A-Z]/))
99+
return { name, from: 'bootstrap-vue-next' }
100+
},
101+
}]
102+
103+
if (options.directives) {
104+
resolvers.push({
105+
type: 'directive',
106+
resolve: (name) => {
107+
if (name.match(/^B[A-Z]/))
108+
return { name: `v${name}`, from: 'bootstrap-vue-next' }
109+
},
110+
})
111+
}
112+
113+
return resolvers
114+
}
115+
116+
/**
117+
* Resolver for legacy BootstrapVue3 apps
118+
*
119+
* @deprecated use BootstrapVueNextResolver with https://github.com/bootstrap-vue/bootstrap-vue-next
120+
* @link https://www.npmjs.com/package/bootstrap-vue-3
121+
*/
122+
export const BootstrapVue3Resolver = (_options: BootstrapVueResolverOptions = {}): Array<ComponentResolver> => {
123+
const options = { directives: true, ..._options }
124+
const resolvers: Array<ComponentResolver> = [{
125+
type: 'component',
126+
resolve: (name) => {
127+
if (name.match(/^B[A-Z]/))
128+
return { name, from: 'bootstrap-vue-3' }
129+
},
130+
}]
131+
132+
if (options.directives) {
133+
resolvers.push({
134+
type: 'directive',
135+
resolve: (name) => {
136+
if (name.match(/^B[A-Z]/))
137+
return { name: `V${name}`, from: 'bootstrap-vue-3' }
138+
},
139+
})
140+
}
141+
142+
return resolvers
143+
}

src/core/resolvers/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ export * from './arco'
1919
export * from './tdesign'
2020
export * from './layui-vue'
2121
export * from './bootstrap-vue'
22-
export * from './bootstrap-vue-3'
2322
export * from './ionic'

0 commit comments

Comments
 (0)