Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
e0f172ef
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,发现更多精彩内容 >>
提交
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
...
@@ -80,6 +80,7 @@ const PLATFORMS = {
...
@@ -80,6 +80,7 @@ const PLATFORMS = {
vue
:
'
@dcloudio/vue-cli-plugin-uni/packages/h5-vue
'
,
vue
:
'
@dcloudio/vue-cli-plugin-uni/packages/h5-vue
'
,
compiler
:
false
,
compiler
:
false
,
megalo
:
false
,
megalo
:
false
,
filterTag
:
'
wxs
'
,
subPackages
:
false
,
subPackages
:
false
,
cssVars
:
{
cssVars
:
{
'
--status-bar-height
'
:
'
0px
'
'
--status-bar-height
'
:
'
0px
'
...
@@ -399,7 +400,19 @@ function devtoolModuleFilenameTemplate (info) {
...
@@ -399,7 +400,19 @@ function devtoolModuleFilenameTemplate (info) {
return
`uni-app:///
${
filePath
}
`
return
`uni-app:///
${
filePath
}
`
}
}
}
}
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
=
{
module
.
exports
=
{
normalizeNodeModules
,
isInHBuilderX
,
isInHBuilderX
,
isInHBuilderXAlpha
,
isInHBuilderXAlpha
,
runByHBuilderX
:
isInHBuilderX
||
!!
process
.
env
.
UNI_HBUILDERX_PLUGINS
,
runByHBuilderX
:
isInHBuilderX
||
!!
process
.
env
.
UNI_HBUILDERX_PLUGINS
,
...
...
packages/uni-cli-shared/package.json
浏览文件 @
e0f172ef
{
{
"name"
:
"@dcloudio/uni-cli-shared"
,
"name"
:
"@dcloudio/uni-cli-shared"
,
"version"
:
"0.2.9
89
"
,
"version"
:
"0.2.9
90
"
,
"description"
:
"uni-cli-shared"
,
"description"
:
"uni-cli-shared"
,
"main"
:
"lib/index.js"
,
"main"
:
"lib/index.js"
,
"files"
:
[
"files"
:
[
...
...
packages/uni-template-compiler/lib/index.js
浏览文件 @
e0f172ef
...
@@ -100,15 +100,18 @@ at ${resourcePath}.vue:1`)
...
@@ -100,15 +100,18 @@ at ${resourcePath}.vue:1`)
}
}
const
filterTemplate
=
[]
const
filterTemplate
=
[]
options
.
mp
.
filterModules
.
forEach
(
name
=>
{
options
.
mp
.
filterModules
.
forEach
(
name
=>
{
const
filterTag
=
options
.
filterTagName
filterTemplate
.
push
(
const
filterModule
=
options
.
filterModules
[
name
]
options
.
mp
.
platform
.
createFilterTag
(
if
(
filterModule
.
content
)
{
options
.
filterTagName
,
filterTemplate
.
push
(
`<
${
filterTag
}
module="
${
name
}
">
options
.
filterModules
[
name
]
${
filterModule
.
content
}
)
</
${
filterTag
}
>`
)
)
}
})
})
if
(
filterTemplate
.
length
)
{
template
=
filterTemplate
.
join
(
'
\n
'
)
+
'
\n
'
+
template
}
if
(
if
(
process
.
UNI_ENTRY
[
resourcePath
]
&&
process
.
UNI_ENTRY
[
resourcePath
]
&&
process
.
env
.
UNI_PLATFORM
!==
'
app-plus
'
&&
process
.
env
.
UNI_PLATFORM
!==
'
app-plus
'
&&
...
...
packages/uni-template-compiler/lib/platforms/mp-alipay.js
浏览文件 @
e0f172ef
...
@@ -42,6 +42,11 @@ module.exports = {
...
@@ -42,6 +42,11 @@ module.exports = {
'
regionchange
'
:
'
onRegionChange
'
'
regionchange
'
:
'
onRegionChange
'
}
}
},
},
createFilterTag
(
filterTag
,
{
attrs
})
{
return
`<
${
filterTag
}
name="
${
attrs
.
module
}
" from="
${
attrs
.
src
}
"></
${
filterTag
}
>`
},
getEventType
(
eventType
)
{
getEventType
(
eventType
)
{
return
EVENTS
[
eventType
]
||
eventType
return
EVENTS
[
eventType
]
||
eventType
},
},
...
...
packages/uni-template-compiler/lib/platforms/mp-base.js
浏览文件 @
e0f172ef
...
@@ -62,6 +62,19 @@ module.exports = {
...
@@ -62,6 +62,19 @@ module.exports = {
isComponent
(
tagName
)
{
isComponent
(
tagName
)
{
return
!
tags
.
includes
(
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
)
{
getEventType
(
eventType
)
{
return
EVENTS
[
eventType
]
||
eventType
return
EVENTS
[
eventType
]
||
eventType
},
},
...
...
packages/uni-template-compiler/package.json
浏览文件 @
e0f172ef
{
{
"name"
:
"@dcloudio/uni-template-compiler"
,
"name"
:
"@dcloudio/uni-template-compiler"
,
"version"
:
"
1.0.0-alpha-2212019081400
2"
,
"version"
:
"
0.9.18
2"
,
"description"
:
"uni-template-compiler"
,
"description"
:
"uni-template-compiler"
,
"main"
:
"lib/index.js"
,
"main"
:
"lib/index.js"
,
"files"
:
[
"files"
:
[
...
...
packages/vue-cli-plugin-uni/lib/h5/index.js
浏览文件 @
e0f172ef
...
@@ -80,6 +80,11 @@ module.exports = {
...
@@ -80,6 +80,11 @@ module.exports = {
before
:
[
`<template><App :keepAliveInclude="keepAliveInclude"/></template>`
]
before
:
[
`<template><App :keepAliveInclude="keepAliveInclude"/></template>`
]
}
}
}
}
},
{
resourceQuery
:
/blockType=wxs/
,
use
:
[{
loader
:
resolve
(
'
packages/webpack-uni-filter-loader
'
)
}]
}]
}]
},
},
resolveLoader
:
{
resolveLoader
:
{
...
@@ -111,6 +116,12 @@ module.exports = {
...
@@ -111,6 +116,12 @@ module.exports = {
cacheIdentifier
:
false
cacheIdentifier
:
false
}))
}))
.
end
()
.
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
'
)
.
use
(
'
uniapp-scoped
'
)
.
loader
(
resolve
(
'
packages/webpack-scoped-loader
'
))
.
loader
(
resolve
(
'
packages/webpack-scoped-loader
'
))
.
end
()
.
end
()
...
...
packages/vue-cli-plugin-uni/lib/mp.js
浏览文件 @
e0f172ef
...
@@ -119,6 +119,12 @@ module.exports = {
...
@@ -119,6 +119,12 @@ module.exports = {
use
:
[{
use
:
[{
loader
:
'
@dcloudio/webpack-uni-mp-loader/lib/template
'
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
:
[
plugins
:
[
...
@@ -128,6 +134,13 @@ module.exports = {
...
@@ -128,6 +134,13 @@ module.exports = {
}
}
},
},
chainWebpack
(
webpackConfig
)
{
chainWebpack
(
webpackConfig
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-baidu
'
)
{
webpackConfig
.
module
.
rule
(
'
js
'
)
.
exclude
.
add
(
/
\.
filter
\.
js$/
)
}
// disable vue cache-loader
// disable vue cache-loader
webpackConfig
.
module
webpackConfig
.
module
.
rule
(
'
vue
'
)
.
rule
(
'
vue
'
)
...
...
packages/vue-cli-plugin-uni/package.json
浏览文件 @
e0f172ef
{
{
"name"
:
"@dcloudio/vue-cli-plugin-uni"
,
"name"
:
"@dcloudio/vue-cli-plugin-uni"
,
"version"
:
"0.9.52
5
"
,
"version"
:
"0.9.52
7
"
,
"description"
:
"uni-app plugin for vue-cli 3"
,
"description"
:
"uni-app plugin for vue-cli 3"
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
packages/vue-cli-plugin-uni/packages/webpack-custom-block-loader/index.js
浏览文件 @
e0f172ef
...
@@ -8,15 +8,13 @@ const {
...
@@ -8,15 +8,13 @@ const {
}))
// 确保使用的与 vue-loader 一致
}))
// 确保使用的与 vue-loader 一致
const
{
const
{
getPlatformFilterTag
getPlatformFilterTag
,
normalizeNodeModules
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
const
FILTER_TAG
=
getPlatformFilterTag
()
const
FILTER_TAG
=
getPlatformFilterTag
()
module
.
exports
=
function
(
source
)
{
module
.
exports
=
function
(
source
)
{
if
(
!
FILTER_TAG
)
{
return
source
}
const
loaderContext
=
this
const
loaderContext
=
this
...
@@ -40,23 +38,31 @@ module.exports = function(source) {
...
@@ -40,23 +38,31 @@ module.exports = function(source) {
needMap
:
sourceMap
needMap
:
sourceMap
})
})
if
(
!
descriptor
.
template
)
{
if
(
!
descriptor
.
template
||
!
FILTER_TAG
)
{
// delete customBlocks
descriptor
.
customBlocks
.
length
=
0
return
source
return
source
}
}
const
modules
=
Object
.
create
(
null
)
const
modules
=
Object
.
create
(
null
)
descriptor
.
customBlocks
.
filter
(
block
=>
{
descriptor
.
customBlocks
=
descriptor
.
customBlocks
.
filter
(
block
=>
{
if
(
block
.
type
===
FILTER_TAG
&&
block
.
attrs
.
module
)
{
if
(
block
.
type
===
FILTER_TAG
&&
block
.
attrs
.
module
)
{
modules
[
block
.
attrs
.
module
]
=
block
modules
[
block
.
attrs
.
module
]
=
block
return
true
}
}
})
})
if
(
Object
.
keys
(
modules
))
{
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
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
...
@@ -4,7 +4,9 @@ const {
...
@@ -4,7 +4,9 @@ const {
getPlatformTarget
getPlatformTarget
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
NODE_MODULES_REGEX
=
/
(\.\.\/)?
node_modules/g
const
{
normalizeNodeModules
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
const
templates
=
{}
const
templates
=
{}
const
compilerOptions
=
{}
const
compilerOptions
=
{}
...
@@ -29,14 +31,6 @@ function resolve (source) {
...
@@ -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
)
{
function
restoreNodeModules
(
str
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
)
{
if
(
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
)
{
str
=
str
.
replace
(
'
node-modules/npm-scope-
'
,
'
node-modules/@
'
)
str
=
str
.
replace
(
'
node-modules/npm-scope-
'
,
'
node-modules/@
'
)
...
...
packages/webpack-uni-mp-loader/package.json
浏览文件 @
e0f172ef
{
{
"name"
:
"@dcloudio/webpack-uni-mp-loader"
,
"name"
:
"@dcloudio/webpack-uni-mp-loader"
,
"version"
:
"
1.0.0-alpha-22120190814002
"
,
"version"
:
"
0.3.644
"
,
"description"
:
"webpack-uni-mp-loader"
,
"description"
:
"webpack-uni-mp-loader"
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"files"
:
[
"files"
:
[
...
...
packages/webpack-uni-pages-loader/package.json
浏览文件 @
e0f172ef
{
{
"name"
:
"@dcloudio/webpack-uni-pages-loader"
,
"name"
:
"@dcloudio/webpack-uni-pages-loader"
,
"version"
:
"0.2.87
3
"
,
"version"
:
"0.2.87
4
"
,
"description"
:
"uni-app pages.json loader"
,
"description"
:
"uni-app pages.json loader"
,
"main"
:
"lib/index.js"
,
"main"
:
"lib/index.js"
,
"files"
:
[
"files"
:
[
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
"strip-json-comments"
:
"^2.0.1"
"strip-json-comments"
:
"^2.0.1"
},
},
"uni-app"
:
{
"uni-app"
:
{
"compilerVersion"
:
"2.2.
1
"
"compilerVersion"
:
"2.2.
3
"
},
},
"gitHead"
:
"08ea04b669e93f0db3acb2dfa38138298edd5789"
"gitHead"
:
"08ea04b669e93f0db3acb2dfa38138298edd5789"
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录