提交 b4262a9a 编写于 作者: fxy060608's avatar fxy060608

wip(uts): compiler

上级 a3744a70
export const PUBLIC_DIR = 'static'
export const EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx']
export const EXTNAME_TS = ['.ts', '.tsx']
export const EXTNAME_VUE = ['.vue', '.nvue']
export const EXTNAME_VUE_TEMPLATE = ['.vue', '.nvue', '.jsx', '.tsx']
export const EXTNAME_VUE = ['.vue', '.nvue', '.uvue']
export const X_EXTNAME_VUE = ['.uvue', '.vue']
export const EXTNAME_VUE_TEMPLATE = ['.vue', '.nvue', '.uvue', '.jsx', '.tsx']
export const EXTNAME_VUE_RE = /\.(vue|nvue|uvue)$/
export const EXTNAME_JS_RE = /\.(js|jsx|ts|tsx|mjs)$/
export const EXTNAME_TS_RE = /\.tsx?$/
......@@ -41,6 +42,9 @@ export const PAGE_EXTNAME_APP = ['.nvue', '.vue', '.tsx', '.jsx', '.js']
// 其他平台解析页面后缀的优先级
export const PAGE_EXTNAME = ['.vue', '.nvue', '.tsx', '.jsx', '.js']
export const X_PAGE_EXTNAME = ['.vue', '.uvue', '.tsx', '.jsx', '.js']
export const X_PAGE_EXTNAME_APP = ['.uvue', '.tsx', '.jsx', '.js']
export const H5_API_STYLE_PATH = '@dcloudio/uni-h5/style/api/'
export const H5_FRAMEWORK_STYLE_PATH = '@dcloudio/uni-h5/style/framework/'
export const H5_COMPONENTS_STYLE_PATH = '@dcloudio/uni-h5/style/'
......
......@@ -4,7 +4,13 @@ import path from 'path'
import colors from 'picocolors'
import { camelize, capitalize } from '@vue/shared'
export { default as hash } from 'hash-sum'
import { EXTNAME_TS_RE, PAGE_EXTNAME, PAGE_EXTNAME_APP } from './constants'
import {
EXTNAME_TS_RE,
PAGE_EXTNAME,
PAGE_EXTNAME_APP,
X_PAGE_EXTNAME,
X_PAGE_EXTNAME_APP,
} from './constants'
import {
NodeTypes,
......@@ -40,9 +46,10 @@ export function normalizeIdentifier(str: string) {
export function normalizePagePath(pagePath: string, platform: UniApp.PLATFORM) {
const absolutePagePath = path.resolve(process.env.UNI_INPUT_DIR, pagePath)
let extensions = PAGE_EXTNAME
const isX = process.env.UNI_APP_X === 'true'
let extensions = isX ? X_PAGE_EXTNAME : PAGE_EXTNAME
if (platform === 'app') {
extensions = PAGE_EXTNAME_APP
extensions = isX ? X_PAGE_EXTNAME_APP : PAGE_EXTNAME_APP
}
for (let i = 0; i < extensions.length; i++) {
const extname = extensions[i]
......
......@@ -631,7 +631,20 @@ export function createStderrListener(
let message = data.toString().trim()
if (message) {
try {
const messages = JSON.parse(message) as MessageSourceLocation[]
const messages = (
JSON.parse(message) as MessageSourceLocation[]
).filter((msg) => {
if (
// 暂时屏蔽 Unchecked cast: Any? to UTSArray<String>​
// Unchecked cast: Any to UTSArray<String>
msg.type === 'warning' &&
msg.message.includes('Unchecked cast: Any') &&
msg.message.includes('to UTSArray<')
) {
return false
}
return true
})
if (messages.length) {
const msg = await parseUTSKotlinStacktrace(messages, {
inputDir,
......
......@@ -84,7 +84,10 @@ function buildManifestJson() {
const outputDir = process.env.UNI_OUTPUT_DIR
const pkg = require(path.resolve(__dirname, '../../package.json'))
process.env.UNI_COMPILER_VERSION = pkg['uni-app']?.['compilerVersion'] || ''
process.env.UNI_COMPILER_VERSION =
process.env.UNI_COMPILER_VERSION ||
pkg['uni-app']?.['compilerVersion'] ||
''
initPreContext(
platform,
process.env.UNI_CUSTOM_CONTEXT,
......
......@@ -46,7 +46,8 @@ const pkg = require(path.resolve(__dirname, '../package.json'))
initModuleAlias()
process.env.UNI_COMPILER_VERSION = pkg['uni-app']?.['compilerVersion'] || ''
process.env.UNI_COMPILER_VERSION =
process.env.UNI_COMPILER_VERSION || pkg['uni-app']?.['compilerVersion'] || ''
process.env.UNI_COMPILER_VERSION_TYPE = pkg.version.includes('alpha')
? 'a'
: 'r'
......
......@@ -2,6 +2,7 @@ import fs, { PathLike } from 'fs'
import path from 'path'
import {
EXTNAME_VUE,
X_EXTNAME_VUE,
isInHBuilderX,
normalizePath,
resolveBuiltIn,
......@@ -16,11 +17,13 @@ export function rewriteCompilerSfcParse() {
// @ts-ignore
const compilerSfc = require(resolveBuiltIn('@vue/compiler-sfc'))
const { parse } = compilerSfc
let extname_vue =
process.env.UNI_APP_X === 'true' ? X_EXTNAME_VUE : EXTNAME_VUE
compilerSfc.parse = (source: string, options: SFCParseOptions) => {
if (options?.filename) {
const extname = path.extname(options.filename)
// wxs、filter、renderjs
if (extname && !EXTNAME_VUE.includes(extname)) {
if (extname && !extname_vue.includes(extname)) {
const tag = extname.slice(1)
source = `<${tag}>` + source + `</${tag}>`
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册