@@ -4,7 +4,7 @@ import './devCheck'
|
||||
import { compile, CompilerOptions, CompilerError } from '@vue/compiler-dom'
|
||||
import { registerRuntimeCompiler, RenderFunction, warn } from '@vue/runtime-dom'
|
||||
import * as runtimeDom from '@vue/runtime-dom'
|
||||
import { isString, NOOP, generateCodeFrame } from '@vue/shared'
|
||||
import { isString, NOOP, generateCodeFrame, extend } from '@vue/shared'
|
||||
|
||||
const compileCache: Record<string, RenderFunction> = Object.create(null)
|
||||
|
||||
@@ -39,25 +39,30 @@ function compileToFunction(
|
||||
template = el ? el.innerHTML : ``
|
||||
}
|
||||
|
||||
const { code } = compile(template, {
|
||||
hoistStatic: true,
|
||||
onError(err: CompilerError) {
|
||||
if (__DEV__) {
|
||||
const message = `Template compilation error: ${err.message}`
|
||||
const codeFrame =
|
||||
err.loc &&
|
||||
generateCodeFrame(
|
||||
template as string,
|
||||
err.loc.start.offset,
|
||||
err.loc.end.offset
|
||||
)
|
||||
warn(codeFrame ? `${message}\n${codeFrame}` : message)
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
},
|
||||
...options
|
||||
})
|
||||
const { code } = compile(
|
||||
template,
|
||||
extend(
|
||||
{
|
||||
hoistStatic: true,
|
||||
onError(err: CompilerError) {
|
||||
if (__DEV__) {
|
||||
const message = `Template compilation error: ${err.message}`
|
||||
const codeFrame =
|
||||
err.loc &&
|
||||
generateCodeFrame(
|
||||
template as string,
|
||||
err.loc.start.offset,
|
||||
err.loc.end.offset
|
||||
)
|
||||
warn(codeFrame ? `${message}\n${codeFrame}` : message)
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
},
|
||||
options
|
||||
)
|
||||
)
|
||||
|
||||
// The wildcard import results in a huge object with every export
|
||||
// with keys that cannot be mangled, and can be quite heavy size-wise.
|
||||
|
||||
Reference in New Issue
Block a user