Skip to content

Commit

Permalink
fix(module): use resolveModule to import presets
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Dec 22, 2021
1 parent 810113c commit 2d31146
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve } from 'pathe'
import { defineNuxtModule, installModule, addComponentsDir, addTemplate, addPlugin } from '@nuxt/kit'
import { defineNuxtModule, installModule, addComponentsDir, addTemplate, addPlugin, resolveModule } from '@nuxt/kit'
import { colors } from '@unocss/preset-uno'
import defu from 'defu'
import type { UnocssNuxtOptions } from '@unocss/nuxt'
Expand Down Expand Up @@ -136,13 +136,15 @@ export default defineNuxtModule<UiOptions>({
nuxt.options.build.transpile.push(runtimeDir)
nuxt.options.build.transpile.push('@popperjs/core', '@headlessui/vue')

let ui: object = await import(resolve(__dirname, `./presets/${defaults.preset}`))
const presetsDir = resolve(__dirname, './presets')

let ui: object = await import(resolveModule(`./${defaults.preset}`, { paths: presetsDir }))
try {
if (typeof preset === 'object') {
ui = defu(preset, ui)
} else {
// @ts-ignore
ui = await import(resolve(__dirname, `./presets/${preset}`))
ui = await import(resolveModule(`./${preset}`, { paths: presetsDir }))
}
} catch (e) {
// eslint-disable-next-line no-console
Expand Down

1 comment on commit 2d31146

@vercel
Copy link

@vercel vercel bot commented on 2d31146 Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.