修复一处笔误; 修正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, imports,
{ IS_MPA, currentPage, IS_ENTRY, DEPLOY_PATH, LEGACY_MODE } = {}, { IS_MPA, currentPage, IS_ENTRY, DEPLOY_PATH, LEGACY_MODE } = {},
filename, filename,
linePatch = 0 linePatch = 1
) { ) {
let fixedStyle = '' let fixedStyle = ''
let ASSETS_DIR = '/@/' let ASSETS_DIR = '/@/'

View File

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