mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
fix(nuxt3): warn if builder can't be loaded (#3766)
This commit is contained in:
parent
2ad93eb34d
commit
6de6e42bb8
@ -1,6 +1,6 @@
|
||||
import chokidar from 'chokidar'
|
||||
import type { Nuxt } from '@nuxt/schema'
|
||||
import { isIgnored, tryImportModule } from '@nuxt/kit'
|
||||
import { importModule, isIgnored } from '@nuxt/kit'
|
||||
import { debounce } from 'perfect-debounce'
|
||||
import { createApp, generateApp as _generateApp } from './app'
|
||||
|
||||
@ -55,13 +55,21 @@ function watch (nuxt: Nuxt) {
|
||||
}
|
||||
|
||||
async function bundle (nuxt: Nuxt) {
|
||||
const { bundle } = typeof nuxt.options.builder === 'string'
|
||||
? await tryImportModule(nuxt.options.builder, { paths: nuxt.options.rootDir })
|
||||
: nuxt.options.builder
|
||||
try {
|
||||
const { bundle } = typeof nuxt.options.builder === 'string'
|
||||
? await importModule(nuxt.options.builder, { paths: nuxt.options.rootDir })
|
||||
: nuxt.options.builder
|
||||
|
||||
return bundle(nuxt)
|
||||
} catch (error) {
|
||||
await nuxt.callHook('build:error', error)
|
||||
|
||||
if (error.toString().includes('Cannot find module \'@nuxt/webpack-builder\'')) {
|
||||
throw new Error([
|
||||
'Could not load `@nuxt/webpack-builder`. You may need to add it to your project dependencies, following the steps in `https://github.com/nuxt/framework/pull/2812`.'
|
||||
].join('\n'))
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user