Nuxt/packages/cli/src/imports.js
pooya parsa dec8f99fc3
feat: support plug-and-play, typescript runtime and native modules (#8389)
Co-authored-by: Clark Du <clark.duxin@gmail.com>
2020-12-22 18:07:50 +01:00

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')