Compare commits

...

4 Commits

Author SHA1 Message Date
yutent 96b9554574 1.4.4:修复样式scoped的范围 2024-09-27 18:43:14 +08:00
yutent dd8ff91294 1.4.3: 修复LEGACY_MODE模式下的语法兼容问题 2024-09-13 18:36:44 +08:00
yutent fa84cc0c5d 修复开发模式 2024-08-01 13:55:40 +08:00
yutent 2b9599781e fixed 2024-07-31 14:15:29 +08:00
4 changed files with 26 additions and 6 deletions

View File

@ -64,7 +64,7 @@ function scopeCss(css = '', hash) {
if (last.startsWith(':')) {
output = parseVDeep(last, output, true)
} else {
output = `${last} ${output}`
output = `${last}[data-${hash}] ${output}`
}
} else {
if (last.includes(':')) {
@ -241,6 +241,8 @@ export function parseJs(
` stylesheet.textContent = ${tmp};\n` +
` document.head.appendChild(stylesheet);\n` +
`}\n`
return `let ${tmp};\n!(async function(){\n ${tmp} = await __fite_import('${name}', import.meta.url);\n})()`
} else {
// CSSStyleSheet.replaceSync 需要FF v101, Safari 16.4才支持
fixedStyle +=
@ -251,8 +253,9 @@ export function parseJs(
` __sheets__.push(stylesheet);\n` +
` document.adoptedStyleSheets = __sheets__;\n` +
`}\n`
return `const ${tmp} = await __fite_import('${name}', import.meta.url)`
}
return `const ${tmp} = await __fite_import('${name}', import.meta.url)`
} else {
if (name.startsWith('@/')) {
name = name.replace('@/', urlJoin(DEPLOY_PATH, ASSETS_DIR))

View File

@ -179,7 +179,10 @@ export default async function createServer(root = '', conf = {}) {
currentPage,
IS_ENTRY: true,
DEPLOY_PATH,
LEGACY_MODE
LEGACY_MODE,
isCustomElement,
plugin,
define
},
page.entry
)
@ -270,10 +273,12 @@ export default async function createServer(root = '', conf = {}) {
break
case 'js':
case 'wasm':
{
let rpath = pathname.replace('@/', '')
let file
let isJson = false
let isWasm = rpath.endsWith('.wasm')
if (rpath.endsWith('json.js')) {
isJson = true
@ -309,6 +314,8 @@ export default async function createServer(root = '', conf = {}) {
} catch (err) {
console.log('%s 语法错误: %s', rpath, red(err.message))
}
} else if (isWasm) {
//
} else {
code = parseJs(
code + '',
@ -317,7 +324,10 @@ export default async function createServer(root = '', conf = {}) {
IS_MPA,
currentPage,
DEPLOY_PATH,
LEGACY_MODE
LEGACY_MODE,
isCustomElement,
plugin,
define
},
file
)

View File

@ -52,7 +52,12 @@ export default function compile(root = '', dist = '', conf = {}, verbose) {
)
const INJECT_SCSS = readFile(conf.inject?.scss)
const LEGACY_MODE = !!conf.legacy
const { ABS_CONFIG_FILEPATH, compileOptions = {}, define = {} } = conf
const {
ABS_CONFIG_FILEPATH,
compileOptions = {},
define = {},
plugin = []
} = conf
const { isCustomElement = defaultCustomElement } = compileOptions
conf.inject = conf.inject || { scss: '' }
@ -203,6 +208,8 @@ export default function compile(root = '', dist = '', conf = {}, verbose) {
doJob()
}
} else {
options.plugin = plugin
options.isCustomElement = isCustomElement
compileFiles(currentPage, page, list, options, {
verbose,
dist,

View File

@ -1,7 +1,7 @@
{
"name": "fite",
"type": "module",
"version": "1.4.0",
"version": "1.4.4",
"bin": {
"fite": "index.js"
},