提交 5b7b2b44 编写于 作者: D DCloud_LXH

fix(nvue): the scroll-view node is missing after compilation

上级 c36e0bb1
......@@ -2,12 +2,7 @@ import type { Plugin } from 'vite'
import type { PluginContext, RollupError } from 'rollup'
import path from 'path'
import fs from 'fs-extra'
import {
CompilerError,
parse,
SFCBlock,
SFCDescriptor,
} from '@vue/compiler-sfc'
import { CompilerError, SFCBlock, SFCDescriptor } from '@vue/compiler-sfc'
import {
hash,
normalizePath,
......@@ -104,12 +99,12 @@ function createAppDescriptor(
const source = readAppCode(filename)
const id = hash(source)
if (!appDescriptor || appDescriptor.id !== id) {
const { descriptor, errors } = parse(source, {
const { descriptor, errors } = require('@vue/compiler-sfc').parse(source, {
filename,
})
descriptor.id = id
if (errors.length) {
errors.forEach((error) =>
errors.forEach((error: any) =>
pluginContext.error(createRollupError(filename, error))
)
}
......
......@@ -21,6 +21,9 @@ interface NVuePages {
}
export const nvuePagesCache = new Map<ResolvedConfig, NVuePages>()
// 在 @vue/compiler-sfc@3.2.47 执行前重写 @vue/compiler-dom compile 方法
const nvuePages: NVuePages = {}
rewriteBindingMetadata(nvuePages)
export function uniPagesJsonPlugin({
renderer,
......@@ -29,11 +32,6 @@ export function uniPagesJsonPlugin({
renderer?: 'native'
appService: boolean
}): Plugin {
const nvuePages: NVuePages = {}
// 仅编译nvue页面时重写
if (!appService) {
rewriteBindingMetadata(nvuePages)
}
return defineUniPagesJsonPlugin((opts) => {
return {
name: 'uni:app-nvue-pages-json',
......
......@@ -46,8 +46,9 @@
"fs-extra": "^10.0.0",
"hash-sum": "^2.0.0",
"jsonc-parser": "^3.0.0",
"terser": "^5.4.0",
"picocolors": "^1.0.0"
"magic-string": "^0.27.0",
"picocolors": "^1.0.0",
"terser": "^5.4.0"
},
"devDependencies": {
"@types/debug": "^4.1.7",
......
......@@ -6,7 +6,7 @@ import { walk } from 'estree-walker'
import { CallExpression } from 'estree'
import { createFilter } from '@rollup/pluginutils'
import { MagicString } from '@vue/compiler-sfc'
import MagicString from 'magic-string'
import {
isIdentifier,
isCallExpression,
......
......@@ -44,8 +44,6 @@ 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'
......@@ -202,5 +200,7 @@ export default function uniPlugin(
)
}
rewriteCompilerSfcParse()
return plugins
}
......@@ -111,6 +111,27 @@ importers:
vue-router: 4.1.6_vue@3.2.47
yorkie: 2.0.0
packages/playground/nvue:
specifiers:
'@dcloudio/uni-app': ../../uni-app
'@dcloudio/uni-app-plus': ../../uni-app-plus
'@dcloudio/uni-components': ../../uni-components
'@dcloudio/vite-plugin-uni': ../../vite-plugin-uni
vite: ^4.1.0
vue: 3.2.47
vue-router: ^4.1.6
vuex: ^4.1.0
dependencies:
'@dcloudio/uni-app': link:../../uni-app
'@dcloudio/uni-app-plus': link:../../uni-app-plus
'@dcloudio/uni-components': link:../../uni-components
vue: 3.2.47
vue-router: 4.1.6_vue@3.2.47
vuex: 4.1.0_vue@3.2.47
devDependencies:
'@dcloudio/vite-plugin-uni': link:../../vite-plugin-uni
vite: 4.1.1
packages/playground/ssr:
specifiers:
'@dcloudio/uni-app': ../../uni-app
......@@ -943,6 +964,7 @@ importers:
fs-extra: ^10.0.0
hash-sum: ^2.0.0
jsonc-parser: ^3.0.0
magic-string: ^0.27.0
picocolors: ^1.0.0
terser: ^5.4.0
vite: ^4.0.0
......@@ -969,6 +991,7 @@ importers:
fs-extra: 10.1.0
hash-sum: 2.0.0
jsonc-parser: 3.2.0
magic-string: 0.27.0
picocolors: 1.0.0
terser: 5.16.1
devDependencies:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册