mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-02 10:27:15 +00:00
dec8f99fc3
Co-authored-by: Clark Du <clark.duxin@gmail.com>
19 lines
584 B
JavaScript
19 lines
584 B
JavaScript
import { requireModule } from '@nuxt/utils'
|
|
|
|
export const importModule = (id) => {
|
|
try {
|
|
return Promise.resolve(requireModule(id))
|
|
} catch (err) {
|
|
if (err.code === 'MODULE_NOT_FOUND') {
|
|
err.message = `Cannot import module '${id}'`
|
|
}
|
|
return Promise.reject(err)
|
|
}
|
|
}
|
|
|
|
export const builder = () => importModule('@nuxt/builder')
|
|
export const webpack = () => importModule('@nuxt/webpack')
|
|
export const generator = () => importModule('@nuxt/generator')
|
|
export const core = () => importModule('@nuxt/core')
|
|
export const server = () => importModule('@nuxt/server')
|