mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
fix(nuxt): resolve builder using esm syntax (#19608)
This commit is contained in:
parent
60b4c48eb4
commit
e13e227d06
@ -1,5 +1,5 @@
|
||||
import chokidar from 'chokidar'
|
||||
import { importModule, isIgnored } from '@nuxt/kit'
|
||||
import { isIgnored, tryResolveModule } from '@nuxt/kit'
|
||||
import { debounce } from 'perfect-debounce'
|
||||
import { normalize } from 'pathe'
|
||||
import type { Nuxt } from 'nuxt/schema'
|
||||
@ -62,7 +62,7 @@ function watch (nuxt: Nuxt) {
|
||||
async function bundle (nuxt: Nuxt) {
|
||||
try {
|
||||
const { bundle } = typeof nuxt.options.builder === 'string'
|
||||
? await importModule(nuxt.options.builder, { paths: [nuxt.options.rootDir, nuxt.options.workspaceDir, import.meta.url] })
|
||||
? await loadBuilder(nuxt, nuxt.options.builder)
|
||||
: nuxt.options.builder
|
||||
|
||||
return bundle(nuxt)
|
||||
@ -78,3 +78,12 @@ async function bundle (nuxt: Nuxt) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
async function loadBuilder (nuxt: Nuxt, builder: string) {
|
||||
for (const root of [nuxt.options.rootDir, import.meta.url]) {
|
||||
const builderPath = await tryResolveModule(builder, root)
|
||||
if (builderPath) {
|
||||
return import(builderPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user