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