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

fix: wxs (question/136633)

上级 13eb8b49
......@@ -79,7 +79,7 @@ export default function vueFactory(exports) {
} = instance; // ShapeFlags.ARRAY_CHILDREN = 1<<4
if (subTree.shapeFlag & 16) {
var elemVNode = subTree.children.find(vnode => isElement(vnode.el));
var elemVNode = subTree.children.find(vnode => vnode.el && isElement(vnode.el));
if (elemVNode) {
return elemVNode.el;
......
......@@ -77,7 +77,7 @@ export default function vueFactory(exports) {
} = instance; // ShapeFlags.ARRAY_CHILDREN = 1<<4
if (subTree.shapeFlag & 16) {
var elemVNode = subTree.children.find(vnode => isElement(vnode.el));
var elemVNode = subTree.children.find(vnode => vnode.el && isElement(vnode.el));
if (elemVNode) {
return elemVNode.el;
......
......@@ -4626,11 +4626,11 @@ const ChooseLocationProtocol = {
longitude: Number
};
const API_GET_LOCATION = "getLocation";
const coordTypes = ["WGS84", "GCJ02"];
const coordTypes = ["wgs84", "gcj02"];
const GetLocationOptions = {
formatArgs: {
type(value, params) {
value = (value || "").toUpperCase();
value = (value || "").toLowerCase();
if (coordTypes.indexOf(value) === -1) {
params.type = coordTypes[0];
} else {
......
......@@ -184,7 +184,7 @@ function resolveOwnerEl(instance) {
const { subTree } = instance;
// ShapeFlags.ARRAY_CHILDREN = 1<<4
if (subTree.shapeFlag & 16) {
const elemVNode = subTree.children.find((vnode) => isElement(vnode.el));
const elemVNode = subTree.children.find((vnode) => vnode.el && isElement(vnode.el));
if (elemVNode) {
return elemVNode.el;
}
......
......@@ -180,7 +180,7 @@ function resolveOwnerEl(instance) {
const { subTree } = instance;
// ShapeFlags.ARRAY_CHILDREN = 1<<4
if (subTree.shapeFlag & 16) {
const elemVNode = subTree.children.find((vnode) => isElement(vnode.el));
const elemVNode = subTree.children.find((vnode) => vnode.el && isElement(vnode.el));
if (elemVNode) {
return elemVNode.el;
}
......
......@@ -30,8 +30,8 @@ export function resolveOwnerEl(instance: ComponentInternalInstance) {
const { subTree } = instance
// ShapeFlags.ARRAY_CHILDREN = 1<<4
if (subTree.shapeFlag & 16) {
const elemVNode = (subTree.children as VNode[]).find((vnode) =>
isElement(vnode.el as Element)
const elemVNode = (subTree.children as VNode[]).find(
(vnode) => vnode.el && isElement(vnode.el as Element)
)
if (elemVNode) {
return elemVNode.el
......
import path from 'path'
import fs from 'fs-extra'
import { build as buildByVite, BuildOptions, InlineConfig } from 'vite'
import { extend } from '@vue/shared'
import {
initPreContext,
normalizeAppManifestJson,
......@@ -11,8 +12,20 @@ import { CliOptions } from '.'
import { addConfigFile, cleanOptions } from './utils'
export async function build(options: CliOptions) {
if (options.platform === 'app' && (options as BuildOptions).manifest) {
return buildManifestJson()
if (options.platform === 'app') {
if ((options as BuildOptions).manifest) {
return buildManifestJson()
}
if (process.env.UNI_RENDERER === 'native') {
return buildByVite(
addConfigFile(
extend(
{ nvue: true },
initBuildOptions(options, cleanOptions(options) as BuildOptions)
)
)
)
}
}
return buildByVite(
addConfigFile(
......
......@@ -10,12 +10,6 @@ export function initNVueEnv() {
const manifestJson = parseManifestJsonOnce(process.env.UNI_INPUT_DIR)
if (getAppRenderer(manifestJson) === 'native') {
process.env.UNI_RENDERER = 'native'
return (
console.error(
`当前项目启用了纯原生渲染,请在manifest.json中切换vue版本为2之后,再重新运行。`
),
process.exit(1)
)
}
const nvueCompiler = getNVueCompiler(manifestJson)
if (nvueCompiler === 'uni-app') {
......
......@@ -17,7 +17,11 @@ import {
import { createConfig } from './config'
import { createConfigResolved } from './configResolved'
import { uniCopyPlugin } from './plugins/copy'
import { initExtraPlugins, initPluginUniOptions } from './utils'
import {
initExtraPlugins,
initPluginUniOptions,
rewriteCompilerSfcParse,
} from './utils'
import {
initPluginViteLegacyOptions,
initPluginVueJsxOptions,
......@@ -31,6 +35,8 @@ const pkg = require(path.resolve(__dirname, '../package.json'))
initModuleAlias()
rewriteCompilerSfcParse()
process.env.UNI_COMPILER_VERSION = pkg['uni-app']?.['compilerVersion'] || ''
process.env.UNI_COMPILER_VERSION_TYPE = pkg.version.includes('alpha')
? 'a'
......
export * from './filter'
export * from './plugin'
export * from './polyfill'
import path from 'path'
import { EXTNAME_VUE, resolveBuiltIn } from '@dcloudio/uni-cli-shared'
import { SFCParseOptions } from '@vue/compiler-sfc'
/**
* TODO 临时重写,解决 @vitejs/plugin-vue 的 Bug
*/
export function rewriteCompilerSfcParse() {
// @ts-ignore
const compilerSfc = require(resolveBuiltIn('@vue/compiler-sfc'))
const { parse } = compilerSfc
compilerSfc.parse = (source: string, options: SFCParseOptions) => {
if (options.filename) {
const extname = path.extname(options.filename)
// wxs、filter、renderjs
if (extname && !EXTNAME_VUE.includes(extname)) {
const tag = extname.slice(1)
source = `<${tag}>` + source + `</${tag}>`
}
}
return parse(source, options)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册