UNPKG

vike

Version:

The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.

28 lines (27 loc) 867 B
export { getExportPath }; import { assert } from '../../utils/assert.js'; function getExportPath(fileExportPathToShowToUser, configName) { if (!fileExportPathToShowToUser) return null; let [exportName, ...exportObjectPath] = fileExportPathToShowToUser; if (!exportName) return null; if (exportObjectPath.length === 0 && ['*', 'default', configName].includes(exportName)) return null; assert(exportName !== '*'); let prefix = ''; let suffix = ''; if (exportName === 'default') { prefix = 'export default'; } else { prefix = 'export'; exportObjectPath = [exportName, ...exportObjectPath]; } exportObjectPath.forEach((prop) => { prefix = `${prefix} { ${prop}`; suffix = ` }${suffix}`; }); const exportPath = prefix + suffix; return exportPath; }