Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
20岁爱吃必胜客
uni-app
提交
e0f172ef
U
uni-app
项目概览
20岁爱吃必胜客
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e0f172ef
编写于
8月 22, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(cli): wxs,filter,import-sjs
上级
624ff73a
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
129 addition
and
44 deletion
+129
-44
packages/uni-cli-shared/lib/platform.js
packages/uni-cli-shared/lib/platform.js
+16
-3
packages/uni-cli-shared/package.json
packages/uni-cli-shared/package.json
+1
-1
packages/uni-template-compiler/lib/index.js
packages/uni-template-compiler/lib/index.js
+10
-7
packages/uni-template-compiler/lib/platforms/mp-alipay.js
packages/uni-template-compiler/lib/platforms/mp-alipay.js
+5
-0
packages/uni-template-compiler/lib/platforms/mp-base.js
packages/uni-template-compiler/lib/platforms/mp-base.js
+18
-5
packages/uni-template-compiler/package.json
packages/uni-template-compiler/package.json
+1
-1
packages/vue-cli-plugin-uni/lib/h5/index.js
packages/vue-cli-plugin-uni/lib/h5/index.js
+15
-4
packages/vue-cli-plugin-uni/lib/mp.js
packages/vue-cli-plugin-uni/lib/mp.js
+13
-0
packages/vue-cli-plugin-uni/package.json
packages/vue-cli-plugin-uni/package.json
+1
-1
packages/vue-cli-plugin-uni/packages/webpack-custom-block-loader/index.js
...-plugin-uni/packages/webpack-custom-block-loader/index.js
+15
-9
packages/vue-cli-plugin-uni/packages/webpack-uni-filter-loader/index.js
...li-plugin-uni/packages/webpack-uni-filter-loader/index.js
+27
-0
packages/webpack-uni-mp-loader/lib/shared.js
packages/webpack-uni-mp-loader/lib/shared.js
+4
-10
packages/webpack-uni-mp-loader/package.json
packages/webpack-uni-mp-loader/package.json
+1
-1
packages/webpack-uni-pages-loader/package.json
packages/webpack-uni-pages-loader/package.json
+2
-2
未找到文件。
packages/uni-cli-shared/lib/platform.js
浏览文件 @
e0f172ef
...
...
@@ -79,7 +79,8 @@ const PLATFORMS = {
exts
:
false
,
vue
:
'
@dcloudio/vue-cli-plugin-uni/packages/h5-vue
'
,
compiler
:
false
,
megalo
:
false
,
megalo
:
false
,
filterTag
:
'
wxs
'
,
subPackages
:
false
,
cssVars
:
{
'
--status-bar-height
'
:
'
0px
'
...
...
@@ -398,8 +399,20 @@ function devtoolModuleFilenameTemplate (info) {
)
{
return
`uni-app:///
${
filePath
}
`
}
}
module
.
exports
=
{
}
const
NODE_MODULES_REGEX
=
/
(\.\.\/)?
node_modules/g
function
normalizeNodeModules
(
str
)
{
str
=
str
.
replace
(
NODE_MODULES_REGEX
,
'
node-modules
'
)
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
)
{
str
=
str
.
replace
(
'
node-modules/@
'
,
'
node-modules/npm-scope-
'
)
}
return
str
}
module
.
exports
=
{
normalizeNodeModules
,
isInHBuilderX
,
isInHBuilderXAlpha
,
runByHBuilderX
:
isInHBuilderX
||
!!
process
.
env
.
UNI_HBUILDERX_PLUGINS
,
...
...
packages/uni-cli-shared/package.json
浏览文件 @
e0f172ef
{
"name"
:
"@dcloudio/uni-cli-shared"
,
"version"
:
"0.2.9
89
"
,
"version"
:
"0.2.9
90
"
,
"description"
:
"uni-cli-shared"
,
"main"
:
"lib/index.js"
,
"files"
:
[
...
...
packages/uni-template-compiler/lib/index.js
浏览文件 @
e0f172ef
...
...
@@ -100,15 +100,18 @@ at ${resourcePath}.vue:1`)
}
const
filterTemplate
=
[]
options
.
mp
.
filterModules
.
forEach
(
name
=>
{
const
filterTag
=
options
.
filterTagName
const
filterModule
=
options
.
filterModules
[
name
]
if
(
filterModule
.
content
)
{
filterTemplate
.
push
(
`<
${
filterTag
}
module="
${
name
}
">
${
filterModule
.
content
}
</
${
filterTag
}
>`
)
}
filterTemplate
.
push
(
options
.
mp
.
platform
.
createFilterTag
(
options
.
filterTagName
,
options
.
filterModules
[
name
]
)
)
})
if
(
filterTemplate
.
length
)
{
template
=
filterTemplate
.
join
(
'
\n
'
)
+
'
\n
'
+
template
}
if
(
process
.
UNI_ENTRY
[
resourcePath
]
&&
process
.
env
.
UNI_PLATFORM
!==
'
app-plus
'
&&
...
...
packages/uni-template-compiler/lib/platforms/mp-alipay.js
浏览文件 @
e0f172ef
...
...
@@ -42,6 +42,11 @@ module.exports = {
'
regionchange
'
:
'
onRegionChange
'
}
},
createFilterTag
(
filterTag
,
{
attrs
})
{
return
`<
${
filterTag
}
name="
${
attrs
.
module
}
" from="
${
attrs
.
src
}
"></
${
filterTag
}
>`
},
getEventType
(
eventType
)
{
return
EVENTS
[
eventType
]
||
eventType
},
...
...
packages/uni-template-compiler/lib/platforms/mp-base.js
浏览文件 @
e0f172ef
...
...
@@ -46,7 +46,7 @@ const tags = [
'
textarea
'
,
'
video
'
,
'
view
'
,
'
web-view
'
,
'
web-view
'
,
'
editor
'
]
...
...
@@ -55,13 +55,26 @@ module.exports = {
refInFor
:
'
data-ref-in-for
'
,
specialEvents
:
{},
/**
* TODO 暂时先简单判断是不是自定义组件,
* 如果要依赖真实导入的组件识别,需要 template-loader 与 script-loader 结合,
* 目前 template 在前,script 在后,要做的话,就需要把 wxml 的生成机制放到 plugin 中才可以拿到真实的组件列表
*/
* TODO 暂时先简单判断是不是自定义组件,
* 如果要依赖真实导入的组件识别,需要 template-loader 与 script-loader 结合,
* 目前 template 在前,script 在后,要做的话,就需要把 wxml 的生成机制放到 plugin 中才可以拿到真实的组件列表
*/
isComponent
(
tagName
)
{
return
!
tags
.
includes
(
tagName
)
},
createFilterTag
(
filterTag
,
{
content
,
attrs
})
{
content
=
content
.
trim
()
if
(
content
)
{
return
`<
${
filterTag
}
module="
${
attrs
.
module
}
">
${
content
}
</
${
filterTag
}
>`
}
else
if
(
attrs
.
src
)
{
return
`<
${
filterTag
}
src="
${
attrs
.
src
}
" module="
${
attrs
.
module
}
"></
${
filterTag
}
>`
}
},
getEventType
(
eventType
)
{
return
EVENTS
[
eventType
]
||
eventType
},
...
...
packages/uni-template-compiler/package.json
浏览文件 @
e0f172ef
{
"name"
:
"@dcloudio/uni-template-compiler"
,
"version"
:
"
1.0.0-alpha-2212019081400
2"
,
"version"
:
"
0.9.18
2"
,
"description"
:
"uni-template-compiler"
,
"main"
:
"lib/index.js"
,
"files"
:
[
...
...
packages/vue-cli-plugin-uni/lib/h5/index.js
浏览文件 @
e0f172ef
...
...
@@ -80,6 +80,11 @@ module.exports = {
before
:
[
`<template><App :keepAliveInclude="keepAliveInclude"/></template>`
]
}
}
},
{
resourceQuery
:
/blockType=wxs/
,
use
:
[{
loader
:
resolve
(
'
packages/webpack-uni-filter-loader
'
)
}]
}]
},
resolveLoader
:
{
...
...
@@ -90,7 +95,7 @@ module.exports = {
plugins
}
},
chainWebpack
(
webpackConfig
)
{
chainWebpack
(
webpackConfig
)
{
webpackConfig
.
plugins
.
delete
(
'
copy
'
)
if
(
!
process
.
env
.
UNI_OPT_PREFETCH
)
{
...
...
@@ -106,16 +111,22 @@ module.exports = {
.
use
(
'
vue-loader
'
)
.
tap
(
options
=>
Object
.
assign
(
options
,
{
compiler
:
getPlatformCompiler
(),
compilerOptions
:
require
(
'
./compiler-options
'
),
cacheDirectory
:
false
,
compilerOptions
:
require
(
'
./compiler-options
'
),
cacheDirectory
:
false
,
cacheIdentifier
:
false
}))
.
end
()
.
use
(
'
uniapp-custom-block-loader
'
)
.
loader
(
require
.
resolve
(
'
@dcloudio/vue-cli-plugin-uni/packages/webpack-custom-block-loader
'
))
.
options
({
compiler
:
getPlatformCompiler
()
})
.
end
()
.
use
(
'
uniapp-scoped
'
)
.
loader
(
resolve
(
'
packages/webpack-scoped-loader
'
))
.
end
()
.
uses
.
delete
(
'
cache-loader
'
)
.
delete
(
'
cache-loader
'
)
if
(
process
.
env
.
NODE_ENV
===
'
production
'
)
{
const
module
=
webpackConfig
.
module
...
...
packages/vue-cli-plugin-uni/lib/mp.js
浏览文件 @
e0f172ef
...
...
@@ -119,6 +119,12 @@ module.exports = {
use
:
[{
loader
:
'
@dcloudio/webpack-uni-mp-loader/lib/template
'
}]
},
{
resourceQuery
:
[
/blockType=wxs/
,
/blockType=filter/
,
/blockType=import-sjs/
],
use
:
[{
loader
:
require
.
resolve
(
'
@dcloudio/vue-cli-plugin-uni/packages/webpack-uni-filter-loader
'
)
}]
}]
},
plugins
:
[
...
...
@@ -128,6 +134,13 @@ module.exports = {
}
},
chainWebpack
(
webpackConfig
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-baidu
'
)
{
webpackConfig
.
module
.
rule
(
'
js
'
)
.
exclude
.
add
(
/
\.
filter
\.
js$/
)
}
// disable vue cache-loader
webpackConfig
.
module
.
rule
(
'
vue
'
)
...
...
packages/vue-cli-plugin-uni/package.json
浏览文件 @
e0f172ef
{
"name"
:
"@dcloudio/vue-cli-plugin-uni"
,
"version"
:
"0.9.52
5
"
,
"version"
:
"0.9.52
7
"
,
"description"
:
"uni-app plugin for vue-cli 3"
,
"main"
:
"index.js"
,
"scripts"
:
{
...
...
packages/vue-cli-plugin-uni/packages/webpack-custom-block-loader/index.js
浏览文件 @
e0f172ef
...
...
@@ -8,15 +8,13 @@ const {
}))
// 确保使用的与 vue-loader 一致
const
{
getPlatformFilterTag
getPlatformFilterTag
,
normalizeNodeModules
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
const
FILTER_TAG
=
getPlatformFilterTag
()
module
.
exports
=
function
(
source
)
{
if
(
!
FILTER_TAG
)
{
return
source
}
const
loaderContext
=
this
...
...
@@ -40,23 +38,31 @@ module.exports = function(source) {
needMap
:
sourceMap
})
if
(
!
descriptor
.
template
)
{
if
(
!
descriptor
.
template
||
!
FILTER_TAG
)
{
// delete customBlocks
descriptor
.
customBlocks
.
length
=
0
return
source
}
const
modules
=
Object
.
create
(
null
)
descriptor
.
customBlocks
.
filter
(
block
=>
{
descriptor
.
customBlocks
=
descriptor
.
customBlocks
.
filter
(
block
=>
{
if
(
block
.
type
===
FILTER_TAG
&&
block
.
attrs
.
module
)
{
modules
[
block
.
attrs
.
module
]
=
block
return
true
}
})
if
(
Object
.
keys
(
modules
))
{
descriptor
.
template
.
attrs
[
'
filter-modules
'
]
=
JSON
.
stringify
(
modules
)
const
filterModules
=
JSON
.
parse
(
JSON
.
stringify
(
modules
))
Object
.
keys
(
filterModules
).
forEach
(
name
=>
{
const
filterModule
=
filterModules
[
name
]
if
(
filterModule
.
attrs
.
src
)
{
filterModule
.
attrs
.
src
=
normalizeNodeModules
(
filterModule
.
attrs
.
src
)
}
})
descriptor
.
template
.
attrs
[
'
filter-modules
'
]
=
JSON
.
stringify
(
filterModules
)
}
// delete customBlocks
descriptor
.
customBlocks
.
length
=
0
return
source
}
packages/vue-cli-plugin-uni/packages/webpack-uni-filter-loader/index.js
0 → 100644
浏览文件 @
e0f172ef
const
path
=
require
(
'
path
'
)
const
loaderUtils
=
require
(
'
loader-utils
'
)
const
{
normalizeNodeModules
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
module
.
exports
=
function
(
source
,
map
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
)
{
// h5
this
.
callback
(
null
,
`export default function (Component) {
(Component.options.wxs||(Component.options.wxs={}))['
${
params
.
module
}
'] = (function(module){
${
source
.
trim
()}
return module.exports
})({exports:{}});
}`
,
map
)
}
else
{
// mp
if
(
params
.
issuerPath
)
{
const
resourcePath
=
normalizeNodeModules
(
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
this
.
resourcePath
))
this
.
emitFile
(
resourcePath
,
source
)
}
this
.
callback
(
null
,
`export default {}`
,
map
)
}
}
packages/webpack-uni-mp-loader/lib/shared.js
浏览文件 @
e0f172ef
...
...
@@ -3,8 +3,10 @@ const {
getPlatformExts
,
getPlatformTarget
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
NODE_MODULES_REGEX
=
/
(\.\.\/)?
node_modules/g
const
{
normalizeNodeModules
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
const
templates
=
{}
const
compilerOptions
=
{}
...
...
@@ -29,14 +31,6 @@ function resolve (source) {
})
}
function
normalizeNodeModules
(
str
)
{
str
=
str
.
replace
(
NODE_MODULES_REGEX
,
'
node-modules
'
)
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
)
{
str
=
str
.
replace
(
'
node-modules/@
'
,
'
node-modules/npm-scope-
'
)
}
return
str
}
function
restoreNodeModules
(
str
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
)
{
str
=
str
.
replace
(
'
node-modules/npm-scope-
'
,
'
node-modules/@
'
)
...
...
packages/webpack-uni-mp-loader/package.json
浏览文件 @
e0f172ef
{
"name"
:
"@dcloudio/webpack-uni-mp-loader"
,
"version"
:
"
1.0.0-alpha-22120190814002
"
,
"version"
:
"
0.3.644
"
,
"description"
:
"webpack-uni-mp-loader"
,
"main"
:
"index.js"
,
"files"
:
[
...
...
packages/webpack-uni-pages-loader/package.json
浏览文件 @
e0f172ef
{
"name"
:
"@dcloudio/webpack-uni-pages-loader"
,
"version"
:
"0.2.87
3
"
,
"version"
:
"0.2.87
4
"
,
"description"
:
"uni-app pages.json loader"
,
"main"
:
"lib/index.js"
,
"files"
:
[
...
...
@@ -16,7 +16,7 @@
"strip-json-comments"
:
"^2.0.1"
},
"uni-app"
:
{
"compilerVersion"
:
"2.2.
1
"
"compilerVersion"
:
"2.2.
3
"
},
"gitHead"
:
"08ea04b669e93f0db3acb2dfa38138298edd5789"
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录