parent
99a5fac97d
commit
5d9f768f1e
|
@ -298,15 +298,41 @@ export function compileVue(file, imports, options = {}) {
|
||||||
|
|
||||||
js = js ? js[1] : ''
|
js = js ? js[1] : ''
|
||||||
|
|
||||||
html = compile(html[1], {
|
try {
|
||||||
mode: 'module',
|
html = compile(html[1], {
|
||||||
prefixIdentifiers: true,
|
mode: 'module',
|
||||||
hoistStatic: true,
|
prefixIdentifiers: true,
|
||||||
cacheHandlers: true,
|
hoistStatic: true,
|
||||||
scopeId: scoped ? scopeId : void 0,
|
cacheHandlers: true,
|
||||||
sourceMap: false,
|
scopeId: scoped ? scopeId : void 0,
|
||||||
isCustomElement: tag => tag.startsWith('wc-')
|
sourceMap: false,
|
||||||
}).code.replace('export function render', 'function render')
|
isCustomElement: tag => tag.startsWith('wc-')
|
||||||
|
}).code.replace('export function render', 'function render')
|
||||||
|
} catch (err) {
|
||||||
|
let tmp = html[1].split('\n')
|
||||||
|
let line = tmp[err.loc.start.line - 1]
|
||||||
|
|
||||||
|
console.log('%s: %s', red('SyntaxError'), red(err.message))
|
||||||
|
console.log(
|
||||||
|
' @ %s%s%s',
|
||||||
|
line.slice(0, err.loc.start.column - 1),
|
||||||
|
red(err.loc.source),
|
||||||
|
line.slice(err.loc.end.column - 1)
|
||||||
|
)
|
||||||
|
console.log(
|
||||||
|
' @ (%s:%d:%d)\n',
|
||||||
|
file,
|
||||||
|
err.loc.start.line,
|
||||||
|
err.loc.start.column
|
||||||
|
)
|
||||||
|
html = `
|
||||||
|
import { openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
|
||||||
|
|
||||||
|
function render(_ctx, _cache) {
|
||||||
|
return (_openBlock(), _createElementBlock("div", null, "SyntaxError: ${err.message}"))
|
||||||
|
}
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
html = html
|
html = html
|
||||||
.replace(/import .* from "vue"/, str => {
|
.replace(/import .* from "vue"/, str => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "fite",
|
"name": "fite",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "0.9.3",
|
"version": "0.9.4",
|
||||||
"bin": {
|
"bin": {
|
||||||
"fite": "index.js"
|
"fite": "index.js"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue