Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
8bf24016
U
uni-app
项目概览
anyefeiyu
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
8bf24016
编写于
5月 19, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(cli): source-map
上级
82f0936c
变更
56
展开全部
隐藏空白更改
内联
并排
Showing
56 changed file
with
480 addition
and
505 deletion
+480
-505
.eslintignore
.eslintignore
+22
-1
lib/h5/uni.config.js
lib/h5/uni.config.js
+0
-5
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+28
-9
packages/uni-app-plus/lib/uni.config.js
packages/uni-app-plus/lib/uni.config.js
+0
-15
packages/uni-cli-shared/lib/source-map.js
packages/uni-cli-shared/lib/source-map.js
+60
-0
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-mp-alipay/lib/uni.config.js
packages/uni-mp-alipay/lib/uni.config.js
+0
-5
packages/uni-mp-baidu/lib/uni.config.js
packages/uni-mp-baidu/lib/uni.config.js
+0
-5
packages/uni-mp-qq/lib/uni.config.js
packages/uni-mp-qq/lib/uni.config.js
+0
-5
packages/uni-mp-toutiao/lib/uni.config.js
packages/uni-mp-toutiao/lib/uni.config.js
+0
-5
packages/uni-mp-weixin/lib/uni.config.js
packages/uni-mp-weixin/lib/uni.config.js
+0
-5
packages/uni-quickapp-webview/lib/uni.config.js
packages/uni-quickapp-webview/lib/uni.config.js
+0
-5
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
+7
-8
packages/vue-cli-plugin-hbuilderx/index.js
packages/vue-cli-plugin-hbuilderx/index.js
+0
-7
packages/vue-cli-plugin-hbuilderx/packages/babel-plugin-console/dist/index.js
...gin-hbuilderx/packages/babel-plugin-console/dist/index.js
+4
-6
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-nvue-plugin/index.js
...-hbuilderx/packages/webpack-app-plus-nvue-plugin/index.js
+4
-5
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
...lugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
+12
-16
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/main.js
...in-hbuilderx/packages/webpack-uni-nvue-loader/lib/main.js
+5
-6
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/style.js
...n-hbuilderx/packages/webpack-uni-nvue-loader/lib/style.js
+50
-50
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/template.js
...builderx/packages/webpack-uni-nvue-loader/lib/template.js
+11
-9
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/template.recycle.js
.../packages/webpack-uni-nvue-loader/lib/template.recycle.js
+2
-2
packages/vue-cli-plugin-hbuilderx/util.js
packages/vue-cli-plugin-hbuilderx/util.js
+0
-64
packages/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js
...lugin-uni-optimize/packages/babel-plugin-uni-api/index.js
+2
-2
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js
...ugin-uni-optimize/packages/webpack-optimize-plugin/api.js
+21
-24
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js
...ni-optimize/packages/webpack-optimize-plugin/component.js
+2
-3
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/index.js
...in-uni-optimize/packages/webpack-optimize-plugin/index.js
+4
-7
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/util.js
...gin-uni-optimize/packages/webpack-optimize-plugin/util.js
+4
-4
packages/vue-cli-plugin-uni-optimize/packages/webpack-style-loader/index.js
...lugin-uni-optimize/packages/webpack-style-loader/index.js
+7
-7
packages/vue-cli-plugin-uni/lib/configure-webpack.js
packages/vue-cli-plugin-uni/lib/configure-webpack.js
+19
-0
packages/vue-cli-plugin-uni/lib/error-reporting.js
packages/vue-cli-plugin-uni/lib/error-reporting.js
+1
-1
packages/vue-cli-plugin-uni/lib/mp/index.js
packages/vue-cli-plugin-uni/lib/mp/index.js
+2
-2
packages/vue-cli-plugin-uni/packages/postcss/index.js
packages/vue-cli-plugin-uni/packages/postcss/index.js
+1
-1
packages/vue-cli-plugin-uni/packages/postcss/tags.js
packages/vue-cli-plugin-uni/packages/postcss/tags.js
+96
-96
packages/vue-cli-plugin-uni/packages/webpack-custom-block-loader/index.bak.js
...gin-uni/packages/webpack-custom-block-loader/index.bak.js
+1
-1
packages/vue-cli-plugin-uni/packages/webpack-html-append-plugin/index.js
...i-plugin-uni/packages/webpack-html-append-plugin/index.js
+4
-3
packages/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js
...li-plugin-uni/packages/webpack-preprocess-loader/index.js
+6
-6
packages/vue-cli-plugin-uni/packages/webpack-scoped-loader/index.js
...ue-cli-plugin-uni/packages/webpack-scoped-loader/index.js
+3
-3
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/filter-modules-template.js
...ackages/webpack-uni-app-loader/filter-modules-template.js
+3
-3
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/page-meta.js
...i-plugin-uni/packages/webpack-uni-app-loader/page-meta.js
+3
-3
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/plugin/index.js
...lugin-uni/packages/webpack-uni-app-loader/plugin/index.js
+4
-10
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/service/style.js
...ugin-uni/packages/webpack-uni-app-loader/service/style.js
+3
-2
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/using-components.js
...n-uni/packages/webpack-uni-app-loader/using-components.js
+3
-3
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
...i-plugin-uni/packages/webpack-uni-app-loader/view/main.js
+15
-15
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/renderjs.js
...ugin-uni/packages/webpack-uni-app-loader/view/renderjs.js
+3
-8
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/script.js
...plugin-uni/packages/webpack-uni-app-loader/view/script.js
+7
-7
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/style.js
...-plugin-uni/packages/webpack-uni-app-loader/view/style.js
+5
-6
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js
...i-plugin-uni/packages/webpack-uni-app-loader/view/util.js
+1
-1
packages/vue-cli-plugin-uni/packages/webpack-uni-filter-loader/index.js
...li-plugin-uni/packages/webpack-uni-filter-loader/index.js
+4
-4
packages/vue-cli-plugin-uni/packages/wrap-loader/index.js
packages/vue-cli-plugin-uni/packages/wrap-loader/index.js
+7
-9
packages/webpack-uni-mp-loader/lib/main-new.js
packages/webpack-uni-mp-loader/lib/main-new.js
+7
-6
packages/webpack-uni-mp-loader/lib/main.js
packages/webpack-uni-mp-loader/lib/main.js
+2
-2
packages/webpack-uni-mp-loader/lib/script.js
packages/webpack-uni-mp-loader/lib/script.js
+1
-1
packages/webpack-uni-mp-loader/lib/style.js
packages/webpack-uni-mp-loader/lib/style.js
+20
-18
packages/webpack-uni-mp-loader/lib/template.js
packages/webpack-uni-mp-loader/lib/template.js
+4
-4
packages/webpack-uni-pages-loader/lib/index-new.js
packages/webpack-uni-pages-loader/lib/index-new.js
+6
-6
packages/webpack-uni-pages-loader/lib/index.js
packages/webpack-uni-pages-loader/lib/index.js
+3
-3
未找到文件。
.eslintignore
浏览文件 @
8bf24016
src/core/helpers/html-parser.js
src/platforms/app-plus-nvue/runtime
build/rollup-plugin-require-context
packages/*/packages
packages/*/packages/uni-app-plus
packages/*/packages/uni-app-plus-nvue
packages/*/packages/uni-app-plus-nvue-v8
packages/*/packages/weex-styler
packages/*/packages/weex-template-compiler
packages/*/packages/@intervolga
packages/*/packages/@megalo
packages/*/packages/@vue
packages/*/packages/app-vue-style-loader
packages/*/packages/h5-vue
packages/*/packages/h5-vue-router
packages/*/packages/h5-vue-style-loader
packages/*/packages/megalo
packages/*/packages/mp-vue
packages/*/packages/mpvue
packages/*/packages/mpvue-page-factory
packages/*/packages/mpvue-template-compiler
packages/*/packages/postcss-normalize-whitespace
packages/*/packages/uni-cloud
packages/*/packages/vue-loader
packages/*/packages/vue-template-compiler
packages/*/packages/webpack-preprocess-loader/preprocess
packages/*/template/**/*
packages/uni-h5/src
packages/uni-stat
...
...
lib/h5/uni.config.js
浏览文件 @
8bf24016
...
...
@@ -47,10 +47,5 @@ module.exports = {
},
'
hybrid/html
'
]
},
configureWebpack
()
{
return
{
devtool
:
process
.
env
.
NODE_ENV
===
'
production
'
?
false
:
'
cheap-module-eval-source-map
'
}
}
}
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
8bf24016
...
...
@@ -5187,8 +5187,7 @@ var serviceContext = (function () {
// tabBar是否遮挡内容区域
get
cover
()
{
const
array
=
[
'
extralight
'
,
'
light
'
,
'
dark
'
];
// 设置背景颜色会失效
return
isIOS$1
&&
array
.
indexOf
(
config
.
blurEffect
)
>=
0
&&
!
config
.
backgroundColor
return
isIOS$1
&&
array
.
indexOf
(
config
.
blurEffect
)
>=
0
},
setStyle
({
mask
})
{
tabBar
.
setMask
({
...
...
@@ -8246,7 +8245,7 @@ var serviceContext = (function () {
}
}
function
showWebview
(
webview
,
animationType
,
animationDuration
,
showCallback
,
delay
)
{
function
showWebview
(
webview
,
animationType
,
animationDuration
,
showCallback
,
delay
)
{
if
(
typeof
delay
===
'
undefined
'
)
{
delay
=
webview
.
nvue
?
0
:
100
;
}
...
...
@@ -8260,16 +8259,36 @@ var serviceContext = (function () {
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[show][
${
Date
.
now
()}
]`
,
delay
);
}
const
duration
=
animationDuration
||
ANI_DURATION
;
setTimeout
(()
=>
{
const
execShowCallback
=
function
()
{
if
(
execShowCallback
.
_called
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
execShowCallback.prevent
'
);
}
return
}
execShowCallback
.
_called
=
true
;
showCallback
&&
showCallback
();
navigateFinish
();
};
const
timer
=
setTimeout
(()
=>
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[show.callback.timer][
${
Date
.
now
()}
]`
);
}
execShowCallback
();
},
duration
+
150
);
webview
.
show
(
animationType
||
ANI_SHOW
,
animationDuration
||
ANI_DURATION
,
duration
,
()
=>
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[show.callback][
${
Date
.
now
()}
]`
);
}
showCallback
&&
showCallback
();
navigateFinish
();
if
(
!
execShowCallback
.
_called
)
{
clearTimeout
(
timer
);
}
execShowCallback
();
}
);
},
delay
);
...
...
@@ -8294,11 +8313,11 @@ var serviceContext = (function () {
mpType
:
'
page
'
,
pageId
,
pagePath
,
pageQuery
,
pageQuery
,
pageInstance
});
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`new
${
pagePath
}
`
,
Date
.
now
()
-
startTime
);
console
.
log
(
`new
${
pagePath
}
[
${
pageId
}
]:time(
${
Date
.
now
()
-
startTime
}
)`
);
}
return
pageVm
}
...
...
@@ -8383,7 +8402,7 @@ var serviceContext = (function () {
}
pages
.
splice
(
index
,
1
);
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
[uni-app] removePage
'
,
path
,
webview
.
id
);
console
.
log
(
'
[uni-app] removePage
(
'
+
path
+
'
)[
'
+
webview
.
id
+
'
]
'
);
}
}
},
...
...
packages/uni-app-plus/lib/uni.config.js
浏览文件 @
8bf24016
...
...
@@ -40,20 +40,5 @@ module.exports = {
copyOptions
.
push
(
path
.
resolve
(
__dirname
,
'
../template/v3
'
))
}
return
copyOptions
},
configureWebpack
(
webpackConfig
,
vueOptions
)
{
let
devtool
=
false
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
UNI_USING_V3
)
{
if
(
vueOptions
.
pluginOptions
[
'
uni-app-plus
'
].
service
)
{
devtool
=
'
eval-source-map
'
}
}
else
{
devtool
=
'
eval-source-map
'
}
}
return
{
devtool
}
}
}
packages/uni-cli-shared/lib/source-map.js
0 → 100644
浏览文件 @
8bf24016
const
path
=
require
(
'
path
'
)
const
webpack
=
require
(
'
webpack
'
)
const
{
normalizePath
,
isInHBuilderX
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/util
'
)
const
isWin
=
/^win/
.
test
(
process
.
platform
)
function
genTranspileDepRegex
(
depPath
)
{
return
new
RegExp
(
isWin
?
depPath
.
replace
(
/
\\
/g
,
'
\\\\
'
)
// double escape for windows style path
:
depPath
)
}
let
sourceRoot
=
false
function
getSourceRoot
()
{
if
(
!
sourceRoot
)
{
if
(
isInHBuilderX
)
{
sourceRoot
=
normalizePath
(
process
.
env
.
UNI_INPUT_DIR
)
}
else
{
sourceRoot
=
normalizePath
(
process
.
env
.
UNI_CLI_CONTEXT
)
}
}
return
sourceRoot
}
function
moduleFilenameTemplate
(
info
)
{
if
(
!
info
.
allLoaders
&&
info
.
resourcePath
)
{
const
filepath
=
normalizePath
(
path
.
relative
(
getSourceRoot
(),
info
.
absoluteResourcePath
))
if
(
filepath
.
indexOf
(
'
../
'
)
===
0
)
{
return
}
return
`uni-app:///
${
filepath
}
`
}
}
const
exclude
=
[
/pages
\.
json/
,
/node_modules/
,
/vue&type=template/
,
/vue&type=style/
]
module
.
exports
=
{
createSourceMapDevToolPlugin
(
filename
=
false
)
{
const
options
=
{
test
:
[
/
\.
js$/
],
exclude
,
moduleFilenameTemplate
}
if
(
filename
)
{
options
.
filename
=
'
../.sourcemap/
'
+
process
.
env
.
UNI_PLATFORM
+
'
/[name].js.map
'
}
return
new
webpack
.
SourceMapDevToolPlugin
(
options
)
},
createEvalSourceMapDevToolPlugin
()
{
return
new
webpack
.
EvalSourceMapDevToolPlugin
({
test
:
genTranspileDepRegex
(
process
.
env
.
UNI_INPUT_DIR
),
exclude
,
moduleFilenameTemplate
})
}
}
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
8bf24016
此差异已折叠。
点击以展开。
packages/uni-mp-alipay/lib/uni.config.js
浏览文件 @
8bf24016
...
...
@@ -16,10 +16,5 @@ module.exports = {
},
copyWebpackOptions
(
platformOptions
,
vueOptions
)
{
return
[
'
mycomponents
'
]
},
configureWebpack
()
{
return
{
devtool
:
process
.
env
.
NODE_ENV
===
'
production
'
?
false
:
'
source-map
'
}
}
}
packages/uni-mp-baidu/lib/uni.config.js
浏览文件 @
8bf24016
...
...
@@ -16,10 +16,5 @@ module.exports = {
},
copyWebpackOptions
(
platformOptions
,
vueOptions
)
{
return
[
'
swancomponents
'
]
},
configureWebpack
()
{
return
{
devtool
:
process
.
env
.
NODE_ENV
===
'
production
'
?
false
:
'
inline-source-map
'
}
}
}
packages/uni-mp-qq/lib/uni.config.js
浏览文件 @
8bf24016
...
...
@@ -37,10 +37,5 @@ module.exports = {
})
}
return
copyOptions
},
configureWebpack
()
{
return
{
devtool
:
process
.
env
.
NODE_ENV
===
'
production
'
?
false
:
'
source-map
'
}
}
}
packages/uni-mp-toutiao/lib/uni.config.js
浏览文件 @
8bf24016
...
...
@@ -13,10 +13,5 @@ module.exports = {
},
copyWebpackOptions
(
platformOptions
,
vueOptions
)
{
return
[
'
ttcomponents
'
]
},
configureWebpack
()
{
return
{
devtool
:
process
.
env
.
NODE_ENV
===
'
production
'
?
false
:
'
inline-source-map
'
}
}
}
packages/uni-mp-weixin/lib/uni.config.js
浏览文件 @
8bf24016
...
...
@@ -37,10 +37,5 @@ module.exports = {
})
}
return
copyOptions
},
configureWebpack
()
{
return
{
devtool
:
process
.
env
.
NODE_ENV
===
'
production
'
?
false
:
'
source-map
'
}
}
}
packages/uni-quickapp-webview/lib/uni.config.js
浏览文件 @
8bf24016
...
...
@@ -51,10 +51,5 @@ module.exports = {
}
return
copyOptions
},
configureWebpack
()
{
return
{
devtool
:
process
.
env
.
NODE_ENV
===
'
production
'
?
false
:
'
inline-source-map
'
}
}
}
packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
浏览文件 @
8bf24016
...
...
@@ -11,10 +11,6 @@ const {
getTemplatePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
devtoolModuleFilenameTemplate
}
=
require
(
'
../util
'
)
const
WebpackAppPlusNVuePlugin
=
process
.
env
.
UNI_USING_V3
?
require
(
'
../packages/webpack-app-plus-plugin
'
)
:
require
(
'
../packages/webpack-app-plus-nvue-plugin
'
)
...
...
@@ -100,6 +96,10 @@ const plugins = [
new
WebpackAppPlusNVuePlugin
()
]
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
plugins
.
push
(
require
(
'
@dcloudio/uni-cli-shared/lib/source-map
'
).
createEvalSourceMapDevToolPlugin
())
}
// const excludeModuleReg = /node_modules(?!(\/|\\).*(weex).*)/
const
rules
=
[{
...
...
@@ -226,7 +226,7 @@ module.exports = function () {
return
{
target
:
'
node
'
,
// 激活 vue-loader 的 isServer 逻辑
mode
:
process
.
env
.
NODE_ENV
,
devtool
:
process
.
env
.
NODE_ENV
===
'
development
'
?
'
inline-source-map
'
:
false
,
devtool
:
false
,
watch
:
process
.
env
.
NODE_ENV
===
'
development
'
,
entry
()
{
return
process
.
UNI_NVUE_ENTRY
...
...
@@ -242,8 +242,7 @@ module.exports = function () {
},
output
:
{
path
:
process
.
env
.
UNI_OUTPUT_DIR
,
filename
:
'
[name].js
'
,
devtoolModuleFilenameTemplate
filename
:
'
[name].js
'
},
resolve
:
{
extensions
:
[
'
.js
'
,
'
.nvue
'
,
'
.vue
'
,
'
.json
'
],
...
...
@@ -323,4 +322,4 @@ module.exports = function () {
zlib
:
false
}
}
}
}
packages/vue-cli-plugin-hbuilderx/index.js
浏览文件 @
8bf24016
...
...
@@ -30,13 +30,6 @@ module.exports = (api, options) => { // 仅处理 app-plus 相关逻辑
plugins
.
push
(
new
WebpackAppPlusPlugin
())
const
{
devtoolModuleFilenameTemplate
}
=
require
(
'
./util
'
)
// sourcemap 输出相对路径
output
.
devtoolModuleFilenameTemplate
=
devtoolModuleFilenameTemplate
api
.
configureWebpack
(
webpackConfig
=>
{
return
{
output
,
...
...
packages/vue-cli-plugin-hbuilderx/packages/babel-plugin-console/dist/index.js
浏览文件 @
8bf24016
const
isWin
=
/^win/
.
test
(
process
.
platform
)
const
normalizePath
=
path
=>
(
isWin
?
path
.
replace
(
/
\\
/g
,
'
/
'
)
:
path
)
const
METHODS
=
[
'
error
'
,
'
warn
'
,
'
info
'
,
'
log
'
,
'
debug
'
]
const
FORMAT_LOG
=
'
__f__
'
module
.
exports
=
function
({
module
.
exports
=
function
({
types
:
t
})
{
return
{
visitor
:
{
CallExpression
(
path
,
state
)
{
CallExpression
(
path
,
state
)
{
const
opts
=
state
.
opts
if
(
path
.
node
.
callee
.
object
&&
path
.
node
.
callee
.
object
.
name
===
'
console
'
&&
METHODS
.
includes
(
path
.
node
.
callee
.
property
.
name
))
{
if
(
path
.
node
.
callee
.
property
.
name
===
'
debug
'
)
{
//console.debug=>console.log
if
(
path
.
node
.
callee
.
property
.
name
===
'
debug
'
)
{
//
console.debug=>console.log
path
.
node
.
callee
.
property
.
name
=
'
log
'
}
...
...
@@ -49,7 +48,6 @@ module.exports = function({
}
}
}
}
}
}
...
...
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-nvue-plugin/index.js
浏览文件 @
8bf24016
...
...
@@ -3,8 +3,7 @@ const {
}
=
require
(
'
@vue/cli-shared-utils
'
)
class
WebpackAppPlusNVuePlugin
{
apply
(
compiler
)
{
apply
(
compiler
)
{
let
isFirst
=
!
process
.
env
.
UNI_USING_NATIVE
&&
!
process
.
env
.
UNI_USING_V3_NATIVE
const
chunkVersions
=
{}
...
...
@@ -35,12 +34,12 @@ class WebpackAppPlusNVuePlugin {
changedFiles
.
length
>
0
&&
!
changedFiles
.
find
(
file
=>
file
===
'
app-config.js
'
||
file
===
'
app-service.js
'
)
)
{
done
(
`Build complete. PAGES:`
+
JSON
.
stringify
(
changedFiles
))
done
(
'
Build complete. PAGES:
'
+
JSON
.
stringify
(
changedFiles
))
}
else
{
done
(
`Build complete. Watching for changes...`
)
done
(
'
Build complete. Watching for changes...
'
)
}
}
else
{
done
(
`Build complete. `
)
done
(
'
Build complete.
'
)
}
}
resolve
()
...
...
packages/vue-cli-plugin-hbuilderx/packages/webpack-app-plus-plugin/index.js
浏览文件 @
8bf24016
...
...
@@ -10,7 +10,6 @@ let nvueCompiled = true
let
serviceCompiled
=
true
let
viewCompiled
=
true
const
nvueChangedFiles
=
[]
const
serviceChangedFiles
=
[]
const
viewChangedFiles
=
[]
...
...
@@ -19,9 +18,8 @@ let isFirst = true
let
compiling
=
false
class
WebpackAppPlusPlugin
{
apply
(
compiler
)
{
if
(
process
.
env
.
UNI_USING_V3
)
{
apply
(
compiler
)
{
if
(
process
.
env
.
UNI_USING_V3
)
{
const
chunkVersions
=
{}
const
entry
=
compiler
.
options
.
entry
()
...
...
@@ -30,7 +28,6 @@ class WebpackAppPlusPlugin {
const
isAppNVue
=
!
isAppService
&&
!
isAppView
compiler
.
hooks
.
invalid
.
tap
(
'
WebpackAppPlusPlugin
'
,
(
fileName
,
changeTime
)
=>
{
if
(
!
compiling
)
{
compiling
=
true
...
...
@@ -82,16 +79,16 @@ class WebpackAppPlusPlugin {
if
(
!
isFirst
&&
changedFiles
.
length
>
0
)
{
if
(
serviceChangedFiles
.
length
===
0
&&
viewChangedFiles
.
length
===
0
)
{
// 仅 nvue 页面发生变化
done
(
`Build complete. PAGES:`
+
JSON
.
stringify
(
changedFiles
))
done
(
'
Build complete. PAGES:
'
+
JSON
.
stringify
(
changedFiles
))
}
else
{
done
(
`Build complete. FILES:`
+
JSON
.
stringify
(
changedFiles
))
done
(
'
Build complete. FILES:
'
+
JSON
.
stringify
(
changedFiles
))
}
}
else
{
!
process
.
env
.
UNI_AUTOMATOR_WS_ENDPOINT
&&
done
(
`Build complete. Watching for changes...`
)
!
process
.
env
.
UNI_AUTOMATOR_WS_ENDPOINT
&&
done
(
'
Build complete. Watching for changes...
'
)
}
isFirst
=
false
}
else
{
done
(
`Build complete. `
)
done
(
'
Build complete.
'
)
}
nvueChangedFiles
.
length
=
0
serviceChangedFiles
.
length
=
0
...
...
@@ -103,21 +100,20 @@ class WebpackAppPlusPlugin {
})
}
else
{
compiler
.
hooks
.
done
.
tapPromise
(
'
WebpackAppPlusPlugin
'
,
compilation
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
return
resolve
()
}
const
callback
=
function
()
{
const
callback
=
function
()
{
fs
.
copyFileSync
(
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_TMP_DIR
,
'
manifest.json
'
),
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
manifest.json
'
))
'
manifest.json
'
),
path
.
resolve
(
process
.
env
.
UNI_OUTPUT_DIR
,
'
manifest.json
'
))
log
()
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
done
(
`Build complete. Watching for changes...`
)
done
(
'
Build complete. Watching for changes...
'
)
}
else
{
done
(
`Build complete. `
)
done
(
'
Build complete.
'
)
}
resolve
()
}
...
...
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/main.js
浏览文件 @
8bf24016
...
...
@@ -17,14 +17,14 @@ const {
const
appVuePath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
App.vue
'
)
function
genStyleRequest
(
style
,
i
,
stringifyRequest
)
{
function
genStyleRequest
(
style
,
i
,
stringifyRequest
)
{
const
src
=
style
.
src
||
normalizePath
(
appVuePath
)
const
attrsQuery
=
attrsToQuery
(
style
.
attrs
,
'
css
'
)
const
query
=
`?vue&type=style&index=
${
i
}${
attrsQuery
}
`
return
stringifyRequest
(
src
+
query
)
}
function
getAppStyleCode
(
stringifyRequest
)
{
function
getAppStyleCode
(
stringifyRequest
)
{
if
(
!
process
.
env
.
UNI_USING_NVUE_COMPILER
)
{
return
''
}
...
...
@@ -37,17 +37,17 @@ function getAppStyleCode(stringifyRequest) {
}
catch
(
e
)
{}
styles
.
forEach
((
style
,
index
)
=>
{
code
=
code
+
`Vue.prototype.__merge_style && Vue.prototype.__merge_style(require(
${
genStyleRequest
(
style
,
index
,
stringifyRequest
)}
).default,Vue.prototype.__$appStyle__)\n`
`Vue.prototype.__merge_style && Vue.prototype.__merge_style(require(
${
genStyleRequest
(
style
,
index
,
stringifyRequest
)}
).default,Vue.prototype.__$appStyle__)\n`
})
return
code
}
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
const
loaderContext
=
this
const
statCode
=
process
.
env
.
UNI_USING_STAT
?
`import '@dcloudio/uni-stat';`
:
''
const
statCode
=
process
.
env
.
UNI_USING_STAT
?
'
import
\'
@dcloudio/uni-stat
\'
;
'
:
''
if
(
this
.
resourceQuery
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
...
...
@@ -69,7 +69,6 @@ module.exports = function(content) {
return
`
${
getAppStyleCode
(
stringifyRequest
)}
`
}
}
}
return
statCode
+
content
}
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/style.js
浏览文件 @
8bf24016
var
path
=
require
(
'
path
'
)
var
styler
=
require
(
'
weex-styler
'
)
var
{
normalizePath
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
module
.
exports
=
function
(
content
)
{
this
.
cacheable
&&
this
.
cacheable
()
return
'
module.exports =
'
+
genStyleString
(
content
.
replace
(
/
\!
important/g
,
''
),
this
)
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
this
.
callback
(
null
,
'
module.exports =
'
+
genStyleString
(
content
.
replace
(
/!important/g
,
''
),
this
),
map
)
}
// @todo:
...
...
@@ -14,57 +14,57 @@ module.exports = function(content) {
// https://drafts.csswg.org/css-values/#lengths
var
REGEXP_LENGTH
=
/^
([
-+
]?[
0-9
]
*
\.?[
0-9
]
+
)(
rem|vw|vh|vmin|vmax|cm|mm|q|in|pt|pc|px
)
$/
function
convertLength
(
k
,
v
)
{
if
(
typeof
v
!==
'
string
'
)
{
return
v
}
var
result
=
v
.
match
(
REGEXP_LENGTH
)
if
(
result
)
{
if
(
result
[
2
]
===
'
px
'
)
{
return
result
[
1
]
}
return
result
[
1
]
+
'
CSS_UNIT_
'
+
result
[
2
].
toUpperCase
()
}
function
convertLength
(
k
,
v
)
{
if
(
typeof
v
!==
'
string
'
)
{
return
v
}
var
result
=
v
.
match
(
REGEXP_LENGTH
)
if
(
result
)
{
if
(
result
[
2
]
===
'
px
'
)
{
return
result
[
1
]
}
return
result
[
1
]
+
'
CSS_UNIT_
'
+
result
[
2
].
toUpperCase
()
}
return
v
}
let
isFirst
=
true
function
genStyleString
(
input
,
loader
)
{
var
output
=
'
{}
'
var
resourcePath
=
normalizePath
(
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
loader
.
resourcePath
))
styler
.
parse
(
input
,
function
(
err
,
obj
)
{
if
(
err
)
{
loader
.
emitError
(
err
)
return
}
if
(
obj
&&
obj
.
jsonStyle
)
{
if
(
obj
.
log
)
{
var
msgs
=
[]
obj
.
log
.
map
((
log
)
=>
{
if
(
log
.
reason
.
indexOf
(
'
NOTE:
'
)
!==
0
)
{
//仅显示警告,错误信息
if
(
log
.
selectors
)
{
msgs
.
push
(
`
${
log
.
selectors
}
:
${
log
.
reason
}
at
${
resourcePath
}
:
${
log
.
line
}
`
)
}
else
{
msgs
.
push
(
`
${
log
.
reason
}
at
${
resourcePath
}
:
${
log
.
line
}
`
)
}
}
})
if
(
msgs
.
length
)
{
if
(
isFirst
)
{
msgs
.
unshift
(
`nvue中不支持如下css。如全局或公共样式受影响,建议将告警样式写在ifndef APP-PLUS-NVUE的条件编译中,详情如下:`
)
isFirst
=
false
}
msgs
.
forEach
(
msg
=>
console
.
warn
(
msg
))
}
function
genStyleString
(
input
,
loader
)
{
var
output
=
'
{}
'
var
resourcePath
=
normalizePath
(
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
loader
.
resourcePath
))
styler
.
parse
(
input
,
function
(
err
,
obj
)
{
if
(
err
)
{
loader
.
emitError
(
err
)
return
}
if
(
obj
&&
obj
.
jsonStyle
)
{
if
(
obj
.
log
)
{
var
msgs
=
[]
obj
.
log
.
map
((
log
)
=>
{
if
(
log
.
reason
.
indexOf
(
'
NOTE:
'
)
!==
0
)
{
// 仅显示警告,错误信息
if
(
log
.
selectors
)
{
msgs
.
push
(
`
${
log
.
selectors
}
:
${
log
.
reason
}
at
${
resourcePath
}
:
${
log
.
line
}
`
)
}
else
{
msgs
.
push
(
`
${
log
.
reason
}
at
${
resourcePath
}
:
${
log
.
line
}
`
)
}
try
{
output
=
JSON
.
stringify
(
obj
.
jsonStyle
,
convertLength
,
2
)
.
replace
(
/"
([
-+
]?[
0-9
]
*
\.?[
0-9
]
+
)
CSS_UNIT_
([
A-Z
]
+
)
"/g
,
'
$1 * CSS_UNIT.$2
'
)
}
catch
(
e
)
{}
}
})
if
(
msgs
.
length
)
{
if
(
isFirst
)
{
msgs
.
unshift
(
'
nvue中不支持如下css。如全局或公共样式受影响,建议将告警样式写在ifndef APP-PLUS-NVUE的条件编译中,详情如下:
'
)
isFirst
=
false
}
msgs
.
forEach
(
msg
=>
console
.
warn
(
msg
))
}
})
return
output
}
try
{
output
=
JSON
.
stringify
(
obj
.
jsonStyle
,
convertLength
,
2
)
.
replace
(
/"
([
-+
]?[
0-9
]
*
\.?[
0-9
]
+
)
CSS_UNIT_
([
A-Z
]
+
)
"/g
,
'
$1 * CSS_UNIT.$2
'
)
}
catch
(
e
)
{}
}
})
return
output
}
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/template.js
浏览文件 @
8bf24016
...
...
@@ -17,15 +17,15 @@ const SCROLLER_COMPONENTS = [
'
waterfall
'
]
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
const
source
=
content
.
trim
()
if
(
SCROLLER_COMPONENTS
.
find
(
name
=>
source
.
indexOf
(
'
<
'
+
name
)
===
0
))
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
if
(
source
.
indexOf
(
'
<recycle-list
'
)
!==
-
1
)
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
let
resourcePath
=
normalizeNodeModules
(
...
...
@@ -44,15 +44,15 @@ module.exports = function(content) {
}
if
(
!
process
.
UNI_NVUE_ENTRY
[
resourcePath
])
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
// 暂时实时读取配置信息,查找是否 disableScroll
const
appJson
=
getPagesJson
()
let
pageJson
if
(
appJson
.
nvue
)
{
//旧版本
if
(
appJson
.
nvue
)
{
//
旧版本
if
(
!
appJson
.
nvue
||
!
appJson
.
nvue
.
pages
)
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
const
pagePath
=
resourcePath
+
'
.html
'
pageJson
=
appJson
.
nvue
.
pages
.
find
(
page
=>
page
.
path
===
pagePath
)
...
...
@@ -61,7 +61,7 @@ module.exports = function(content) {
}
if
(
!
pageJson
)
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
if
(
!
appJson
.
globalStyle
)
{
...
...
@@ -72,8 +72,10 @@ module.exports = function(content) {
Object
.
assign
(
pageJson
.
style
,
pageJson
.
style
[
'
app-plus
'
]
||
{})
const
pageJsonStyle
=
Object
.
assign
(
appJson
.
globalStyle
,
pageJson
.
style
)
if
(
pageJsonStyle
.
disableScroll
===
true
)
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
return
`<scroll-view :scroll-y="true" :show-scrollbar="
${
pageJsonStyle
.
scrollIndicator
===
'
none
'
?
'
false
'
:
'
true
'
}
" :enableBackToTop="true" bubble="true" style="flex-direction:column">
${
content
}
</scroll-view>`
this
.
callback
(
null
,
`<scroll-view :scroll-y="true" :show-scrollbar="
${
pageJsonStyle
.
scrollIndicator
===
'
none
'
?
'
false
'
:
'
true
'
}
" :enableBackToTop="true" bubble="true" style="flex-direction:column">
${
content
}
</scroll-view>`
,
map
)
}
packages/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/template.recycle.js
浏览文件 @
8bf24016
const
loaderUtils
=
require
(
'
loader-utils
'
)
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
const
vueLoaderOptions
=
this
.
loaders
.
find
(
loader
=>
loader
.
ident
===
'
vue-loader-options
'
)
...
...
@@ -14,5 +14,5 @@ module.exports = function(content) {
throw
new
Error
(
'
vue-loader-options parse error
'
)
}
return
content
this
.
callback
(
null
,
content
,
map
)
}
packages/vue-cli-plugin-hbuilderx/util.js
已删除
100644 → 0
浏览文件 @
82f0936c
const
path
=
require
(
'
path
'
)
const
{
normalizePath
,
isInHBuilderX
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/util
'
)
let
sourceRoot
=
false
function
devtoolModuleFilenameTemplate
(
info
)
{
if
(
!
sourceRoot
)
{
if
(
isInHBuilderX
)
{
sourceRoot
=
normalizePath
(
process
.
env
.
UNI_INPUT_DIR
)
}
else
{
sourceRoot
=
normalizePath
(
process
.
env
.
UNI_CLI_CONTEXT
)
}
}
let
filePath
=
false
const
absoluteResourcePath
=
normalizePath
(
info
.
absoluteResourcePath
)
if
(
absoluteResourcePath
.
indexOf
(
sourceRoot
)
!==
-
1
&&
(
absoluteResourcePath
.
endsWith
(
'
.js
'
)
||
absoluteResourcePath
.
endsWith
(
'
.ts
'
)
)
)
{
filePath
=
normalizePath
(
path
.
relative
(
sourceRoot
,
absoluteResourcePath
))
if
(
filePath
.
indexOf
(
'
node_modules/@dcloudio
'
)
===
0
||
filePath
.
indexOf
(
'
node_modules/vue-loader
'
)
===
0
||
filePath
.
indexOf
(
'
node_modules/webpack
'
)
===
0
)
{
filePath
=
false
}
}
else
if
(
!
info
.
moduleId
&&
(
absoluteResourcePath
.
endsWith
(
'
.vue
'
)
||
absoluteResourcePath
.
endsWith
(
'
.nvue
'
)
)
)
{
if
(
absoluteResourcePath
.
indexOf
(
'
src
'
)
!==
0
&&
absoluteResourcePath
.
indexOf
(
'
node-modules
'
)
!==
0
)
{
filePath
=
normalizePath
(
path
.
relative
(
sourceRoot
,
absoluteResourcePath
))
}
else
{
filePath
=
absoluteResourcePath
}
}
if
(
filePath
&&
filePath
!==
'
main.js
'
&&
filePath
!==
'
main.ts
'
&&
filePath
!==
'
src/main.js
'
&&
filePath
!==
'
src/main.ts
'
)
{
return
`uni-app:///
${
filePath
}
`
}
}
module
.
exports
=
{
devtoolModuleFilenameTemplate
}
packages/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js
浏览文件 @
8bf24016
...
...
@@ -8,12 +8,12 @@ process.UNI_APIS = new Set()
const
sourcePath
=
normalizePath
(
path
.
join
(
require
.
resolve
(
'
@dcloudio/uni-h5
'
),
'
../../
'
))
module
.
exports
=
function
({
module
.
exports
=
function
({
types
:
t
})
{
return
{
visitor
:
{
MemberExpression
(
path
,
state
)
{
MemberExpression
(
path
,
state
)
{
if
(
t
.
isIdentifier
(
path
.
node
.
object
)
&&
(
...
...
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js
浏览文件 @
8bf24016
...
...
@@ -4,24 +4,24 @@ const updateComponents = require('./component')
const
tmpDir
=
path
.
resolve
(
__dirname
,
'
../../.tmp
'
)
function
writeFileSync
(
filename
,
content
)
{
function
writeFileSync
(
filename
,
content
)
{
fs
.
writeFileSync
(
path
.
resolve
(
tmpDir
,
filename
),
content
,
'
utf8
'
)
}
function
parseImportPath
(
filepath
)
{
if
(
filepath
.
indexOf
(
'
/platforms
'
)
===
0
)
{
//api,appComponents(h5),appMixins(h5),systemRoutes(h5)
function
parseImportPath
(
filepath
)
{
if
(
filepath
.
indexOf
(
'
/platforms
'
)
===
0
)
{
//
api,appComponents(h5),appMixins(h5),systemRoutes(h5)
return
filepath
.
replace
(
'
/platforms/
'
+
process
.
env
.
UNI_PLATFORM
,
'
uni-platform
'
)
}
else
if
(
filepath
.
indexOf
(
'
/core/helpers
'
)
===
0
)
{
//protocol
}
else
if
(
filepath
.
indexOf
(
'
/core/helpers
'
)
===
0
)
{
//
protocol
return
filepath
.
replace
(
'
/core/helpers
'
,
'
uni-helpers
'
)
}
else
if
(
filepath
.
indexOf
(
'
/core/view
'
)
===
0
)
{
//subscribe
}
else
if
(
filepath
.
indexOf
(
'
/core/view
'
)
===
0
)
{
//
subscribe
return
filepath
.
replace
(
'
/core/view
'
,
'
uni-view
'
)
}
else
if
(
filepath
.
indexOf
(
'
/core
'
)
===
0
)
{
//api
}
else
if
(
filepath
.
indexOf
(
'
/core
'
)
===
0
)
{
//
api
return
filepath
.
replace
(
'
/core
'
,
'
uni-core
'
)
}
return
filepath
}
function
updateExportDefaultObject
(
paths
,
filename
,
isMulti
=
true
,
isExportArray
=
false
)
{
function
updateExportDefaultObject
(
paths
,
filename
,
isMulti
=
true
,
isExportArray
=
false
)
{
const
imports
=
[]
const
exports
=
[]
Object
.
keys
(
paths
).
forEach
(
name
=>
{
...
...
@@ -32,7 +32,7 @@ function updateExportDefaultObject(paths, filename, isMulti = true, isExportArra
}
exports
.
push
(
name
)
})
let
content
=
isExportArray
?
`export default []`
:
`export default {}`
let
content
=
isExportArray
?
'
export default []
'
:
'
export default {}
'
if
(
exports
.
length
)
{
if
(
isExportArray
)
{
content
=
`
...
...
@@ -53,37 +53,37 @@ function updateExportDefaultObject(paths, filename, isMulti = true, isExportArra
writeFileSync
(
filename
,
content
)
}
function
updateApi
(
paths
)
{
function
updateApi
(
paths
)
{
return
updateExportDefaultObject
(
paths
,
'
api.js
'
)
}
function
updateApiProtocol
(
paths
)
{
function
updateApiProtocol
(
paths
)
{
return
updateExportDefaultObject
(
paths
,
'
protocol.js
'
)
}
function
updateApiSubscribe
(
paths
)
{
function
updateApiSubscribe
(
paths
)
{
return
updateExportDefaultObject
(
paths
,
'
subscribe.js
'
)
}
function
updateInvokeApi
(
paths
)
{
function
updateInvokeApi
(
paths
)
{
return
updateExportDefaultObject
(
paths
,
'
invoke-api.js
'
)
}
function
updateAppComponents
(
paths
)
{
function
updateAppComponents
(
paths
)
{
return
updateExportDefaultObject
(
paths
,
'
app-components.js
'
,
false
)
}
function
updateCoreComponents
(
paths
)
{
function
updateCoreComponents
(
paths
)
{
const
tags
=
process
.
UNI_TAGS
||
new
Set
()
Object
.
keys
(
paths
).
forEach
(
tag
=>
tags
.
add
(
tag
.
replace
(
/
([
a-z
])([
A-Z
])
/g
,
'
$1-$2
'
).
toLowerCase
()))
updateComponents
(
tags
)
}
function
updateAppMixins
(
paths
)
{
function
updateAppMixins
(
paths
)
{
return
updateExportDefaultObject
(
paths
,
'
app-mixins.js
'
,
false
,
true
)
}
function
updateSystemRoutes
(
paths
)
{
function
updateSystemRoutes
(
paths
)
{
return
updateExportDefaultObject
(
paths
,
'
system-routes.js
'
,
false
)
}
...
...
@@ -118,9 +118,7 @@ const isApiSubscribe = filepath => {
return
filepath
.
indexOf
(
'
/core/view/bridge/subscribe/api
'
)
===
0
}
function
parseDeps
(
apis
,
manifest
)
{
function
parseDeps
(
apis
,
manifest
)
{
const
apiPaths
=
Object
.
create
(
null
)
const
apiProtocolPaths
=
Object
.
create
(
null
)
const
invokeApiPaths
=
Object
.
create
(
null
)
...
...
@@ -152,7 +150,7 @@ function parseDeps(apis, manifest) {
test
:
isApiSubscribe
,
paths
:
apiSubscribePaths
}]
for
(
le
t
name
of
apis
.
values
())
{
for
(
cons
t
name
of
apis
.
values
())
{
const
options
=
manifest
[
name
]
if
(
Array
.
isArray
(
options
))
{
apiPaths
[
name
]
=
options
[
0
]
...
...
@@ -167,7 +165,7 @@ function parseDeps(apis, manifest) {
const
filepath
=
dep
[
0
]
const
exports
=
dep
[
1
]
if
(
isCoreApi
&&
isPlatformApi
(
filepath
))
{
//invoke-api
if
(
isCoreApi
&&
isPlatformApi
(
filepath
))
{
//
invoke-api
invokeApiPaths
[
exports
]
=
filepath
}
else
{
const
strategy
=
strategies
.
find
(
strategy
=>
{
...
...
@@ -176,7 +174,7 @@ function parseDeps(apis, manifest) {
if
(
strategy
)
{
strategy
.
paths
[
exports
]
=
filepath
}
else
{
console
.
log
(
'
dep
'
,
name
,
dep
)
console
.
log
(
'
dep
'
,
name
,
dep
)
console
.
warn
(
`
${
filepath
}
未识别`
)
}
}
...
...
@@ -198,8 +196,7 @@ function parseDeps(apis, manifest) {
}
}
module
.
exports
=
function
updateApis
(
apis
=
new
Set
(),
userApis
=
new
Set
())
{
module
.
exports
=
function
updateApis
(
apis
=
new
Set
(),
userApis
=
new
Set
())
{
if
(
!
fs
.
existsSync
(
tmpDir
))
{
fs
.
mkdirSync
(
tmpDir
)
}
...
...
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js
浏览文件 @
8bf24016
...
...
@@ -16,7 +16,7 @@ const autoloadTags = {
}
}
module
.
exports
=
function
updateComponents
(
tags
)
{
module
.
exports
=
function
updateComponents
(
tags
)
{
autoloadTags
.
root
.
forEach
(
tagName
=>
{
tags
.
add
(
tagName
)
})
...
...
@@ -54,6 +54,5 @@ ${componentsStr}
fs
.
mkdirSync
(
dir
)
}
fs
.
writeFileSync
(
path
.
resolve
(
dir
,
'
components.js
'
),
content
,
'
utf8
'
)
fs
.
writeFileSync
(
path
.
resolve
(
dir
,
'
components.js
'
),
content
,
'
utf8
'
)
}
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/index.js
浏览文件 @
8bf24016
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
const
{
info
,
done
,
done
}
=
require
(
'
@vue/cli-shared-utils
'
)
const
updateComponents
=
require
(
'
./component
'
)
const
updateApis
=
require
(
'
./api
'
)
class
WebpackOptimizePlugin
{
apply
(
compiler
)
{
apply
(
compiler
)
{
let
optimized
=
false
compiler
.
hooks
.
beforeCompile
.
tapPromise
(
'
WebpackOptimizePlugin
'
,
compilation
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -28,12 +25,12 @@ class WebpackOptimizePlugin {
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
!
optimized
)
{
console
.
log
()
info
(
`Build optimizing...`
)
info
(
'
Build optimizing...
'
)
optimized
=
true
updateComponents
(
process
.
UNI_TAGS
||
new
Set
())
updateApis
(
process
.
UNI_APIS
||
new
Set
(),
process
.
UNI_USER_APIS
||
new
Set
())
}
else
{
done
(
`Build complete.`
)
done
(
'
Build complete.
'
)
process
.
exit
(
0
)
}
resolve
()
...
...
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/util.js
浏览文件 @
8bf24016
function
cached
(
fn
)
{
function
cached
(
fn
)
{
const
cache
=
Object
.
create
(
null
)
return
function
cachedFn
(
str
)
{
return
function
cachedFn
(
str
)
{
const
hit
=
cache
[
str
]
return
hit
||
(
cache
[
str
]
=
fn
(
str
))
}
...
...
@@ -8,11 +8,11 @@ function cached(fn) {
const
camelizeRE
=
/-
(\w)
/g
const
camelize
=
cached
(
function
(
str
)
{
const
camelize
=
cached
(
function
(
str
)
{
return
str
.
replace
(
camelizeRE
,
(
_
,
c
)
=>
c
?
c
.
toUpperCase
()
:
''
)
})
const
capitalize
=
cached
(
function
(
str
)
{
const
capitalize
=
cached
(
function
(
str
)
{
return
str
.
charAt
(
0
).
toUpperCase
()
+
str
.
slice
(
1
)
})
...
...
packages/vue-cli-plugin-uni-optimize/packages/webpack-style-loader/index.js
浏览文件 @
8bf24016
...
...
@@ -5,11 +5,11 @@ const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
const
src
=
require
(
'
@dcloudio/uni-h5/path
'
).
src
module
.
exports
=
function
(
content
)
{
this
.
cacheable
&&
this
.
cacheable
()
const
resourcePath
=
normalizePath
(
this
.
resourcePath
)
const
sourcePath
=
normalizePath
(
src
)
if
(
resourcePath
.
indexOf
(
sourcePath
)
===
0
)
{
return
''
}
return
content
this
.
cacheable
&&
this
.
cacheable
()
const
resourcePath
=
normalizePath
(
this
.
resourcePath
)
const
sourcePath
=
normalizePath
(
src
)
if
(
resourcePath
.
indexOf
(
sourcePath
)
===
0
)
{
return
''
}
return
content
}
packages/vue-cli-plugin-uni/lib/configure-webpack.js
浏览文件 @
8bf24016
...
...
@@ -263,7 +263,26 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
})
}
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
const
sourceMap
=
require
(
'
@dcloudio/uni-cli-shared/lib/source-map
'
)
let
isAppService
=
false
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
&&
vueOptions
.
pluginOptions
[
'
uni-app-plus
'
])
{
isAppService
=
!!
vueOptions
.
pluginOptions
[
'
uni-app-plus
'
].
service
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
||
isAppService
)
{
plugins
.
push
(
sourceMap
.
createEvalSourceMapDevToolPlugin
())
}
else
if
(
process
.
env
.
UNI_PLATFORM
.
indexOf
(
'
mp-
'
)
===
0
&&
process
.
env
.
UNI_PLATFORM
!==
'
mp-baidu
'
&&
process
.
env
.
UNI_PLATFORM
!==
'
mp-alipay
'
&&
process
.
env
.
UNI_PLATFORM
!==
'
quickapp-webview
'
// 目前 ov 的开发工具支持 eval 模式
)
{
plugins
.
push
(
sourceMap
.
createSourceMapDevToolPlugin
(
process
.
env
.
UNI_PLATFORM
===
'
mp-weixin
'
))
}
}
return
merge
({
devtool
:
false
,
resolve
:
{
alias
:
{
'
@
'
:
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
),
...
...
packages/vue-cli-plugin-uni/lib/error-reporting.js
浏览文件 @
8bf24016
...
...
@@ -15,7 +15,7 @@ function shouldReport (err = '') {
// err:string|Error
function
report
(
type
,
err
)
{
if
(
shouldReport
(
err
))
{
console
.
log
(
'
Error Reporting...
'
)
//
console.log('Error Reporting...')
// const https = require('https')
// const data = ...
// const req = https.request({
...
...
packages/vue-cli-plugin-uni/lib/mp/index.js
浏览文件 @
8bf24016
...
...
@@ -89,8 +89,8 @@ module.exports = {
output
:
{
filename
:
'
[name].js
'
,
chunkFilename
:
'
[id].js
'
,
globalObject
:
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
?
'
my
'
:
'
global
'
,
sourceMapFilename
:
'
../.sourcemap/
'
+
process
.
env
.
UNI_PLATFORM
+
'
/[name].js.map
'
globalObject
:
process
.
env
.
UNI_PLATFORM
===
'
mp-alipay
'
?
'
my
'
:
'
global
'
//
sourceMapFilename: '../.sourcemap/' + process.env.UNI_PLATFORM + '/[name].js.map'
},
performance
:
{
hints
:
false
...
...
packages/vue-cli-plugin-uni/packages/postcss/index.js
浏览文件 @
8bf24016
...
...
@@ -70,7 +70,7 @@ if (process.env.UNI_USING_V3) {
let
cssVarValue
=
false
walk
(
node
.
nodes
,
n
=>
{
if
(
n
.
type
===
'
word
'
)
{
if
(
cssVars
.
hasOwnProperty
(
n
.
value
))
{
// 目前仅考虑 nodes 长度为0
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
cssVars
,
n
.
value
))
{
// 目前仅考虑 nodes 长度为0
cssVarValue
=
cssVars
[
n
.
value
]
}
}
...
...
packages/vue-cli-plugin-uni/packages/postcss/tags.js
浏览文件 @
8bf24016
module
.
exports
=
{
'
br
'
:
'
r
'
,
'
hr
'
:
'
r
'
,
br
:
'
r
'
,
hr
:
'
r
'
,
'
p
'
:
'
r
'
,
'
h1
'
:
'
r
'
,
'
h2
'
:
'
r
'
,
'
h3
'
:
'
r
'
,
'
h4
'
:
'
r
'
,
'
h5
'
:
'
r
'
,
'
h6
'
:
'
r
'
,
'
abbr
'
:
'
r
'
,
'
address
'
:
'
r
'
,
'
b
'
:
'
r
'
,
'
bdi
'
:
'
r
'
,
'
bdo
'
:
'
r
'
,
'
blockquote
'
:
'
r
'
,
'
cite
'
:
'
r
'
,
'
code
'
:
'
r
'
,
'
del
'
:
'
r
'
,
'
ins
'
:
'
r
'
,
'
dfn
'
:
'
r
'
,
'
em
'
:
'
r
'
,
'
strong
'
:
'
r
'
,
'
samp
'
:
'
r
'
,
'
kbd
'
:
'
r
'
,
'
var
'
:
'
r
'
,
'
i
'
:
'
r
'
,
'
mark
'
:
'
r
'
,
'
pre
'
:
'
r
'
,
'
q
'
:
'
r
'
,
'
ruby
'
:
'
r
'
,
'
rp
'
:
'
r
'
,
'
rt
'
:
'
r
'
,
'
s
'
:
'
r
'
,
'
small
'
:
'
r
'
,
'
sub
'
:
'
r
'
,
'
sup
'
:
'
r
'
,
'
time
'
:
'
r
'
,
'
u
'
:
'
r
'
,
'
wbr
'
:
'
r
'
,
p
:
'
r
'
,
h1
:
'
r
'
,
h2
:
'
r
'
,
h3
:
'
r
'
,
h4
:
'
r
'
,
h5
:
'
r
'
,
h6
:
'
r
'
,
abbr
:
'
r
'
,
address
:
'
r
'
,
b
:
'
r
'
,
bdi
:
'
r
'
,
bdo
:
'
r
'
,
blockquote
:
'
r
'
,
cite
:
'
r
'
,
code
:
'
r
'
,
del
:
'
r
'
,
ins
:
'
r
'
,
dfn
:
'
r
'
,
em
:
'
r
'
,
strong
:
'
r
'
,
samp
:
'
r
'
,
kbd
:
'
r
'
,
var
:
'
r
'
,
i
:
'
r
'
,
mark
:
'
r
'
,
pre
:
'
r
'
,
q
:
'
r
'
,
ruby
:
'
r
'
,
rp
:
'
r
'
,
rt
:
'
r
'
,
s
:
'
r
'
,
small
:
'
r
'
,
sub
:
'
r
'
,
sup
:
'
r
'
,
time
:
'
r
'
,
u
:
'
r
'
,
wbr
:
'
r
'
,
// 表单元素
// 'form': 'r',
// 'input': 'r',
// 'textarea': 'r',
// 'button': 'r',
'
select
'
:
'
r
'
,
'
option
'
:
'
r
'
,
'
optgroup
'
:
'
r
'
,
select
:
'
r
'
,
option
:
'
r
'
,
optgroup
:
'
r
'
,
// 'label': 'r',
'
fieldset
'
:
'
r
'
,
'
datalist
'
:
'
r
'
,
'
legend
'
:
'
r
'
,
'
output
'
:
'
r
'
,
fieldset
:
'
r
'
,
datalist
:
'
r
'
,
legend
:
'
r
'
,
output
:
'
r
'
,
// 框架
'
iframe
'
:
'
r
'
,
iframe
:
'
r
'
,
// 图像
'
img
'
:
'
r
'
,
img
:
'
r
'
,
// 'canvas': 'r',
'
figure
'
:
'
r
'
,
'
figcaption
'
:
'
r
'
,
figure
:
'
r
'
,
figcaption
:
'
r
'
,
// 音视频
// 'audio': 'r',
'
source
'
:
'
r
'
,
source
:
'
r
'
,
// 'video': 'r',
'
track
'
:
'
r
'
,
track
:
'
r
'
,
// 链接
'
a
'
:
'
r
'
,
'
nav
'
:
'
r
'
,
'
link
'
:
'
r
'
,
a
:
'
r
'
,
nav
:
'
r
'
,
link
:
'
r
'
,
// 列表
'
ul
'
:
'
r
'
,
'
ol
'
:
'
r
'
,
'
li
'
:
'
r
'
,
'
dl
'
:
'
r
'
,
'
dt
'
:
'
r
'
,
'
dd
'
:
'
r
'
,
'
menu
'
:
'
r
'
,
'
command
'
:
'
r
'
,
ul
:
'
r
'
,
ol
:
'
r
'
,
li
:
'
r
'
,
dl
:
'
r
'
,
dt
:
'
r
'
,
dd
:
'
r
'
,
menu
:
'
r
'
,
command
:
'
r
'
,
// 表格table
'
table
'
:
'
r
'
,
'
caption
'
:
'
r
'
,
'
th
'
:
'
r
'
,
'
td
'
:
'
r
'
,
'
tr
'
:
'
r
'
,
'
thead
'
:
'
r
'
,
'
tbody
'
:
'
r
'
,
'
tfoot
'
:
'
r
'
,
'
col
'
:
'
r
'
,
'
colgroup
'
:
'
r
'
,
table
:
'
r
'
,
caption
:
'
r
'
,
th
:
'
r
'
,
td
:
'
r
'
,
tr
:
'
r
'
,
thead
:
'
r
'
,
tbody
:
'
r
'
,
tfoot
:
'
r
'
,
col
:
'
r
'
,
colgroup
:
'
r
'
,
// 样式 节
'
div
'
:
'
r
'
,
'
main
'
:
'
r
'
,
'
span
'
:
'
r
'
,
'
header
'
:
'
r
'
,
'
footer
'
:
'
r
'
,
'
section
'
:
'
r
'
,
'
article
'
:
'
r
'
,
'
aside
'
:
'
r
'
,
'
details
'
:
'
r
'
,
'
dialog
'
:
'
r
'
,
'
summary
'
:
'
r
'
,
div
:
'
r
'
,
main
:
'
r
'
,
span
:
'
r
'
,
header
:
'
r
'
,
footer
:
'
r
'
,
section
:
'
r
'
,
article
:
'
r
'
,
aside
:
'
r
'
,
details
:
'
r
'
,
dialog
:
'
r
'
,
summary
:
'
r
'
,
// 'progress': 'r',
'
meter
'
:
'
r
'
,
// todo
'
head
'
:
'
r
'
,
// todo
'
meta
'
:
'
r
'
,
// todo
'
base
'
:
'
r
'
,
// todo
meter
:
'
r
'
,
// todo
head
:
'
r
'
,
// todo
meta
:
'
r
'
,
// todo
base
:
'
r
'
,
// todo
// 'map': 'r', // TODO不是很恰当
'
area
'
:
'
r
'
,
// j结合map使用
area
:
'
r
'
,
// j结合map使用
'
script
'
:
'
r
'
,
'
noscript
'
:
'
r
'
,
'
embed
'
:
'
r
'
,
'
object
'
:
'
r
'
,
'
param
'
:
'
r
'
,
'
body
'
:
'
page
'
,
'
html
'
:
'
page
'
script
:
'
r
'
,
noscript
:
'
r
'
,
embed
:
'
r
'
,
object
:
'
r
'
,
param
:
'
r
'
,
body
:
'
page
'
,
html
:
'
page
'
}
packages/vue-cli-plugin-uni/packages/webpack-custom-block-loader/index.bak.js
浏览文件 @
8bf24016
...
...
@@ -14,7 +14,7 @@ const {
const
FILTER_TAG
=
getPlatformFilterTag
()
module
.
exports
=
function
(
source
)
{
module
.
exports
=
function
(
source
)
{
const
loaderContext
=
this
const
{
...
...
packages/vue-cli-plugin-uni/packages/webpack-html-append-plugin/index.js
浏览文件 @
8bf24016
const
HtmlWebpackPlugin
=
require
(
'
html-webpack-plugin
'
)
class
WebpackHtmlAppendPlugin
{
constructor
(
content
)
{
constructor
(
content
)
{
this
.
content
=
content
||
''
}
apply
(
compiler
)
{
}
apply
(
compiler
)
{
compiler
.
hooks
.
compilation
.
tap
(
'
WebpackHtmlAppendPlugin
'
,
(
compilation
)
=>
{
let
beforeEmit
=
compilation
.
hooks
.
htmlWebpackPluginAfterHtmlProcessing
if
(
!
beforeEmit
&&
HtmlWebpackPlugin
.
getHooks
)
{
...
...
packages/vue-cli-plugin-uni/packages/webpack-preprocess-loader/index.js
浏览文件 @
8bf24016
...
...
@@ -8,17 +8,17 @@ const {
const
preprocessor
=
require
(
'
./preprocess/lib/preprocess
'
)
const
ERRORS
=
{
'
html
'
:
`条件编译失败,参考示例(注意 ifdef 与 endif 必须配对使用):
html
:
`条件编译失败,参考示例(注意 ifdef 与 endif 必须配对使用):
<!-- #ifdef %PLATFORM% -->
模板代码
<!-- #endif -->
`
,
'
js
'
:
`条件编译失败,参考示例(注意 ifdef 与 endif 必须配对使用):
js
:
`条件编译失败,参考示例(注意 ifdef 与 endif 必须配对使用):
// #ifdef %PLATFORM%
js代码
// #endif
`
,
'
css
'
:
`条件编译失败,参考示例(注意 ifdef 与 endif 必须配对使用):
css
:
`条件编译失败,参考示例(注意 ifdef 与 endif 必须配对使用):
/* #ifdef %PLATFORM% */
css代码
/* #endif */
...
...
@@ -26,9 +26,9 @@ css代码
}
const
TAGS
=
{
'
html
'
:
'
template
'
,
'
js
'
:
'
script
'
,
'
css
'
:
'
style
'
html
:
'
template
'
,
js
:
'
script
'
,
css
:
'
style
'
}
module
.
exports
=
function
(
content
,
map
)
{
...
...
packages/vue-cli-plugin-uni/packages/webpack-scoped-loader/index.js
浏览文件 @
8bf24016
...
...
@@ -4,14 +4,14 @@ const isWin = /^win/.test(process.platform)
const
normalizePath
=
path
=>
(
isWin
?
path
.
replace
(
/
\\
/g
,
'
/
'
)
:
path
)
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
const
resourcePath
=
normalizePath
(
this
.
resourcePath
)
if
(
resourcePath
!==
normalizePath
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
App.vue
'
))
&&
content
.
indexOf
(
'
platform="mp-weixin"
'
)
===
-
1
// 小程序组件暂不加scoped
)
{
return
content
.
replace
(
/
(
<style
\b[^
><
]
*
)
>/ig
,
'
$1 scoped>
'
)
return
this
.
callback
(
null
,
content
.
replace
(
/
(
<style
\b[^
><
]
*
)
>/ig
,
'
$1 scoped>
'
),
map
)
}
return
content
this
.
callback
(
null
,
content
,
map
)
}
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/filter-modules-template.js
浏览文件 @
8bf24016
const
loaderUtils
=
require
(
'
loader-utils
'
)
function
parseFilterModules
(
filterModules
)
{
function
parseFilterModules
(
filterModules
)
{
if
(
filterModules
)
{
return
JSON
.
parse
(
Buffer
.
from
(
filterModules
,
'
base64
'
).
toString
(
'
utf8
'
))
}
return
{}
}
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
const
vueLoaderOptions
=
this
.
loaders
.
find
(
loader
=>
loader
.
ident
===
'
vue-loader-options
'
)
...
...
@@ -21,5 +21,5 @@ module.exports = function(content) {
}
else
{
throw
new
Error
(
'
vue-loader-options parse error
'
)
}
return
content
this
.
callback
(
null
,
content
,
map
)
}
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/page-meta.js
浏览文件 @
8bf24016
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
// TODO 简单判断,只要包含 page-meta,就在外层包裹一层 view (vue2 不支持多 root)
if
(
content
.
indexOf
(
'
<page-meta
'
)
!==
-
1
)
{
return
`<view>
${
content
}
</view>`
return
this
.
callback
(
null
,
`<view>
${
content
}
</view>`
,
map
)
}
return
content
this
.
callback
(
null
,
content
,
map
)
}
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/plugin/index.js
浏览文件 @
8bf24016
const
path
=
require
(
'
path
'
)
const
{
normalizePath
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
initAutoImportScanComponents
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
...
...
@@ -11,19 +5,19 @@ const {
let
compiling
=
false
class
WebpackUniAppPlugin
{
apply
(
compiler
)
{
apply
(
compiler
)
{
if
(
process
.
UNI_CONFUSION
)
{
compiler
.
hooks
.
emit
.
tapPromise
(
'
webpack-uni-app-emit
'
,
compilation
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
compilation
.
assets
[
'
app-confusion.js
'
])
{
//存在加密
if
(
compilation
.
assets
[
'
app-confusion.js
'
])
{
//
存在加密
const
manifestJson
=
JSON
.
parse
(
`
${
compilation
.
assets
[
'
manifest.json
'
].
source
()}
`
)
manifestJson
.
plus
.
confusion
.
resources
[
'
app-confusion.js
'
]
=
{}
const
source
=
JSON
.
stringify
(
manifestJson
)
compilation
.
assets
[
'
manifest.json
'
]
=
{
size
()
{
size
()
{
return
Buffer
.
byteLength
(
source
,
'
utf8
'
)
},
source
()
{
source
()
{
return
source
}
}
...
...
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/service/style.js
浏览文件 @
8bf24016
module
.
exports
=
function
(
source
,
map
)
{
module
.
exports
=
function
(
source
,
map
)
{
/* eslint-disable no-mixed-operators */
console
.
warn
(
`App平台 v3 模式暂不支持在 js 文件中引用"
${
this
.
_module
&&
this
.
_module
.
rawRequest
||
this
.
resourcePath
}
"`
)
return
''
this
.
callback
(
null
,
''
,
map
)
}
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/using-components.js
浏览文件 @
8bf24016
...
...
@@ -8,7 +8,7 @@ const {
getUsingComponentsCode
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/pages
'
)
module
.
exports
=
function
(
content
,
map
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
const
resourcePath
=
removeExt
(
normalizePath
(
path
.
relative
(
process
.
env
.
UNI_INPUT_DIR
,
this
.
resourcePath
))
...
...
@@ -16,7 +16,7 @@ module.exports = function(content, map) {
content
=
content
+
getUsingComponentsCode
(
resourcePath
)
// TODO 自动导入 vue 组件(h5,小程序,app[vue,nvue])
// 1. 需要 template-loader 解析出所有自定义组件()
// 2. 根据自定义组件信息生成引用代码
// 2. 根据自定义组件信息生成引用代码
// 3. node-modules中的组件不提供自动导入
return
content
this
.
callback
(
null
,
content
,
map
)
}
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
浏览文件 @
8bf24016
...
...
@@ -21,7 +21,7 @@ const {
parseComponents
}
=
require
(
'
./util
'
)
function
getDefineComponents
({
function
getDefineComponents
({
components
})
{
return
components
.
map
(({
...
...
@@ -32,7 +32,7 @@ function getDefineComponents({
const
appVueFilePath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
app.vue
'
)
function
getStylesCode
(
loaderContext
)
{
function
getStylesCode
(
loaderContext
)
{
if
(
!
fs
.
existsSync
(
appVueFilePath
))
{
return
}
...
...
@@ -59,10 +59,8 @@ function getStylesCode(loaderContext) {
})
// styles
let
stylesCode
=
``
let
stylesCode
=
''
if
(
descriptor
.
styles
.
length
)
{
const
isServer
=
false
const
isShadow
=
false
const
isProduction
=
options
.
productionMode
||
minimize
||
process
.
env
.
NODE_ENV
===
'
production
'
const
stringifyRequest
=
r
=>
loaderUtils
.
stringifyRequest
(
loaderContext
,
r
)
...
...
@@ -77,9 +75,9 @@ function getStylesCode(loaderContext) {
const
needsHotReload
=
false
const
id
=
hash
(
isProduction
?
(
shortFilePath
+
'
\n
'
+
source
)
:
shortFilePath
isProduction
?
(
shortFilePath
+
'
\n
'
+
source
)
:
shortFilePath
)
stylesCode
=
genStylesCode
(
loaderContext
,
...
...
@@ -95,14 +93,15 @@ function getStylesCode(loaderContext) {
return
stylesCode
.
replace
(
/main
\.[
jt
]
s/g
,
'
App.vue
'
)
}
module
.
exports
=
function
(
source
,
map
)
{
module
.
exports
=
function
(
source
,
map
)
{
// 追加小程序全局自定义组件(仅v3)
source
=
getGlobalUsingComponentsCode
()
+
source
const
automatorCode
=
process
.
env
.
UNI_AUTOMATOR_WS_ENDPOINT
?
`import '@dcloudio/uni-app-plus/dist/automator.view'`
:
''
return
`
import 'uni-pages?
${
JSON
.
stringify
({
type
:
'
view
'
})}
'
const
automatorCode
=
process
.
env
.
UNI_AUTOMATOR_WS_ENDPOINT
?
'
import
\'
@dcloudio/uni-app-plus/dist/automator.view
\'
'
:
''
this
.
callback
(
null
,
`
import 'uni-pages?
${
JSON
.
stringify
({
type
:
'
view
'
})}
'
${
automatorCode
}
function initView(){
${
getStylesCode
(
this
)}
...
...
@@ -115,5 +114,6 @@ if(typeof plus !== 'undefined'){
} else {
document.addEventListener('plusready',initView)
}
`
`
,
map
)
}
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/renderjs.js
浏览文件 @
8bf24016
const
path
=
require
(
'
path
'
)
const
loaderUtils
=
require
(
'
loader-utils
'
)
module
.
exports
=
function
(
source
,
map
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
module
.
exports
=
function
(
source
,
map
)
{
// v3 app-plus
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
&&
process
.
env
.
UNI_USING_V3
)
{
this
.
callback
(
return
this
.
callback
(
null
,
`export default function (Component) {
${
source
.
trim
()}
...
...
@@ -14,5 +9,5 @@ ${source.trim()}
map
)
}
return
source
this
.
callback
(
null
,
source
,
map
)
}
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/script.js
浏览文件 @
8bf24016
...
...
@@ -10,7 +10,7 @@ const {
parseComponents
}
=
require
(
'
./util
'
)
function
genComponentCode
(
components
)
{
function
genComponentCode
(
components
)
{
const
importCode
=
[]
const
componentsCode
=
[]
components
.
forEach
(({
...
...
@@ -24,7 +24,7 @@ function genComponentCode(components) {
return
[
importCode
.
join
(
'
\n
'
),
componentsCode
.
join
(
'
,
\n
'
)]
}
function
genCode
({
function
genCode
({
components
,
options
},
css
=
[])
{
...
...
@@ -37,10 +37,10 @@ function genCode({
return
`
${
importComponentCode
}
export default {
${
optionsCode
.
length
?(
optionsCode
.
join
(
'
,
'
)
+
'
,
'
):
''
}
${
optionsCode
.
length
?
(
optionsCode
.
join
(
'
,
'
)
+
'
,
'
)
:
''
}
data(){
return {
wxsProps:{}
return {
wxsProps:{}
}
},
components:{
...
...
@@ -50,12 +50,12 @@ export default {
`
}
module
.
exports
=
function
(
content
,
map
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
content
=
preprocessor
.
preprocess
(
content
,
jsPreprocessOptions
.
context
,
{
type
:
jsPreprocessOptions
.
type
})
return
genCode
(
parseComponents
(
content
,
traverse
)
)
this
.
callback
(
null
,
genCode
(
parseComponents
(
content
,
traverse
)),
map
)
}
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/style.js
浏览文件 @
8bf24016
...
...
@@ -5,20 +5,19 @@ const isWin = /^win/.test(process.platform)
const
normalizePath
=
path
=>
(
isWin
?
path
.
replace
(
/
\\
/g
,
'
/
'
)
:
path
)
const
AppPath
=
normalizePath
(
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
App.vue
'
))
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
if
(
this
.
resourceQuery
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
if
(
params
.
mpType
===
'
page
'
)
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
}
if
(
normalizePath
(
this
.
resourcePath
)
===
AppPath
)
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
if
(
content
.
indexOf
(
'
platform="mp-weixin"
'
)
!==
-
1
)
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
return
content
.
replace
(
/
(
<style
\b[^
><
]
*
)
>/ig
,
'
$1 scoped>
'
)
return
this
.
callback
(
null
,
content
.
replace
(
/
(
<style
\b[^
><
]
*
)
>/ig
,
'
$1 scoped>
'
),
map
)
}
packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js
浏览文件 @
8bf24016
const
parser
=
require
(
'
@babel/parser
'
)
function
parseComponents
(
content
,
traverse
)
{
function
parseComponents
(
content
,
traverse
)
{
const
{
state
:
{
options
,
...
...
packages/vue-cli-plugin-uni/packages/webpack-uni-filter-loader/index.js
浏览文件 @
8bf24016
...
...
@@ -10,7 +10,7 @@ const {
normalizeNodeModules
}
=
require
(
'
@dcloudio/uni-cli-shared/lib/platform
'
)
module
.
exports
=
function
(
source
,
map
)
{
module
.
exports
=
function
(
source
,
map
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
||
...
...
@@ -35,7 +35,7 @@ module.exports = function(source, map) {
traverse
(
parser
.
parse
(
source
,
{
sourceType
:
'
module
'
}),
{
MemberExpression
(
path
,
state
)
{
MemberExpression
(
path
,
state
)
{
const
property
=
path
.
node
.
property
const
parentNode
=
path
.
parent
if
(
...
...
@@ -60,8 +60,8 @@ module.exports = function(source, map) {
if(!Component.options.wxsCallMethods){
Component.options.wxsCallMethods = []
}
${[...
callMethods
].
map
(
method
=>
{
return
"
Component.options.wxsCallMethods.push('
"
+
method
+
"
')
"
${[...
callMethods
].
map
(
method
=>
{
return
"
Component.options.wxsCallMethods.push('
"
+
method
+
"
')
"
}).
join
(
'
\n
'
)}
}`
,
map
)
...
...
packages/vue-cli-plugin-uni/packages/wrap-loader/index.js
浏览文件 @
8bf24016
const
utils
=
require
(
'
loader-utils
'
)
module
.
exports
=
function
(
source
)
{
this
.
cacheable
()
const
opts
=
utils
.
getOptions
(
this
)
||
{}
// fixed by xxxxxx 保持行号不变
return
[].
concat
(
opts
.
before
,
source
,
opts
.
after
).
join
(
''
).
trim
()
// return [].concat(opts.before, source, opts.after).join('\n').trim()
const
utils
=
require
(
'
loader-utils
'
)
module
.
exports
=
function
(
source
,
map
)
{
this
.
cacheable
()
const
opts
=
utils
.
getOptions
(
this
)
||
{}
this
.
callback
(
null
,
[].
concat
(
opts
.
before
,
source
,
opts
.
after
).
join
(
''
).
trim
(),
map
)
}
packages/webpack-uni-mp-loader/lib/main-new.js
浏览文件 @
8bf24016
...
...
@@ -45,7 +45,7 @@ function addCreateApp (babelLoader) {
babelLoader
.
options
.
plugins
.
push
([
babelPluginCreateApp
])
}
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
if
(
this
.
resourceQuery
)
{
...
...
@@ -65,11 +65,12 @@ module.exports = function (content) {
}
}
}
return
`
return
this
.
callback
(
null
,
`
import Vue from 'vue'
import Page from './
${
normalizePath
(
params
.
page
)}${
ext
}
'
createPage(Page)
`
`
,
map
)
}
}
else
{
content
=
preprocessor
.
preprocess
(
content
,
jsPreprocessOptions
.
context
,
{
...
...
@@ -96,7 +97,7 @@ createPage(Page)
if
(
!
components
.
length
)
{
// 防止组件从有到无
updateUsingComponents
(
resourcePath
,
Object
.
create
(
null
),
'
App
'
)
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
const
callback
=
this
.
async
()
...
...
@@ -130,9 +131,9 @@ createPage(Page)
addDynamicImport
(
babelLoader
,
resourcePath
,
dynamicImports
)
updateUsingComponents
(
resourcePath
,
usingComponents
,
'
App
'
)
callback
(
null
,
content
)
callback
(
null
,
content
,
map
)
},
err
=>
{
callback
(
err
,
content
)
callback
(
err
,
content
,
map
)
})
}
}
packages/webpack-uni-mp-loader/lib/main.js
浏览文件 @
8bf24016
...
...
@@ -36,9 +36,9 @@ function getMPVuePageFactoryMainJsCode (params) {
Page(pageFactory(App))`
}
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
if
(
process
.
env
.
UNI_USING_COMPONENTS
)
{
return
require
(
'
./main-new
'
).
call
(
this
,
content
)
return
require
(
'
./main-new
'
).
call
(
this
,
content
,
map
)
}
this
.
cacheable
&&
this
.
cacheable
()
if
(
this
.
resourceQuery
)
{
...
...
packages/webpack-uni-mp-loader/lib/script.js
浏览文件 @
8bf24016
...
...
@@ -19,7 +19,7 @@ module.exports = function (content, map) {
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
)
{
return
require
(
'
./script-new
'
).
call
(
this
,
content
,
map
)
}
return
require
(
'
./script-new
'
).
call
(
this
,
content
)
return
require
(
'
./script-new
'
).
call
(
this
,
content
,
map
)
}
this
.
cacheable
&&
this
.
cacheable
()
...
...
packages/webpack-uni-mp-loader/lib/style.js
浏览文件 @
8bf24016
const
fs
=
require
(
'
fs
'
)
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
const
{
removeExt
,
normalizePath
,
getFlexDirection
,
getFlexDirection
,
parseManifestJson
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
...
...
@@ -12,14 +12,14 @@ const {
normalizeNodeModules
}
=
require
(
'
./shared
'
)
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
if
(
!
process
.
env
.
UNI_USING_NVUE_COMPILER
)
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
if
(
path
.
extname
(
this
.
resourcePath
)
!==
'
.nvue
'
)
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
const
resourcePath
=
normalizeNodeModules
(
removeExt
(
...
...
@@ -27,22 +27,24 @@ module.exports = function (content) {
)
)
if
(
!
process
.
UNI_ENTRY
[
resourcePath
])
{
return
content
return
this
.
callback
(
null
,
content
,
map
)
}
const
manifestJsonPath
=
path
.
resolve
(
process
.
env
.
UNI_INPUT_DIR
,
'
manifest.json
'
)
const
manifestJson
=
parseManifestJson
(
fs
.
readFileSync
(
manifestJsonPath
,
'
utf8
'
))
return
`<style>
this
.
callback
(
null
,
`
${
content
}
<style>
view,
swiper-item,
swiper-item,
scroll-view {
display:flex;
flex-direction:
${
getFlexDirection
(
manifestJson
[
'
app-plus
'
])}
;
flex-shrink: 0;
flex-grow: 0;
flex-basis: auto;
align-items: stretch;
flex-direction:
${
getFlexDirection
(
manifestJson
[
'
app-plus
'
])}
;
flex-shrink: 0;
flex-grow: 0;
flex-basis: auto;
align-items: stretch;
align-content: flex-start;
}
view,
...
...
@@ -57,10 +59,10 @@ module.exports = function (content) {
position: relative;
border: 0px solid #000000;
box-sizing: border-box;
}
swiper-item {
position: absolute;
}
</style>
${
content
}
`
swiper-item {
position: absolute;
}
</style>`
,
map
)
}
packages/webpack-uni-mp-loader/lib/template.js
浏览文件 @
8bf24016
...
...
@@ -28,15 +28,15 @@ const {
const
templateExt
=
getPlatformExts
().
template
const
filterTagName
=
getPlatformFilterTag
()
||
''
function
parseFilterModules
(
filterModules
)
{
if
(
filterModules
)
{
return
JSON
.
parse
(
Buffer
.
from
(
filterModules
,
'
base64
'
).
toString
(
'
utf8
'
))
}
return
{}
}
}
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
const
vueLoaderOptions
=
this
.
loaders
.
find
(
loader
=>
loader
.
ident
===
'
vue-loader-options
'
)
...
...
@@ -69,5 +69,5 @@ module.exports = function (content) {
}
else
{
throw
new
Error
(
'
vue-loader-options parse error
'
)
}
return
content
this
.
callback
(
null
,
content
,
map
)
}
packages/webpack-uni-pages-loader/lib/index-new.js
浏览文件 @
8bf24016
...
...
@@ -32,7 +32,7 @@ function renameUsingComponents (jsonObj) {
return
jsonObj
}
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
this
.
cacheable
&&
this
.
cacheable
()
let
isAppView
=
false
...
...
@@ -67,10 +67,10 @@ module.exports = function (content) {
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
h5
'
)
{
return
require
(
'
./platforms/h5
'
)(
pagesJson
,
manifestJson
,
this
)
return
this
.
callback
(
null
,
require
(
'
./platforms/h5
'
)(
pagesJson
,
manifestJson
,
this
),
map
)
}
if
(
process
.
env
.
UNI_PLATFORM
===
'
quickapp-native
'
)
{
return
require
(
'
./platforms/quickapp-native
'
)(
pagesJson
,
manifestJson
,
this
)
return
this
.
callback
(
null
,
require
(
'
./platforms/quickapp-native
'
)(
pagesJson
,
manifestJson
,
this
),
map
)
}
if
(
!
process
.
env
.
UNI_USING_V3
)
{
...
...
@@ -104,7 +104,7 @@ module.exports = function (content) {
}
}
})
return
appConfigContent
return
this
.
callback
(
null
,
appConfigContent
,
map
)
}
if
(
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
let
appConfigContent
=
''
...
...
@@ -117,7 +117,7 @@ module.exports = function (content) {
}
}
})
return
appConfigContent
return
this
.
callback
(
null
,
appConfigContent
,
map
)
}
jsonFiles
.
forEach
(
jsonFile
=>
{
...
...
@@ -131,5 +131,5 @@ module.exports = function (content) {
})
}
return
''
this
.
callback
(
null
,
''
,
map
)
}
packages/webpack-uni-pages-loader/lib/index.js
浏览文件 @
8bf24016
...
...
@@ -29,7 +29,7 @@ function checkEmitFile (filePath, jsonObj, changedEmitFiles) {
}
}
module
.
exports
=
function
(
content
)
{
module
.
exports
=
function
(
content
,
map
)
{
if
(
this
.
resourceQuery
)
{
const
params
=
loaderUtils
.
parseQuery
(
this
.
resourceQuery
)
if
(
params
)
{
...
...
@@ -46,7 +46,7 @@ module.exports = function (content) {
process
.
env
.
UNI_PLATFORM
===
'
h5
'
||
process
.
env
.
UNI_PLATFORM
===
'
quickapp-native
'
)
{
return
require
(
'
./index-new
'
).
call
(
this
,
content
)
return
require
(
'
./index-new
'
).
call
(
this
,
content
,
map
)
}
this
.
cacheable
&&
this
.
cacheable
()
...
...
@@ -98,5 +98,5 @@ module.exports = function (content) {
this
.
emitFile
(
name
+
'
.json
'
,
emitFileCaches
[
name
])
})
return
''
this
.
callback
(
null
,
''
,
map
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录