fix(nitro): dot-prop esm compatibility (#829)

This commit is contained in:
Anthony Fu 2021-10-13 02:51:24 +08:00 committed by GitHub
parent 4608c92c2b
commit 10170daa84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ import defu from 'defu'
import { mergeHooks } from 'hookable' import { mergeHooks } from 'hookable'
import consola from 'consola' import consola from 'consola'
import chalk from 'chalk' import chalk from 'chalk'
import { get } from 'dot-prop' import dotProp from 'dot-prop'
import type { NitroPreset, NitroInput } from '../context' import type { NitroPreset, NitroInput } from '../context'
export function hl (str: string) { export function hl (str: string) {
@ -20,7 +20,7 @@ export function prettyPath (p: string, highlight = true) {
export function compileTemplate (contents: string) { export function compileTemplate (contents: string) {
return (params: Record<string, any>) => contents.replace(/{{ ?([\w.]+) ?}}/g, (_, match) => { return (params: Record<string, any>) => contents.replace(/{{ ?([\w.]+) ?}}/g, (_, match) => {
const val = get(params, match) const val = dotProp.get(params, match)
if (!val) { if (!val) {
consola.warn(`cannot resolve template param '${match}' in ${contents.substr(0, 20)}`) consola.warn(`cannot resolve template param '${match}' in ${contents.substr(0, 20)}`)
} }