Skip to content

Commit

Permalink
fix: typings for kirbyup.import
Browse files Browse the repository at this point in the history
Fixes #32
  • Loading branch information
johannschopplich committed Nov 30, 2022
1 parent ed38a2e commit 95d99b1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/client/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export const kirbyup = Object.freeze({
* @example
* kirbyup.import('./components/blocks/*.vue')
*/
import(modules: Record<string, Module>) {
import(glob: string) {
// `kirbyup.import(<path>)` will be transformed by the auto import plugin,
// which will change the signature at build-time to:
// `kirbyup.import(import.meta.glob(<path>, { eager: true }))`
// Thus, we have to force a type cast here
const modules = glob as unknown as Record<string, Module>
return Object.entries(modules).reduce<Record<string, any>>(
(accumulator, [path, component]) => {
accumulator[getComponentName(path)] = component.default
Expand Down

0 comments on commit 95d99b1

Please sign in to comment.