Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
6efd63d8
U
uni-app
项目概览
陈庄旺
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6efd63d8
编写于
10月 31, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(ssr): match-media
上级
ab4470e8
变更
35
显示空白变更内容
内联
并排
Showing
35 changed file
with
472 addition
and
236 deletion
+472
-236
packages/uni-app-vite/src/plugin/uni/index.ts
packages/uni-app-vite/src/plugin/uni/index.ts
+7
-4
packages/uni-cli-shared/src/vite/index.ts
packages/uni-cli-shared/src/vite/index.ts
+0
-1
packages/uni-cli-shared/src/vue/transforms/index.ts
packages/uni-cli-shared/src/vue/transforms/index.ts
+18
-0
packages/uni-cli-shared/src/vue/transforms/transformEvent.ts
packages/uni-cli-shared/src/vue/transforms/transformEvent.ts
+5
-4
packages/uni-cli-shared/src/vue/transforms/transformTag.ts
packages/uni-cli-shared/src/vue/transforms/transformTag.ts
+48
-0
packages/uni-cli-shared/src/vue/utils.ts
packages/uni-cli-shared/src/vue/utils.ts
+1
-1
packages/uni-h5-vite/src/plugin/index.ts
packages/uni-h5-vite/src/plugin/index.ts
+7
-4
packages/uni-mp-alipay/__tests__/component.spec.ts
packages/uni-mp-alipay/__tests__/component.spec.ts
+9
-0
packages/uni-mp-alipay/__tests__/testUtils.ts
packages/uni-mp-alipay/__tests__/testUtils.ts
+2
-9
packages/uni-mp-alipay/dist/uni.compiler.js
packages/uni-mp-alipay/dist/uni.compiler.js
+64
-7
packages/uni-mp-alipay/src/compiler/options.ts
packages/uni-mp-alipay/src/compiler/options.ts
+19
-9
packages/uni-mp-baidu/__tests__/component.spec.ts
packages/uni-mp-baidu/__tests__/component.spec.ts
+13
-0
packages/uni-mp-baidu/__tests__/testUtils.ts
packages/uni-mp-baidu/__tests__/testUtils.ts
+2
-10
packages/uni-mp-baidu/build.json
packages/uni-mp-baidu/build.json
+3
-2
packages/uni-mp-baidu/dist/uni.compiler.js
packages/uni-mp-baidu/dist/uni.compiler.js
+13
-7
packages/uni-mp-baidu/src/compiler/options.ts
packages/uni-mp-baidu/src/compiler/options.ts
+16
-7
packages/uni-mp-qq/__tests__/component.spec.ts
packages/uni-mp-qq/__tests__/component.spec.ts
+13
-0
packages/uni-mp-qq/__tests__/testUtils.ts
packages/uni-mp-qq/__tests__/testUtils.ts
+37
-0
packages/uni-mp-qq/build.json
packages/uni-mp-qq/build.json
+4
-1
packages/uni-mp-qq/dist/uni.compiler.js
packages/uni-mp-qq/dist/uni.compiler.js
+19
-16
packages/uni-mp-qq/src/compiler/options.ts
packages/uni-mp-qq/src/compiler/options.ts
+28
-15
packages/uni-mp-toutiao/__tests__/component.spec.ts
packages/uni-mp-toutiao/__tests__/component.spec.ts
+13
-0
packages/uni-mp-toutiao/__tests__/testUtils.ts
packages/uni-mp-toutiao/__tests__/testUtils.ts
+2
-5
packages/uni-mp-toutiao/build.json
packages/uni-mp-toutiao/build.json
+1
-0
packages/uni-mp-toutiao/dist/uni.compiler.js
packages/uni-mp-toutiao/dist/uni.compiler.js
+1
-41
packages/uni-mp-toutiao/src/compiler/options.ts
packages/uni-mp-toutiao/src/compiler/options.ts
+13
-7
packages/uni-mp-weixin/__tests__/component.spec.ts
packages/uni-mp-weixin/__tests__/component.spec.ts
+13
-0
packages/uni-mp-weixin/__tests__/testUtils.ts
packages/uni-mp-weixin/__tests__/testUtils.ts
+37
-0
packages/uni-mp-weixin/build.json
packages/uni-mp-weixin/build.json
+7
-1
packages/uni-mp-weixin/dist/uni.compiler.js
packages/uni-mp-weixin/dist/uni.compiler.js
+20
-21
packages/uni-mp-weixin/src/compiler/options.ts
packages/uni-mp-weixin/src/compiler/options.ts
+30
-19
packages/vite-plugin-uni/src/utils/plugin.ts
packages/vite-plugin-uni/src/utils/plugin.ts
+0
-4
packages/vite-plugin-uni/src/vue/options.ts
packages/vite-plugin-uni/src/vue/options.ts
+7
-21
packages/vite-plugin-uni/src/vue/transforms/transformContext.ts
...es/vite-plugin-uni/src/vue/transforms/transformContext.ts
+0
-13
packages/vite-plugin-uni/src/vue/transforms/transformMatchMedia.ts
...vite-plugin-uni/src/vue/transforms/transformMatchMedia.ts
+0
-7
未找到文件。
packages/uni-app-vite/src/plugin/uni/index.ts
浏览文件 @
6efd63d8
...
@@ -4,6 +4,8 @@ import {
...
@@ -4,6 +4,8 @@ import {
UniVitePlugin
,
UniVitePlugin
,
initI18nOptions
,
initI18nOptions
,
transformPageHead
,
transformPageHead
,
transformMatchMedia
,
transformTapToClick
,
}
from
'
@dcloudio/uni-cli-shared
'
}
from
'
@dcloudio/uni-cli-shared
'
export
function
uniOptions
():
UniVitePlugin
[
'
uni
'
]
{
export
function
uniOptions
():
UniVitePlugin
[
'
uni
'
]
{
...
@@ -32,10 +34,11 @@ export function uniOptions(): UniVitePlugin['uni'] {
...
@@ -32,10 +34,11 @@ export function uniOptions(): UniVitePlugin['uni'] {
compilerOptions
:
{
compilerOptions
:
{
isNativeTag
,
isNativeTag
,
isCustomElement
,
isCustomElement
,
nodeTransforms
:
[
transformPageHead
],
nodeTransforms
:
[
},
transformTapToClick
,
transformEvent
:
{
transformMatchMedia
,
tap
:
'
click
'
,
transformPageHead
,
],
},
},
}
}
}
}
packages/uni-cli-shared/src/vite/index.ts
浏览文件 @
6efd63d8
...
@@ -23,7 +23,6 @@ interface UniVitePluginUniOptions {
...
@@ -23,7 +23,6 @@ interface UniVitePluginUniOptions {
directiveTransforms
?:
CompilerOptions
[
'
directiveTransforms
'
]
directiveTransforms
?:
CompilerOptions
[
'
directiveTransforms
'
]
nodeTransforms
?:
CompilerOptions
[
'
nodeTransforms
'
]
nodeTransforms
?:
CompilerOptions
[
'
nodeTransforms
'
]
}
}
transformEvent
?:
Record
<
string
,
string
>
copyOptions
?:
CopyOptions
|
(()
=>
CopyOptions
)
copyOptions
?:
CopyOptions
|
(()
=>
CopyOptions
)
}
}
export
interface
UniVitePlugin
extends
Plugin
{
export
interface
UniVitePlugin
extends
Plugin
{
...
...
packages/uni-cli-shared/src/vue/transforms/index.ts
浏览文件 @
6efd63d8
import
{
createTransformTag
}
from
'
./transformTag
'
import
{
createTransformEvent
}
from
'
./transformEvent
'
import
{
createTransformComponentLink
}
from
'
./transformComponent
'
import
{
COMPONENT_BIND_LINK
}
from
'
../../mp/constants
'
export
*
from
'
./transformRef
'
export
*
from
'
./transformRef
'
export
*
from
'
./transformPageHead
'
export
*
from
'
./transformPageHead
'
export
*
from
'
./transformComponent
'
export
*
from
'
./transformComponent
'
export
*
from
'
./transformEvent
'
export
*
from
'
./transformTag
'
export
const
transformMatchMedia
=
createTransformTag
({
'
match-media
'
:
'
uni-match-media
'
,
})
export
const
transformTapToClick
=
createTransformEvent
({
tap
:
'
click
'
,
})
export
const
transformComponentLink
=
createTransformComponentLink
(
COMPONENT_BIND_LINK
)
packages/
vite-plugin-uni
/src/vue/transforms/transformEvent.ts
→
packages/
uni-cli-shared
/src/vue/transforms/transformEvent.ts
浏览文件 @
6efd63d8
import
{
DirectiveNode
,
NodeTransform
}
from
'
@vue/compiler-core
'
import
{
DirectiveNode
,
NodeTransform
}
from
'
@vue/compiler-core
'
import
{
isElementNode
,
isSimpleExpressionNode
}
from
'
../../
utils
'
import
{
isElementNode
,
isSimpleExpressionNode
}
from
'
../../
vite/utils/ast
'
export
function
createTransformEvent
(
options
:
Record
<
string
,
string
>
)
{
export
function
createTransformEvent
(
const
transformEvent
:
NodeTransform
=
(
node
)
=>
{
options
:
Record
<
string
,
string
>
):
NodeTransform
{
return
function
transformEvent
(
node
)
{
if
(
!
isElementNode
(
node
))
{
if
(
!
isElementNode
(
node
))
{
return
return
}
}
...
@@ -17,5 +19,4 @@ export function createTransformEvent(options: Record<string, string>) {
...
@@ -17,5 +19,4 @@ export function createTransformEvent(options: Record<string, string>) {
}
}
})
})
}
}
return
transformEvent
}
}
packages/uni-cli-shared/src/vue/transforms/transformTag.ts
0 → 100644
浏览文件 @
6efd63d8
import
{
CodegenContext
,
NodeTransform
}
from
'
@vue/compiler-core
'
import
{
isElementNode
}
from
'
../../vite/utils/ast
'
export
function
createTransformTag
(
opts
:
Record
<
string
,
string
>
):
NodeTransform
{
return
function
transformTag
(
node
,
context
)
{
if
(
!
isElementNode
(
node
))
{
return
}
const
oldTag
=
node
.
tag
const
newTag
=
opts
[
oldTag
]
if
(
!
newTag
)
{
return
}
node
.
tag
=
newTag
// SSR 时,已被提前添加到 components 中
if
(
context
.
ssr
&&
context
.
components
.
has
(
oldTag
))
{
context
.
components
.
delete
(
oldTag
)
context
.
components
.
add
(
newTag
)
}
}
}
const
easycoms
:
Record
<
string
,
string
>
=
{
_component_uni_match_media
:
'
_component_match_media
'
,
_component_page_head_meta
:
'
_component_head
'
,
}
const
easycomKeys
=
Object
.
keys
(
easycoms
)
export
const
onContextCreated
:
(
context
:
CodegenContext
)
=>
void
=
(
context
)
=>
{
if
(
!
context
.
ssr
)
{
return
}
// 替换生成的 easycom 变量名
const
push
=
context
.
push
context
.
push
=
(
code
,
node
)
=>
{
if
(
code
.
includes
(
'
_resolveComponent(
'
))
{
const
name
=
easycomKeys
.
find
((
name
)
=>
code
.
includes
(
name
))
if
(
name
)
{
code
=
code
.
replace
(
name
,
easycoms
[
name
])
}
}
return
push
(
code
,
node
)
}
}
packages/uni-cli-shared/src/vue/utils.ts
浏览文件 @
6efd63d8
...
@@ -69,7 +69,7 @@ export function addStaticClass(node: ElementNode, clazz: string) {
...
@@ -69,7 +69,7 @@ export function addStaticClass(node: ElementNode, clazz: string) {
}
}
}
}
function
createDirectiveNode
(
export
function
createDirectiveNode
(
name
:
string
,
name
:
string
,
arg
:
string
,
arg
:
string
,
exp
:
string
exp
:
string
...
...
packages/uni-h5-vite/src/plugin/index.ts
浏览文件 @
6efd63d8
...
@@ -4,6 +4,8 @@ import { isH5CustomElement, isH5NativeTag } from '@dcloudio/uni-shared'
...
@@ -4,6 +4,8 @@ import { isH5CustomElement, isH5NativeTag } from '@dcloudio/uni-shared'
import
{
import
{
isInHBuilderX
,
isInHBuilderX
,
resolveMainPathOnce
,
resolveMainPathOnce
,
transformMatchMedia
,
transformTapToClick
,
UniVitePlugin
,
UniVitePlugin
,
}
from
'
@dcloudio/uni-cli-shared
'
}
from
'
@dcloudio/uni-cli-shared
'
import
{
createHandleHotUpdate
}
from
'
./handleHotUpdate
'
import
{
createHandleHotUpdate
}
from
'
./handleHotUpdate
'
...
@@ -21,13 +23,14 @@ export const UniH5Plugin: UniVitePlugin = {
...
@@ -21,13 +23,14 @@ export const UniH5Plugin: UniVitePlugin = {
copyOptions
:
{
copyOptions
:
{
assets
:
[
'
hybrid/html
'
],
assets
:
[
'
hybrid/html
'
],
},
},
transformEvent
:
{
tap
:
'
click
'
,
},
compilerOptions
:
{
compilerOptions
:
{
isNativeTag
:
isH5NativeTag
,
isNativeTag
:
isH5NativeTag
,
isCustomElement
:
isH5CustomElement
,
isCustomElement
:
isH5CustomElement
,
nodeTransforms
:
[
transformPageHead
],
nodeTransforms
:
[
transformTapToClick
,
transformMatchMedia
,
transformPageHead
,
],
},
},
},
},
config
(
config
,
env
)
{
config
(
config
,
env
)
{
...
...
packages/uni-mp-alipay/__tests__/component.spec.ts
浏览文件 @
6efd63d8
...
@@ -9,6 +9,15 @@ describe('mp-alipay: transform component', () => {
...
@@ -9,6 +9,15 @@ describe('mp-alipay: transform component', () => {
code
,
code
,
`(_ctx, _cache) => {
`(_ctx, _cache) => {
return {}
return {}
}`
)
})
test
(
`match-media`
,
()
=>
{
assert
(
`<match-media/>`
,
`<uni-match-media v-i="2a9ec0b0-0" onVI="__l"/>`
,
`(_ctx, _cache) => {
return {}
}`
}`
)
)
})
})
...
...
packages/uni-mp-alipay/__tests__/testUtils.ts
浏览文件 @
6efd63d8
import
{
isNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
compile
,
CompilerOptions
}
from
'
@dcloudio/uni-mp-compiler
'
import
{
compile
,
CompilerOptions
}
from
'
@dcloudio/uni-mp-compiler
'
import
{
import
{
compilerOptions
,
miniProgram
}
from
'
../src/compiler/options
'
isCustomElement
,
miniProgram
,
nodeTransforms
,
}
from
'
../src/compiler/options
'
export
function
assert
(
export
function
assert
(
template
:
string
,
template
:
string
,
...
@@ -18,12 +13,9 @@ export function assert(
...
@@ -18,12 +13,9 @@ export function assert(
filename
:
'
foo.vue
'
,
filename
:
'
foo.vue
'
,
prefixIdentifiers
:
true
,
prefixIdentifiers
:
true
,
inline
:
true
,
inline
:
true
,
isNativeTag
,
isCustomElement
,
generatorOpts
:
{
generatorOpts
:
{
concise
:
true
,
concise
:
true
,
},
},
nodeTransforms
,
miniProgram
:
{
miniProgram
:
{
...
miniProgram
,
...
miniProgram
,
emitFile
({
source
})
{
emitFile
({
source
})
{
...
@@ -34,6 +26,7 @@ export function assert(
...
@@ -34,6 +26,7 @@ export function assert(
return
''
return
''
},
},
},
},
...
compilerOptions
,
...
options
,
...
options
,
})
})
if
(
!
options
.
onError
)
{
if
(
!
options
.
onError
)
{
...
...
packages/uni-mp-alipay/dist/uni.compiler.js
浏览文件 @
6efd63d8
...
@@ -2,15 +2,70 @@
...
@@ -2,15 +2,70 @@
var
initMiniProgramPlugin
=
require
(
'
@dcloudio/uni-mp-vite
'
);
var
initMiniProgramPlugin
=
require
(
'
@dcloudio/uni-mp-vite
'
);
var
path
=
require
(
'
path
'
);
var
path
=
require
(
'
path
'
);
var
shared
=
require
(
'
@vue/shared
'
);
var
uniCliShared
=
require
(
'
@dcloudio/uni-cli-shared
'
);
var
uniCliShared
=
require
(
'
@dcloudio/uni-cli-shared
'
);
var
compilerCore
=
require
(
'
@vue/compiler-core
'
);
var
compilerCore
=
require
(
'
@vue/compiler-core
'
);
var
shared
=
require
(
'
@vue/shared
'
);
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
var
initMiniProgramPlugin__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
initMiniProgramPlugin
);
var
initMiniProgramPlugin__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
initMiniProgramPlugin
);
var
path__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
path
);
var
path__default
=
/*#__PURE__*/
_interopDefaultLegacy
(
path
);
const
BUILT_IN_TAGS
=
[
'
ad
'
,
'
ad-content-page
'
,
'
ad-draw
'
,
'
audio
'
,
'
button
'
,
'
camera
'
,
'
canvas
'
,
'
checkbox
'
,
'
checkbox-group
'
,
'
cover-image
'
,
'
cover-view
'
,
'
editor
'
,
'
form
'
,
'
functional-page-navigator
'
,
'
icon
'
,
'
image
'
,
'
input
'
,
'
label
'
,
'
live-player
'
,
'
live-pusher
'
,
'
map
'
,
'
movable-area
'
,
'
movable-view
'
,
'
navigator
'
,
'
official-account
'
,
'
open-data
'
,
'
picker
'
,
'
picker-view
'
,
'
picker-view-column
'
,
'
progress
'
,
'
radio
'
,
'
radio-group
'
,
'
rich-text
'
,
'
scroll-view
'
,
'
slider
'
,
'
swiper
'
,
'
swiper-item
'
,
'
switch
'
,
'
text
'
,
'
textarea
'
,
'
video
'
,
'
view
'
,
'
web-view
'
,
].
map
((
tag
)
=>
'
uni-
'
+
tag
);
function
isBuiltInComponent
(
tag
)
{
return
BUILT_IN_TAGS
.
indexOf
(
'
uni-
'
+
tag
)
!==
-
1
;
}
function
isNativeTag
(
tag
)
{
return
shared
.
isHTMLTag
(
tag
)
||
shared
.
isSVGTag
(
tag
)
||
isBuiltInComponent
(
tag
);
}
function
isCustomElement$1
(
_tag
)
{
return
false
;
}
var
component2
=
true
;
var
component2
=
true
;
var
enableAppxNg
=
true
;
var
enableAppxNg
=
true
;
var
source
=
{
var
source
=
{
...
@@ -137,12 +192,17 @@ const miniProgram = {
...
@@ -137,12 +192,17 @@ const miniProgram = {
},
},
directive
:
'
a:
'
,
directive
:
'
a:
'
,
};
};
// TODO getPhoneNumber 等事件
const
nodeTransforms
=
[
const
nodeTransforms
=
[
transformRef
,
transformRef
,
transformOpenType
,
transformOpenType
,
uniCliShared
.
transformMatchMedia
,
uniCliShared
.
createTransformComponentLink
(
uniCliShared
.
COMPONENT_ON_LINK
,
6
/* ATTRIBUTE */
),
uniCliShared
.
createTransformComponentLink
(
uniCliShared
.
COMPONENT_ON_LINK
,
6
/* ATTRIBUTE */
),
];
];
const
compilerOptions
=
{
isNativeTag
,
isCustomElement
,
nodeTransforms
,
};
const
tags
=
[
const
tags
=
[
'
lifestyle
'
,
'
lifestyle
'
,
'
life-follow
'
,
'
life-follow
'
,
...
@@ -157,7 +217,7 @@ const tags = [
...
@@ -157,7 +217,7 @@ const tags = [
'
mkt
'
,
'
mkt
'
,
];
];
function
isCustomElement
(
tag
)
{
function
isCustomElement
(
tag
)
{
return
tags
.
includes
(
tag
);
return
tags
.
includes
(
tag
)
||
isCustomElement$1
()
;
}
}
const
options
=
{
const
options
=
{
vite
:
{
vite
:
{
...
@@ -215,10 +275,7 @@ const options = {
...
@@ -215,10 +275,7 @@ const options = {
// 暂不处理,让开发者自己全部使用 src 引入
// 暂不处理,让开发者自己全部使用 src 引入
return
`<import-sjs name="
${
filter
.
name
}
" from="
${
filename
}
.sjs"/>`
;
return
`<import-sjs name="
${
filter
.
name
}
" from="
${
filename
}
.sjs"/>`
;
},
},
},
extname
:
'
.axml
'
,
compilerOptions
:
{
},
extname
:
'
.axml
'
,
compilerOptions
}),
isCustomElement
,
nodeTransforms
,
}
}),
style
:
{
style
:
{
extname
:
'
.acss
'
,
extname
:
'
.acss
'
,
},
},
...
...
packages/uni-mp-alipay/src/compiler/options.ts
浏览文件 @
6efd63d8
import
path
from
'
path
'
import
path
from
'
path
'
import
{
NodeTypes
}
from
'
@vue/compiler-core
'
import
{
CompilerOptions
,
NodeTypes
}
from
'
@vue/compiler-core
'
import
{
isNativeTag
,
isCustomElement
as
baseIsCustomElement
,
}
from
'
@dcloudio/uni-shared
'
import
{
import
{
COMPONENT_ON_LINK
,
COMPONENT_ON_LINK
,
createTransformComponentLink
,
createTransformComponentLink
,
MiniProgramCompilerOptions
,
MiniProgramCompilerOptions
,
transformMatchMedia
,
}
from
'
@dcloudio/uni-cli-shared
'
}
from
'
@dcloudio/uni-cli-shared
'
import
{
UniMiniProgramPluginOptions
}
from
'
@dcloudio/uni-mp-vite
'
import
{
UniMiniProgramPluginOptions
}
from
'
@dcloudio/uni-mp-vite
'
import
source
from
'
./mini.project.json
'
import
source
from
'
./mini.project.json
'
...
@@ -25,12 +30,18 @@ export const miniProgram: MiniProgramCompilerOptions = {
...
@@ -25,12 +30,18 @@ export const miniProgram: MiniProgramCompilerOptions = {
},
},
directive
:
'
a:
'
,
directive
:
'
a:
'
,
}
}
// TODO getPhoneNumber 等事件
const
nodeTransforms
=
[
export
const
nodeTransforms
=
[
transformRef
,
transformRef
,
transformOpenType
,
transformOpenType
,
transformMatchMedia
,
createTransformComponentLink
(
COMPONENT_ON_LINK
,
NodeTypes
.
ATTRIBUTE
),
createTransformComponentLink
(
COMPONENT_ON_LINK
,
NodeTypes
.
ATTRIBUTE
),
]
]
export
const
compilerOptions
:
CompilerOptions
=
{
isNativeTag
,
isCustomElement
,
nodeTransforms
,
}
export
const
tags
=
[
export
const
tags
=
[
'
lifestyle
'
,
'
lifestyle
'
,
'
life-follow
'
,
'
life-follow
'
,
...
@@ -44,9 +55,11 @@ export const tags = [
...
@@ -44,9 +55,11 @@ export const tags = [
'
ix-native-list
'
,
'
ix-native-list
'
,
'
mkt
'
,
'
mkt
'
,
]
]
export
function
isCustomElement
(
tag
:
string
)
{
return
tags
.
includes
(
tag
)
function
isCustomElement
(
tag
:
string
)
{
return
tags
.
includes
(
tag
)
||
baseIsCustomElement
(
tag
)
}
}
export
const
options
:
UniMiniProgramPluginOptions
=
{
export
const
options
:
UniMiniProgramPluginOptions
=
{
vite
:
{
vite
:
{
inject
:
{
inject
:
{
...
@@ -108,10 +121,7 @@ export const options: UniMiniProgramPluginOptions = {
...
@@ -108,10 +121,7 @@ export const options: UniMiniProgramPluginOptions = {
},
},
},
},
extname
:
'
.axml
'
,
extname
:
'
.axml
'
,
compilerOptions
:
{
compilerOptions
,
isCustomElement
,
nodeTransforms
,
},
},
},
style
:
{
style
:
{
extname
:
'
.acss
'
,
extname
:
'
.acss
'
,
...
...
packages/uni-mp-baidu/__tests__/component.spec.ts
0 → 100644
浏览文件 @
6efd63d8
import
{
assert
}
from
'
./testUtils
'
describe
(
'
mp-baidu: transform component
'
,
()
=>
{
test
(
`match-media`
,
()
=>
{
assert
(
`<match-media/>`
,
`<uni-match-media v-i="2a9ec0b0-0"/>`
,
`(_ctx, _cache) => {
return {}
}`
)
})
})
packages/uni-mp-baidu/__tests__/testUtils.ts
浏览文件 @
6efd63d8
import
{
isCustomElement
,
isNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
isCustomElement
,
isNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
compile
,
CompilerOptions
}
from
'
@dcloudio/uni-mp-compiler
'
import
{
compile
,
CompilerOptions
}
from
'
@dcloudio/uni-mp-compiler
'
import
{
transformFor
}
from
'
../src/compiler/transforms/vFor
'
import
{
miniProgram
,
compilerOptions
}
from
'
../src/compiler/options
'
import
{
transformOn
}
from
'
../src/compiler/transforms/vOn
'
import
{
transformModel
}
from
'
../src/compiler/transforms/vModel
'
import
{
miniProgram
}
from
'
../src/compiler/options
'
import
{
transformRef
}
from
'
@dcloudio/uni-cli-shared
'
export
function
assert
(
export
function
assert
(
template
:
string
,
template
:
string
,
...
@@ -22,11 +18,6 @@ export function assert(
...
@@ -22,11 +18,6 @@ export function assert(
generatorOpts
:
{
generatorOpts
:
{
concise
:
true
,
concise
:
true
,
},
},
nodeTransforms
:
[
transformRef
,
transformFor
],
directiveTransforms
:
{
on
:
transformOn
,
model
:
transformModel
,
},
miniProgram
:
{
miniProgram
:
{
...
miniProgram
,
...
miniProgram
,
emitFile
({
source
})
{
emitFile
({
source
})
{
...
@@ -37,6 +28,7 @@ export function assert(
...
@@ -37,6 +28,7 @@ export function assert(
return
''
return
''
},
},
},
},
...
compilerOptions
,
...
options
,
...
options
,
})
})
if
(
!
options
.
onError
)
{
if
(
!
options
.
onError
)
{
...
...
packages/uni-mp-baidu/build.json
浏览文件 @
6efd63d8
...
@@ -7,10 +7,11 @@
...
@@ -7,10 +7,11 @@
"format"
:
"cjs"
"format"
:
"cjs"
},
},
"external"
:
[
"external"
:
[
"@vue/compiler-core"
,
"@dcloudio/uni-shared"
,
"@dcloudio/uni-cli-shared"
,
"@dcloudio/uni-cli-shared"
,
"@dcloudio/uni-mp-compiler"
,
"@dcloudio/uni-mp-vite"
,
"@dcloudio/uni-mp-vite"
,
"@
vue/compiler-core
"
"@
dcloudio/uni-mp-compiler
"
]
]
},
},
{
{
...
...
packages/uni-mp-baidu/dist/uni.compiler.js
浏览文件 @
6efd63d8
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
var
initMiniProgramPlugin
=
require
(
'
@dcloudio/uni-mp-vite
'
);
var
initMiniProgramPlugin
=
require
(
'
@dcloudio/uni-mp-vite
'
);
var
path
=
require
(
'
path
'
);
var
path
=
require
(
'
path
'
);
var
uniShared
=
require
(
'
@dcloudio/uni-shared
'
);
var
uniCliShared
=
require
(
'
@dcloudio/uni-cli-shared
'
);
var
uniCliShared
=
require
(
'
@dcloudio/uni-cli-shared
'
);
var
uniMpCompiler
=
require
(
'
@dcloudio/uni-mp-compiler
'
);
var
uniMpCompiler
=
require
(
'
@dcloudio/uni-mp-compiler
'
);
var
compilerCore
=
require
(
'
@vue/compiler-core
'
);
var
compilerCore
=
require
(
'
@vue/compiler-core
'
);
...
@@ -144,6 +145,11 @@ const transformModel = (dir, node, context, augmentor) => {
...
@@ -144,6 +145,11 @@ const transformModel = (dir, node, context, augmentor) => {
return
res
;
return
res
;
};
};
const
nodeTransforms
=
[
uniCliShared
.
transformRef
,
transformFor
,
uniCliShared
.
transformMatchMedia
];
const
directiveTransforms
=
{
on
:
transformOn
,
model
:
transformModel
,
};
const
miniProgram
=
{
const
miniProgram
=
{
class
:
{
class
:
{
array
:
true
,
array
:
true
,
...
@@ -153,6 +159,12 @@ const miniProgram = {
...
@@ -153,6 +159,12 @@ const miniProgram = {
},
},
directive
:
'
s-
'
,
directive
:
'
s-
'
,
};
};
const
compilerOptions
=
{
isNativeTag
:
uniShared
.
isNativeTag
,
isCustomElement
:
uniShared
.
isCustomElement
,
nodeTransforms
,
directiveTransforms
,
};
const
projectConfigFilename
=
'
project.swan.json
'
;
const
projectConfigFilename
=
'
project.swan.json
'
;
const
options
=
{
const
options
=
{
vite
:
{
vite
:
{
...
@@ -186,13 +198,7 @@ const options = {
...
@@ -186,13 +198,7 @@ const options = {
${
filter
.
code
}
${
filter
.
code
}
</import-sjs>`
;
</import-sjs>`
;
},
},
},
extname
:
'
.swan
'
,
compilerOptions
:
{
},
extname
:
'
.swan
'
,
compilerOptions
}),
nodeTransforms
:
[
uniCliShared
.
transformRef
,
transformFor
],
directiveTransforms
:
{
on
:
transformOn
,
model
:
transformModel
,
},
}
}),
style
:
{
style
:
{
extname
:
'
.css
'
,
extname
:
'
.css
'
,
},
},
...
...
packages/uni-mp-baidu/src/compiler/options.ts
浏览文件 @
6efd63d8
import
path
from
'
path
'
import
path
from
'
path
'
import
type
{
CompilerOptions
}
from
'
@vue/compiler-core
'
import
{
isCustomElement
,
isNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
import
{
MiniProgramCompilerOptions
,
MiniProgramCompilerOptions
,
transformMatchMedia
,
transformRef
,
transformRef
,
}
from
'
@dcloudio/uni-cli-shared
'
}
from
'
@dcloudio/uni-cli-shared
'
import
{
UniMiniProgramPluginOptions
}
from
'
@dcloudio/uni-mp-vite
'
import
{
UniMiniProgramPluginOptions
}
from
'
@dcloudio/uni-mp-vite
'
...
@@ -10,6 +13,11 @@ import { transformFor } from './transforms/vFor'
...
@@ -10,6 +13,11 @@ import { transformFor } from './transforms/vFor'
import
{
transformOn
}
from
'
./transforms/vOn
'
import
{
transformOn
}
from
'
./transforms/vOn
'
import
{
transformModel
}
from
'
./transforms/vModel
'
import
{
transformModel
}
from
'
./transforms/vModel
'
const
nodeTransforms
=
[
transformRef
,
transformFor
,
transformMatchMedia
]
const
directiveTransforms
=
{
on
:
transformOn
,
model
:
transformModel
,
}
export
const
miniProgram
:
MiniProgramCompilerOptions
=
{
export
const
miniProgram
:
MiniProgramCompilerOptions
=
{
class
:
{
class
:
{
array
:
true
,
array
:
true
,
...
@@ -20,6 +28,13 @@ export const miniProgram: MiniProgramCompilerOptions = {
...
@@ -20,6 +28,13 @@ export const miniProgram: MiniProgramCompilerOptions = {
directive
:
'
s-
'
,
directive
:
'
s-
'
,
}
}
export
const
compilerOptions
:
CompilerOptions
=
{
isNativeTag
,
isCustomElement
,
nodeTransforms
,
directiveTransforms
,
}
const
projectConfigFilename
=
'
project.swan.json
'
const
projectConfigFilename
=
'
project.swan.json
'
export
const
options
:
UniMiniProgramPluginOptions
=
{
export
const
options
:
UniMiniProgramPluginOptions
=
{
...
@@ -59,13 +74,7 @@ export const options: UniMiniProgramPluginOptions = {
...
@@ -59,13 +74,7 @@ export const options: UniMiniProgramPluginOptions = {
},
},
},
},
extname
:
'
.swan
'
,
extname
:
'
.swan
'
,
compilerOptions
:
{
compilerOptions
,
nodeTransforms
:
[
transformRef
,
transformFor
],
directiveTransforms
:
{
on
:
transformOn
,
model
:
transformModel
,
},
},
},
},
style
:
{
style
:
{
extname
:
'
.css
'
,
extname
:
'
.css
'
,
...
...
packages/uni-mp-qq/__tests__/component.spec.ts
0 → 100644
浏览文件 @
6efd63d8
import
{
assert
}
from
'
./testUtils
'
describe
(
'
mp-baidu: transform component
'
,
()
=>
{
test
(
`match-media`
,
()
=>
{
assert
(
`<match-media/>`
,
`<uni-match-media v-i="2a9ec0b0-0" bind:__l="__l"/>`
,
`(_ctx, _cache) => {
return {}
}`
)
})
})
packages/uni-mp-qq/__tests__/testUtils.ts
0 → 100644
浏览文件 @
6efd63d8
import
{
isNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
compile
,
CompilerOptions
}
from
'
@dcloudio/uni-mp-compiler
'
import
{
compilerOptions
,
miniProgram
}
from
'
../src/compiler/options
'
export
function
assert
(
template
:
string
,
templateCode
:
string
,
renderCode
:
string
,
options
:
CompilerOptions
=
{}
)
{
const
res
=
compile
(
template
,
{
mode
:
'
module
'
,
filename
:
'
foo.vue
'
,
prefixIdentifiers
:
true
,
inline
:
true
,
isNativeTag
,
generatorOpts
:
{
concise
:
true
,
},
miniProgram
:
{
...
miniProgram
,
emitFile
({
source
})
{
// console.log(source)
if
(
!
options
.
onError
)
{
expect
(
source
).
toBe
(
templateCode
)
}
return
''
},
},
...
compilerOptions
,
...
options
,
})
if
(
!
options
.
onError
)
{
expect
(
res
.
code
).
toBe
(
renderCode
)
}
}
packages/uni-mp-qq/build.json
浏览文件 @
6efd63d8
...
@@ -8,8 +8,11 @@
...
@@ -8,8 +8,11 @@
},
},
"external"
:
[
"external"
:
[
"fs-extra"
,
"fs-extra"
,
"@vue/compiler-core"
,
"@dcloudio/uni-shared"
,
"@dcloudio/uni-cli-shared"
,
"@dcloudio/uni-cli-shared"
,
"@dcloudio/uni-mp-vite"
"@dcloudio/uni-mp-vite"
,
"@dcloudio/uni-mp-compiler"
]
]
},
},
{
{
...
...
packages/uni-mp-qq/dist/uni.compiler.js
浏览文件 @
6efd63d8
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
var
initMiniProgramPlugin
=
require
(
'
@dcloudio/uni-mp-vite
'
);
var
initMiniProgramPlugin
=
require
(
'
@dcloudio/uni-mp-vite
'
);
var
path
=
require
(
'
path
'
);
var
path
=
require
(
'
path
'
);
var
fs
=
require
(
'
fs-extra
'
);
var
fs
=
require
(
'
fs-extra
'
);
var
uniShared
=
require
(
'
@dcloudio/uni-shared
'
);
var
uniCliShared
=
require
(
'
@dcloudio/uni-cli-shared
'
);
var
uniCliShared
=
require
(
'
@dcloudio/uni-cli-shared
'
);
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
...
@@ -84,8 +85,23 @@ var source = {
...
@@ -84,8 +85,23 @@ var source = {
const
nodeTransforms
=
[
const
nodeTransforms
=
[
uniCliShared
.
transformRef
,
uniCliShared
.
transformRef
,
uniCliShared
.
createTransformComponentLink
(
uniCliShared
.
COMPONENT_BIND_LINK
),
uniCliShared
.
transformMatchMedia
,
uniCliShared
.
transformComponentLink
,
];
];
const
compilerOptions
=
{
isNativeTag
:
uniShared
.
isNativeTag
,
isCustomElement
:
uniShared
.
isCustomElement
,
nodeTransforms
,
};
const
miniProgram
=
{
class
:
{
array
:
true
,
},
slot
:
{
fallback
:
false
,
},
directive
:
'
qq:
'
,
};
const
options
=
{
const
options
=
{
vite
:
{
vite
:
{
inject
:
{
inject
:
{
...
@@ -115,11 +131,7 @@ const options = {
...
@@ -115,11 +131,7 @@ const options = {
filename
:
'
project.config.json
'
,
filename
:
'
project.config.json
'
,
source
,
source
,
},
},
template
:
{
template
:
Object
.
assign
(
Object
.
assign
({},
miniProgram
),
{
filter
:
{
class
:
{
array
:
true
,
},
filter
:
{
extname
:
'
.qs
'
,
extname
:
'
.qs
'
,
lang
:
'
wxs
'
,
lang
:
'
wxs
'
,
generate
(
filter
,
filename
)
{
generate
(
filter
,
filename
)
{
...
@@ -130,16 +142,7 @@ const options = {
...
@@ -130,16 +142,7 @@ const options = {
${
filter
.
code
}
${
filter
.
code
}
</qs>`
;
</qs>`
;
},
},
},
},
extname
:
'
.qml
'
,
compilerOptions
}),
slot
:
{
fallback
:
false
,
},
extname
:
'
.qml
'
,
directive
:
'
qq:
'
,
compilerOptions
:
{
nodeTransforms
,
},
},
style
:
{
style
:
{
extname
:
'
.qss
'
,
extname
:
'
.qss
'
,
},
},
...
...
packages/uni-mp-qq/src/compiler/options.ts
浏览文件 @
6efd63d8
import
path
from
'
path
'
import
path
from
'
path
'
import
type
{
CompilerOptions
}
from
'
@vue/compiler-core
'
import
{
isCustomElement
,
isNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
import
{
COMPONENT_BIND_LINK
,
MiniProgramCompilerOptions
,
createTransformComponentLink
,
transformComponentLink
,
transformMatchMedia
,
transformRef
,
transformRef
,
}
from
'
@dcloudio/uni-cli-shared
'
}
from
'
@dcloudio/uni-cli-shared
'
import
{
UniMiniProgramPluginOptions
}
from
'
@dcloudio/uni-mp-vite
'
import
{
UniMiniProgramPluginOptions
}
from
'
@dcloudio/uni-mp-vite
'
import
source
from
'
./project.config.json
'
import
source
from
'
./project.config.json
'
export
const
nodeTransforms
=
[
const
nodeTransforms
=
[
transformRef
,
transformRef
,
createTransformComponentLink
(
COMPONENT_BIND_LINK
),
transformMatchMedia
,
transformComponentLink
,
]
]
export
const
compilerOptions
:
CompilerOptions
=
{
isNativeTag
,
isCustomElement
,
nodeTransforms
,
}
export
const
miniProgram
:
MiniProgramCompilerOptions
=
{
class
:
{
array
:
true
,
},
slot
:
{
fallback
:
false
,
},
directive
:
'
qq:
'
,
}
export
const
options
:
UniMiniProgramPluginOptions
=
{
export
const
options
:
UniMiniProgramPluginOptions
=
{
vite
:
{
vite
:
{
inject
:
{
inject
:
{
...
@@ -43,9 +63,8 @@ export const options: UniMiniProgramPluginOptions = {
...
@@ -43,9 +63,8 @@ export const options: UniMiniProgramPluginOptions = {
source
,
source
,
},
},
template
:
{
template
:
{
class
:
{
/* eslint-disable no-restricted-syntax */
array
:
true
,
...
miniProgram
,
},
filter
:
{
filter
:
{
extname
:
'
.qs
'
,
extname
:
'
.qs
'
,
lang
:
'
wxs
'
,
lang
:
'
wxs
'
,
...
@@ -58,14 +77,8 @@ export const options: UniMiniProgramPluginOptions = {
...
@@ -58,14 +77,8 @@ export const options: UniMiniProgramPluginOptions = {
</qs>`
</qs>`
},
},
},
},
slot
:
{
fallback
:
false
,
},
extname
:
'
.qml
'
,
extname
:
'
.qml
'
,
directive
:
'
qq:
'
,
compilerOptions
,
compilerOptions
:
{
nodeTransforms
,
},
},
},
style
:
{
style
:
{
extname
:
'
.qss
'
,
extname
:
'
.qss
'
,
...
...
packages/uni-mp-toutiao/__tests__/component.spec.ts
0 → 100644
浏览文件 @
6efd63d8
import
{
assert
}
from
'
./testUtils
'
describe
(
'
mp-baidu: transform component
'
,
()
=>
{
test
(
`match-media`
,
()
=>
{
assert
(
`<match-media/>`
,
`<uni-match-media v-i="2a9ec0b0-0" bind:__l="__l"/>`
,
`(_ctx, _cache) => {
return {}
}`
)
})
})
packages/uni-mp-toutiao/__tests__/testUtils.ts
浏览文件 @
6efd63d8
import
{
isCustomElement
,
isNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
compile
,
CompilerOptions
}
from
'
@dcloudio/uni-mp-compiler
'
import
{
compile
,
CompilerOptions
}
from
'
@dcloudio/uni-mp-compiler
'
import
{
miniProgram
,
nodeTransform
s
}
from
'
../src/compiler/options
'
import
{
miniProgram
,
compilerOption
s
}
from
'
../src/compiler/options
'
export
function
assert
(
export
function
assert
(
template
:
string
,
template
:
string
,
...
@@ -14,12 +13,9 @@ export function assert(
...
@@ -14,12 +13,9 @@ export function assert(
filename
:
'
foo.vue
'
,
filename
:
'
foo.vue
'
,
prefixIdentifiers
:
true
,
prefixIdentifiers
:
true
,
inline
:
true
,
inline
:
true
,
isNativeTag
,
isCustomElement
,
generatorOpts
:
{
generatorOpts
:
{
concise
:
true
,
concise
:
true
,
},
},
nodeTransforms
,
miniProgram
:
{
miniProgram
:
{
...
miniProgram
,
...
miniProgram
,
emitFile
({
source
})
{
emitFile
({
source
})
{
...
@@ -30,6 +26,7 @@ export function assert(
...
@@ -30,6 +26,7 @@ export function assert(
return
''
return
''
},
},
},
},
...
compilerOptions
,
...
options
,
...
options
,
})
})
if
(
!
options
.
onError
)
{
if
(
!
options
.
onError
)
{
...
...
packages/uni-mp-toutiao/build.json
浏览文件 @
6efd63d8
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
},
},
"external"
:
[
"external"
:
[
"@vue/compiler-core"
,
"@vue/compiler-core"
,
"@dcloudio/uni-shared"
,
"@dcloudio/uni-cli-shared"
,
"@dcloudio/uni-cli-shared"
,
"@dcloudio/uni-mp-vite"
,
"@dcloudio/uni-mp-vite"
,
"@dcloudio/uni-mp-compiler"
"@dcloudio/uni-mp-compiler"
...
...
packages/uni-mp-toutiao/dist/uni.compiler.js
浏览文件 @
6efd63d8
...
@@ -2,9 +2,6 @@
...
@@ -2,9 +2,6 @@
var
initMiniProgramPlugin
=
require
(
'
@dcloudio/uni-mp-vite
'
);
var
initMiniProgramPlugin
=
require
(
'
@dcloudio/uni-mp-vite
'
);
var
path
=
require
(
'
path
'
);
var
path
=
require
(
'
path
'
);
var
uniCliShared
=
require
(
'
@dcloudio/uni-cli-shared
'
);
var
uniMpCompiler
=
require
(
'
@dcloudio/uni-mp-compiler
'
);
var
compilerCore
=
require
(
'
@vue/compiler-core
'
);
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
...
@@ -32,42 +29,7 @@ var source = {
...
@@ -32,42 +29,7 @@ var source = {
condition
:
condition
condition
:
condition
};
};
function
transformSwiper
(
node
)
{
if
(
node
.
type
!==
1
/* ELEMENT */
||
node
.
tag
!==
'
swiper
'
)
{
return
;
}
const
disableTouchProp
=
compilerCore
.
findProp
(
node
,
'
disable-touch
'
,
false
,
true
);
if
(
!
disableTouchProp
)
{
return
;
}
const
{
props
}
=
node
;
if
(
disableTouchProp
.
type
===
6
/* ATTRIBUTE */
)
{
// <swiper disable-touch/> => <swiper :touchable="false"/>
props
.
splice
(
props
.
indexOf
(
disableTouchProp
),
1
,
uniCliShared
.
createBindDirectiveNode
(
'
touchable
'
,
'
false
'
));
}
else
{
if
(
disableTouchProp
.
exp
)
{
// <swiper :disable-touch="true"/> => <swiper :touchable="!(true)"/>
let
touchable
=
''
;
if
(
disableTouchProp
.
exp
.
type
===
4
/* SIMPLE_EXPRESSION */
)
{
if
(
disableTouchProp
.
exp
.
content
===
'
true
'
)
{
touchable
=
'
false
'
;
}
else
if
(
disableTouchProp
.
exp
.
content
===
'
false
'
)
{
touchable
=
'
true
'
;
}
}
props
.
splice
(
props
.
indexOf
(
disableTouchProp
),
1
,
uniCliShared
.
createBindDirectiveNode
(
'
touchable
'
,
touchable
||
`!(
${
uniMpCompiler
.
genExpr
(
disableTouchProp
.
exp
)}
)`
));
}
}
}
const
projectConfigFilename
=
'
project.config.json
'
;
const
projectConfigFilename
=
'
project.config.json
'
;
const
nodeTransforms
=
[
uniCliShared
.
transformRef
,
transformSwiper
,
uniCliShared
.
createTransformComponentLink
(
uniCliShared
.
COMPONENT_BIND_LINK
),
];
const
miniProgram
=
{
const
miniProgram
=
{
class
:
{
class
:
{
array
:
false
,
array
:
false
,
...
@@ -109,9 +71,7 @@ const options = {
...
@@ -109,9 +71,7 @@ const options = {
${
filter
.
code
}
${
filter
.
code
}
</sjs>`
;
</sjs>`
;
},
},
},
extname
:
'
.ttml
'
,
compilerOptions
:
{
},
extname
:
'
.ttml
'
}),
nodeTransforms
,
}
}),
style
:
{
style
:
{
extname
:
'
.ttss
'
,
extname
:
'
.ttss
'
,
},
},
...
...
packages/uni-mp-toutiao/src/compiler/options.ts
浏览文件 @
6efd63d8
import
path
from
'
path
'
import
path
from
'
path
'
import
type
{
CompilerOptions
}
from
'
@vue/compiler-core
'
import
{
isCustomElement
,
isNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
import
{
COMPONENT_BIND_LINK
,
createTransformComponentLink
,
MiniProgramCompilerOptions
,
MiniProgramCompilerOptions
,
transformComponentLink
,
transformMatchMedia
,
transformRef
,
transformRef
,
}
from
'
@dcloudio/uni-cli-shared
'
}
from
'
@dcloudio/uni-cli-shared
'
import
{
UniMiniProgramPluginOptions
}
from
'
@dcloudio/uni-mp-vite
'
import
{
UniMiniProgramPluginOptions
}
from
'
@dcloudio/uni-mp-vite
'
...
@@ -12,11 +14,18 @@ import { transformSwiper } from './transforms/transformSwiper'
...
@@ -12,11 +14,18 @@ import { transformSwiper } from './transforms/transformSwiper'
const
projectConfigFilename
=
'
project.config.json
'
const
projectConfigFilename
=
'
project.config.json
'
export
const
nodeTransforms
=
[
const
nodeTransforms
=
[
transformRef
,
transformRef
,
transformSwiper
,
transformSwiper
,
createTransformComponentLink
(
COMPONENT_BIND_LINK
),
transformMatchMedia
,
transformComponentLink
,
]
]
export
const
compilerOptions
:
CompilerOptions
=
{
isNativeTag
,
isCustomElement
,
nodeTransforms
,
}
export
const
miniProgram
:
MiniProgramCompilerOptions
=
{
export
const
miniProgram
:
MiniProgramCompilerOptions
=
{
class
:
{
class
:
{
array
:
false
,
array
:
false
,
...
@@ -64,9 +73,6 @@ ${filter.code}
...
@@ -64,9 +73,6 @@ ${filter.code}
},
},
},
},
extname
:
'
.ttml
'
,
extname
:
'
.ttml
'
,
compilerOptions
:
{
nodeTransforms
,
},
},
},
style
:
{
style
:
{
extname
:
'
.ttss
'
,
extname
:
'
.ttss
'
,
...
...
packages/uni-mp-weixin/__tests__/component.spec.ts
0 → 100644
浏览文件 @
6efd63d8
import
{
assert
}
from
'
./testUtils
'
describe
(
'
mp-baidu: transform component
'
,
()
=>
{
test
(
`match-media`
,
()
=>
{
assert
(
`<match-media/>`
,
`<match-media/>`
,
`(_ctx, _cache) => {
return {}
}`
)
})
})
packages/uni-mp-weixin/__tests__/testUtils.ts
0 → 100644
浏览文件 @
6efd63d8
import
{
isNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
compile
,
CompilerOptions
}
from
'
@dcloudio/uni-mp-compiler
'
import
{
compilerOptions
,
miniProgram
}
from
'
../src/compiler/options
'
export
function
assert
(
template
:
string
,
templateCode
:
string
,
renderCode
:
string
,
options
:
CompilerOptions
=
{}
)
{
const
res
=
compile
(
template
,
{
mode
:
'
module
'
,
filename
:
'
foo.vue
'
,
prefixIdentifiers
:
true
,
inline
:
true
,
isNativeTag
,
generatorOpts
:
{
concise
:
true
,
},
miniProgram
:
{
...
miniProgram
,
emitFile
({
source
})
{
// console.log(source)
if
(
!
options
.
onError
)
{
expect
(
source
).
toBe
(
templateCode
)
}
return
''
},
},
...
compilerOptions
,
...
options
,
})
if
(
!
options
.
onError
)
{
expect
(
res
.
code
).
toBe
(
renderCode
)
}
}
packages/uni-mp-weixin/build.json
浏览文件 @
6efd63d8
...
@@ -6,7 +6,13 @@
...
@@ -6,7 +6,13 @@
"output"
:
{
"output"
:
{
"format"
:
"cjs"
"format"
:
"cjs"
},
},
"external"
:
[
"@dcloudio/uni-cli-shared"
,
"@dcloudio/uni-mp-vite"
]
"external"
:
[
"@vue/compiler-core"
,
"@dcloudio/uni-shared"
,
"@dcloudio/uni-cli-shared"
,
"@dcloudio/uni-mp-vite"
,
"@dcloudio/uni-mp-compiler"
]
},
},
{
{
"input"
:
{
"input"
:
{
...
...
packages/uni-mp-weixin/dist/uni.compiler.js
浏览文件 @
6efd63d8
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
var
initMiniProgramPlugin
=
require
(
'
@dcloudio/uni-mp-vite
'
);
var
initMiniProgramPlugin
=
require
(
'
@dcloudio/uni-mp-vite
'
);
var
path
=
require
(
'
path
'
);
var
path
=
require
(
'
path
'
);
var
uniShared
=
require
(
'
@dcloudio/uni-shared
'
);
var
uniCliShared
=
require
(
'
@dcloudio/uni-cli-shared
'
);
var
uniCliShared
=
require
(
'
@dcloudio/uni-cli-shared
'
);
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
function
_interopDefaultLegacy
(
e
)
{
return
e
&&
typeof
e
===
'
object
'
&&
'
default
'
in
e
?
e
:
{
'
default
'
:
e
};
}
...
@@ -58,6 +59,23 @@ var source = {
...
@@ -58,6 +59,23 @@ var source = {
condition
:
condition
condition
:
condition
};
};
const
compilerOptions
=
{
isNativeTag
:
uniShared
.
isNativeTag
,
isCustomElement
:
(
tag
)
=>
{
return
([
'
page-meta
'
,
'
navigation-bar
'
,
'
match-media
'
].
includes
(
tag
)
||
uniShared
.
isCustomElement
(
tag
));
},
nodeTransforms
:
[
uniCliShared
.
transformRef
,
uniCliShared
.
transformComponentLink
],
};
const
miniProgram
=
{
class
:
{
array
:
true
,
},
slot
:
{
fallback
:
false
,
},
directive
:
'
wx:
'
,
};
const
projectConfigFilename
=
'
project.config.json
'
;
const
projectConfigFilename
=
'
project.config.json
'
;
const
options
=
{
const
options
=
{
vite
:
{
vite
:
{
...
@@ -95,11 +113,7 @@ const options = {
...
@@ -95,11 +113,7 @@ const options = {
filename
:
projectConfigFilename
,
filename
:
projectConfigFilename
,
source
,
source
,
},
},
template
:
{
template
:
Object
.
assign
(
Object
.
assign
({},
miniProgram
),
{
filter
:
{
class
:
{
array
:
true
,
},
filter
:
{
extname
:
'
.wxs
'
,
extname
:
'
.wxs
'
,
lang
:
'
wxs
'
,
lang
:
'
wxs
'
,
generate
(
filter
,
filename
)
{
generate
(
filter
,
filename
)
{
...
@@ -110,22 +124,7 @@ const options = {
...
@@ -110,22 +124,7 @@ const options = {
${
filter
.
code
}
${
filter
.
code
}
</wxs>`
;
</wxs>`
;
},
},
},
},
extname
:
'
.wxml
'
,
compilerOptions
}),
slot
:
{
fallback
:
false
,
},
extname
:
'
.wxml
'
,
directive
:
'
wx:
'
,
compilerOptions
:
{
isCustomElement
:
(
tag
)
=>
{
return
[
'
page-meta
'
,
'
navigation-bar
'
,
'
match-media
'
].
includes
(
tag
);
},
nodeTransforms
:
[
uniCliShared
.
transformRef
,
uniCliShared
.
createTransformComponentLink
(
uniCliShared
.
COMPONENT_BIND_LINK
),
],
},
},
style
:
{
style
:
{
extname
:
'
.wxss
'
,
extname
:
'
.wxss
'
,
},
},
...
...
packages/uni-mp-weixin/src/compiler/options.ts
浏览文件 @
6efd63d8
import
path
from
'
path
'
import
path
from
'
path
'
import
type
{
CompilerOptions
}
from
'
@vue/compiler-core
'
import
{
isNativeTag
,
isCustomElement
as
baseIsCustomElement
,
}
from
'
@dcloudio/uni-shared
'
import
{
import
{
COMPONENT_BIND_LINK
,
MiniProgramCompilerOptions
,
createT
ransformComponentLink
,
t
ransformComponentLink
,
transformRef
,
transformRef
,
}
from
'
@dcloudio/uni-cli-shared
'
}
from
'
@dcloudio/uni-cli-shared
'
import
{
UniMiniProgramPluginOptions
}
from
'
@dcloudio/uni-mp-vite
'
import
{
UniMiniProgramPluginOptions
}
from
'
@dcloudio/uni-mp-vite
'
import
source
from
'
./project.config.json
'
import
source
from
'
./project.config.json
'
export
const
compilerOptions
:
CompilerOptions
=
{
isNativeTag
,
isCustomElement
:
(
tag
)
=>
{
return
(
[
'
page-meta
'
,
'
navigation-bar
'
,
'
match-media
'
].
includes
(
tag
)
||
baseIsCustomElement
(
tag
)
)
},
nodeTransforms
:
[
transformRef
,
transformComponentLink
],
}
export
const
miniProgram
:
MiniProgramCompilerOptions
=
{
class
:
{
array
:
true
,
},
slot
:
{
fallback
:
false
,
},
directive
:
'
wx:
'
,
}
const
projectConfigFilename
=
'
project.config.json
'
const
projectConfigFilename
=
'
project.config.json
'
export
const
options
:
UniMiniProgramPluginOptions
=
{
export
const
options
:
UniMiniProgramPluginOptions
=
{
...
@@ -48,9 +72,8 @@ export const options: UniMiniProgramPluginOptions = {
...
@@ -48,9 +72,8 @@ export const options: UniMiniProgramPluginOptions = {
source
,
source
,
},
},
template
:
{
template
:
{
class
:
{
/* eslint-disable no-restricted-syntax */
array
:
true
,
...
miniProgram
,
},
filter
:
{
filter
:
{
extname
:
'
.wxs
'
,
extname
:
'
.wxs
'
,
lang
:
'
wxs
'
,
lang
:
'
wxs
'
,
...
@@ -63,20 +86,8 @@ ${filter.code}
...
@@ -63,20 +86,8 @@ ${filter.code}
</wxs>`
</wxs>`
},
},
},
},
slot
:
{
fallback
:
false
,
},
extname
:
'
.wxml
'
,
extname
:
'
.wxml
'
,
directive
:
'
wx:
'
,
compilerOptions
,
compilerOptions
:
{
isCustomElement
:
(
tag
)
=>
{
return
[
'
page-meta
'
,
'
navigation-bar
'
,
'
match-media
'
].
includes
(
tag
)
},
nodeTransforms
:
[
transformRef
,
createTransformComponentLink
(
COMPONENT_BIND_LINK
),
],
},
},
},
style
:
{
style
:
{
extname
:
'
.wxss
'
,
extname
:
'
.wxss
'
,
...
...
packages/vite-plugin-uni/src/utils/plugin.ts
浏览文件 @
6efd63d8
...
@@ -34,7 +34,6 @@ export function initPluginUniOptions(UniVitePlugins: UniVitePlugin[]) {
...
@@ -34,7 +34,6 @@ export function initPluginUniOptions(UniVitePlugins: UniVitePlugin[]) {
compiler
:
pluginTemplateCompiler
,
compiler
:
pluginTemplateCompiler
,
copyOptions
:
pluginCopyOptions
,
copyOptions
:
pluginCopyOptions
,
compilerOptions
:
pluginCompilerOptions
,
compilerOptions
:
pluginCompilerOptions
,
transformEvent
:
pluginTransformEvent
,
}
=
plugin
.
uni
||
{}
}
=
plugin
.
uni
||
{}
if
(
pluginTemplateCompiler
)
{
if
(
pluginTemplateCompiler
)
{
compiler
=
pluginTemplateCompiler
compiler
=
pluginTemplateCompiler
...
@@ -42,9 +41,6 @@ export function initPluginUniOptions(UniVitePlugins: UniVitePlugin[]) {
...
@@ -42,9 +41,6 @@ export function initPluginUniOptions(UniVitePlugins: UniVitePlugin[]) {
if
(
pluginCompilerOptions
)
{
if
(
pluginCompilerOptions
)
{
extend
(
compilerOptions
,
pluginCompilerOptions
)
extend
(
compilerOptions
,
pluginCompilerOptions
)
}
}
if
(
pluginTransformEvent
)
{
extend
(
transformEvent
,
pluginTransformEvent
)
}
if
(
pluginCopyOptions
)
{
if
(
pluginCopyOptions
)
{
let
copyOptions
=
pluginCopyOptions
as
CopyOptions
let
copyOptions
=
pluginCopyOptions
as
CopyOptions
if
(
isFunction
(
pluginCopyOptions
))
{
if
(
isFunction
(
pluginCopyOptions
))
{
...
...
packages/vite-plugin-uni/src/vue/options.ts
浏览文件 @
6efd63d8
import
{
extend
,
hasOwn
,
isArray
,
isPlainObject
}
from
'
@vue/shared
'
import
{
hasOwn
,
isArray
,
isPlainObject
}
from
'
@vue/shared
'
import
{
TemplateCompiler
}
from
'
@vue/compiler-sfc
'
import
{
TemplateCompiler
}
from
'
@vue/compiler-sfc
'
import
{
import
{
EXTNAME_VUE_RE
,
EXTNAME_VUE_RE
,
UniVitePlugin
,
UniVitePlugin
,
uniPostcssScopedPlugin
,
uniPostcssScopedPlugin
,
createUniVueTransformAssetUrls
,
createUniVueTransformAssetUrls
,
onContextCreated
,
}
from
'
@dcloudio/uni-cli-shared
'
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
transformMatchMedia
}
from
'
./transforms/transformMatchMedia
'
import
{
createTransformEvent
}
from
'
./transforms/transformEvent
'
// import { transformContext } from './transforms/transformContext'
export
function
initPluginVueOptions
(
export
function
initPluginVueOptions
(
options
:
VitePluginUniResolvedOptions
,
options
:
VitePluginUniResolvedOptions
,
...
@@ -64,11 +62,11 @@ export function initPluginVueOptions(
...
@@ -64,11 +62,11 @@ export function initPluginVueOptions(
}
}
compilerOptions
.
isNativeTag
=
isNativeTag
compilerOptions
.
isNativeTag
=
isNativeTag
compilerOptions
.
isCustomElement
=
isCustomElement
compilerOptions
.
isCustomElement
=
isCustomElement
if
(
directiveTransforms
)
{
;(
compilerOptions
as
any
).
onContextCreated
=
onContextCreated
compilerOptions
.
directiveTransforms
=
extend
(
compilerOptions
.
directiveTransforms
||
{},
compilerOptions
.
directiveTransforms
=
{
directiveTransforms
...
compilerOptions
.
directiveTransforms
,
)
...
directiveTransforms
,
}
}
if
(
!
compilerOptions
.
nodeTransforms
)
{
if
(
!
compilerOptions
.
nodeTransforms
)
{
...
@@ -85,18 +83,6 @@ export function initPluginVueOptions(
...
@@ -85,18 +83,6 @@ export function initPluginVueOptions(
// compatConfig
// compatConfig
// )
// )
const
eventOpts
=
UniVitePlugins
.
reduce
<
Record
<
string
,
string
>>
(
(
eventOpts
,
UniVitePlugin
)
=>
{
return
extend
(
eventOpts
,
UniVitePlugin
.
uni
?.
transformEvent
)
},
{}
)
// compilerOptions.nodeTransforms.unshift(transformContext)
compilerOptions
.
nodeTransforms
.
unshift
(
createTransformEvent
(
eventOpts
))
if
(
options
.
platform
!==
'
mp-weixin
'
)
{
compilerOptions
.
nodeTransforms
.
unshift
(
transformMatchMedia
)
}
// App,MP 平台不支持使用静态节点
// App,MP 平台不支持使用静态节点
compilerOptions
.
hoistStatic
=
false
compilerOptions
.
hoistStatic
=
false
return
vueOptions
return
vueOptions
...
...
packages/vite-plugin-uni/src/vue/transforms/transformContext.ts
已删除
100644 → 0
浏览文件 @
ab4470e8
import
{
// RESOLVE_DYNAMIC_COMPONENT,
NodeTypes
,
NodeTransform
,
}
from
'
@vue/compiler-core
'
export
const
transformContext
:
NodeTransform
=
(
node
,
context
)
=>
{
if
(
node
.
type
===
NodeTypes
.
ROOT
)
{
// 注入 resolveDynamicComponent,easycom 会使用 resolveDynamicComponent 替换 resolveComponent 来解决 warning 的问题
// resolveComponent('custom-component') => resolveDynamicComponent('custom-component')
// context.helper(RESOLVE_DYNAMIC_COMPONENT)
}
}
packages/vite-plugin-uni/src/vue/transforms/transformMatchMedia.ts
已删除
100644 → 0
浏览文件 @
ab4470e8
import
{
ElementNode
,
NodeTransform
}
from
'
@vue/compiler-core
'
export
const
transformMatchMedia
:
NodeTransform
=
(
node
)
=>
{
if
((
node
as
ElementNode
).
tag
===
'
match-media
'
)
{
;(
node
as
ElementNode
).
tag
=
'
uni-match-media
'
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录