修复一处笔误; 修正js解析行号;修复js解析时文件名未传的bug

pull/6/head
yutent 2023-06-25 11:59:20 +08:00
parent 3404c87a71
commit 0225e1e499
2 changed files with 26 additions and 16 deletions

View File

@ -112,7 +112,7 @@ export function parseJs(
imports,
{ IS_MPA, currentPage, IS_ENTRY, DEPLOY_PATH, LEGACY_MODE } = {},
filename,
linePatch = 0
linePatch = 1
) {
let fixedStyle = ''
let ASSETS_DIR = '/@/'

View File

@ -166,13 +166,18 @@ export default async function createServer(root = '', conf = {}) {
let entry = fs.cat(page.entry)?.toString()
let html = fs.cat(join(process.cwd(), 'index.html')).toString()
entry = parseJs(entry, conf.imports, {
entry = parseJs(
entry,
conf.imports,
{
IS_MPA,
currentPage,
IS_ENTRY: true,
DEPLOY_PATH,
LEGACY_MODE
})
},
page.entry
)
code = parseHtml(html, {
page,
@ -198,7 +203,6 @@ export default async function createServer(root = '', conf = {}) {
file = join(SOURCE_DIR, rpath)
}
} else {
ndex.html
file = join(SOURCE_DIR, rpath)
}
if (!fs.isfile(file)) {
@ -267,19 +271,25 @@ export default async function createServer(root = '', conf = {}) {
if (fs.isfile(file)) {
code = fs.cat(file)
} else if (fs.isfile(join(PUBLIC_DIR, rpath))) {
code = fs.cat(join(PUBLIC_DIR, rpath))
file = join(PUBLIC_DIR, rpath)
code = fs.cat(file)
} else {
friendlyErrors(rpath, ext)
res.writeHead(404, USE_HTTPS ? void 0 : 'Not Found')
res.end('')
return
}
code = parseJs(code + '', conf.imports, {
code = parseJs(
code + '',
conf.imports,
{
IS_MPA,
currentPage,
DEPLOY_PATH,
LEGACY_MODE
})
},
file
)
res.setHeader('content-type', MIME_TYPES.js)
}