parent
a0f06b0171
commit
dc1fea1bbb
|
@ -10,6 +10,7 @@ import { createHash } from 'crypto'
|
|||
import Es from 'esbuild'
|
||||
import { join } from 'path'
|
||||
import { compile } from '@vue/compiler-dom'
|
||||
import { red, cyan, blue } from 'kolorist'
|
||||
|
||||
import {
|
||||
JS_EXP,
|
||||
|
@ -103,7 +104,8 @@ export function parseJs(
|
|||
code = '',
|
||||
imports,
|
||||
{ IS_MPA, currentPage, IS_ENTRY, DEPLOY_PATH } = {},
|
||||
isBuild
|
||||
isBuild,
|
||||
filename
|
||||
) {
|
||||
let fixedStyle = '\n\n'
|
||||
let ASSETS_DIR = '/@/'
|
||||
|
@ -111,7 +113,23 @@ export function parseJs(
|
|||
if (isBuild) {
|
||||
ASSETS_DIR = '/assets/' // + (IS_MPA ? 'pages/' : '')
|
||||
}
|
||||
try {
|
||||
code = Es.transformSync(code).code || ''
|
||||
} catch (e) {
|
||||
let err = e.errors.pop()
|
||||
console.log('%s: %s', red('Uncaught SyntaxError'), err.text)
|
||||
console.log(
|
||||
' @ line %d: %s',
|
||||
err.location.line,
|
||||
cyan(err.location.lineText)
|
||||
)
|
||||
console.log(
|
||||
' @ %s:%d:%d',
|
||||
blue(filename),
|
||||
err.location.line,
|
||||
err.location.column
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
code
|
||||
|
@ -275,7 +293,7 @@ export function compileVue(file, imports, options = {}, isBuild) {
|
|||
CACHE[file] = { changed: false, js, html }
|
||||
}
|
||||
|
||||
output += parseJs(js, imports, options, isBuild).replace(
|
||||
output += parseJs(js, imports, options, isBuild, file).replace(
|
||||
'export default {',
|
||||
'const __sfc__ = {\n render,\n'
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "fite",
|
||||
"type": "module",
|
||||
"version": "0.7.1",
|
||||
"version": "0.7.2",
|
||||
"bin": {
|
||||
"fite": "index.js"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue