@mpxjs/webpack-plugin 2.7.52 → 2.7.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dependencies/DynamicEntryDependency.js +18 -11
- package/lib/extractor.js +2 -1
- package/lib/index.js +4 -4
- package/lib/loader.js +10 -6
- package/lib/runtime/animation.js +59 -0
- package/lib/runtime/components/web/mpx-picker.vue +14 -8
- package/lib/runtime/optionProcessor.js +9 -100
- package/lib/runtime/transRpxStyle.js +44 -0
- package/lib/template-compiler/compiler.js +6 -2
- package/lib/template-compiler/index.js +3 -1
- package/lib/web/processJSON.js +1 -3
- package/lib/web/processScript.js +8 -4
- package/lib/wxss/CssSyntaxError.js +29 -0
- package/lib/wxss/Warning.js +22 -0
- package/lib/wxss/index.js +5 -0
- package/lib/wxss/loader.js +233 -131
- package/lib/wxss/options.json +209 -0
- package/lib/wxss/plugins/index.js +5 -0
- package/lib/wxss/plugins/postcss-icss-parser.js +124 -0
- package/lib/wxss/plugins/postcss-import-parser.js +372 -0
- package/lib/wxss/plugins/postcss-url-parser.js +447 -0
- package/lib/wxss/runtime/api.js +104 -0
- package/lib/wxss/runtime/getUrl.js +28 -0
- package/lib/wxss/runtime/noSourceMaps.js +1 -0
- package/lib/wxss/runtime/sourceMaps.js +24 -0
- package/lib/wxss/utils.js +1317 -0
- package/package.json +2 -2
- package/lib/wxss/compile-exports.js +0 -52
- package/lib/wxss/createResolver.js +0 -36
- package/lib/wxss/css-base.js +0 -79
- package/lib/wxss/getLocalIdent.js +0 -24
- package/lib/wxss/localsLoader.js +0 -44
- package/lib/wxss/processCss.js +0 -271
- package/lib/wxss/url/escape.js +0 -16
|
@@ -73,13 +73,20 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
73
73
|
resource = addQuery(resource, { packageRoot }, true)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
const key = resource
|
|
77
|
-
let addEntryPromise
|
|
76
|
+
const key = [resource, filename].join('|')
|
|
78
77
|
|
|
79
78
|
if (alreadyOutputted) {
|
|
80
|
-
addEntryPromise = mpx.addEntryPromiseMap.get(key)
|
|
79
|
+
const addEntryPromise = mpx.addEntryPromiseMap.get(key)
|
|
80
|
+
if (addEntryPromise) {
|
|
81
|
+
addEntryPromise.then(entryModule => {
|
|
82
|
+
// 构建entry依赖图,针对alreadyOutputted的entry也需要记录
|
|
83
|
+
originEntryNode.addChild(mpx.getEntryNode(entryModule, entryType))
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
// alreadyOutputted时直接返回,避免存在模块循环引用时死循环
|
|
87
|
+
return callback(null, { resultPath })
|
|
81
88
|
} else {
|
|
82
|
-
addEntryPromise = new Promise((resolve, reject) => {
|
|
89
|
+
const addEntryPromise = new Promise((resolve, reject) => {
|
|
83
90
|
mpx.addEntry(resource, filename, (err, entryModule) => {
|
|
84
91
|
if (err) return reject(err)
|
|
85
92
|
if (entryType === 'export') {
|
|
@@ -88,15 +95,15 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
88
95
|
resolve(entryModule)
|
|
89
96
|
})
|
|
90
97
|
})
|
|
98
|
+
addEntryPromise
|
|
99
|
+
.then(entryModule => {
|
|
100
|
+
originEntryNode.addChild(mpx.getEntryNode(entryModule, entryType))
|
|
101
|
+
callback(null, { resultPath })
|
|
102
|
+
})
|
|
103
|
+
.catch(err => callback(err))
|
|
104
|
+
|
|
91
105
|
mpx.addEntryPromiseMap.set(key, addEntryPromise)
|
|
92
106
|
}
|
|
93
|
-
|
|
94
|
-
addEntryPromise
|
|
95
|
-
.then(entryModule => {
|
|
96
|
-
if (entryModule) originEntryNode.addChild(mpx.getEntryNode(entryModule, entryType))
|
|
97
|
-
callback(null, { resultPath })
|
|
98
|
-
})
|
|
99
|
-
.catch(err => callback(err))
|
|
100
107
|
}
|
|
101
108
|
], callback)
|
|
102
109
|
}
|
package/lib/extractor.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -44,7 +44,7 @@ const { matchCondition } = require('./utils/match-condition')
|
|
|
44
44
|
const { preProcessDefs } = require('./utils/index')
|
|
45
45
|
const config = require('./config')
|
|
46
46
|
const hash = require('hash-sum')
|
|
47
|
-
const wxssLoaderPath = normalize.lib('wxss/
|
|
47
|
+
const wxssLoaderPath = normalize.lib('wxss/index')
|
|
48
48
|
const wxmlLoaderPath = normalize.lib('wxml/loader')
|
|
49
49
|
const wxsLoaderPath = normalize.lib('wxs/loader')
|
|
50
50
|
const styleCompilerPath = normalize.lib('style-compiler/index')
|
|
@@ -147,7 +147,7 @@ class MpxWebpackPlugin {
|
|
|
147
147
|
options.auditResource = options.auditResource || false
|
|
148
148
|
options.decodeHTMLText = options.decodeHTMLText || false
|
|
149
149
|
options.i18n = options.i18n || null
|
|
150
|
-
options.
|
|
150
|
+
options.checkUsingComponentsRules = options.checkUsingComponentsRules || (options.checkUsingComponents ? { include: () => true } : { exclude: () => true })
|
|
151
151
|
options.reportSize = options.reportSize || null
|
|
152
152
|
options.pathHashMode = options.pathHashMode || 'absolute'
|
|
153
153
|
options.forceDisableBuiltInLoader = options.forceDisableBuiltInLoader || false
|
|
@@ -196,7 +196,7 @@ class MpxWebpackPlugin {
|
|
|
196
196
|
|
|
197
197
|
static wxssLoader (options) {
|
|
198
198
|
return {
|
|
199
|
-
loader: normalize.lib('wxss/
|
|
199
|
+
loader: normalize.lib('wxss/index'),
|
|
200
200
|
options
|
|
201
201
|
}
|
|
202
202
|
}
|
|
@@ -566,7 +566,7 @@ class MpxWebpackPlugin {
|
|
|
566
566
|
tabBarMap: {},
|
|
567
567
|
defs: preProcessDefs(this.options.defs),
|
|
568
568
|
i18n: this.options.i18n,
|
|
569
|
-
|
|
569
|
+
checkUsingComponentsRules: this.options.checkUsingComponentsRules,
|
|
570
570
|
forceDisableBuiltInLoader: this.options.forceDisableBuiltInLoader,
|
|
571
571
|
appTitle: 'Mpx homepage',
|
|
572
572
|
attributes: this.options.attributes,
|
package/lib/loader.js
CHANGED
|
@@ -65,6 +65,10 @@ module.exports = function (content) {
|
|
|
65
65
|
this._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, ctorType, entryName, packageRoot))
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
if (ctorType === 'app') {
|
|
69
|
+
const appName = getEntryName(this)
|
|
70
|
+
this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
|
|
71
|
+
}
|
|
68
72
|
const loaderContext = this
|
|
69
73
|
const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
|
|
70
74
|
const isProduction = this.minimize || process.env.NODE_ENV === 'production'
|
|
@@ -100,6 +104,7 @@ module.exports = function (content) {
|
|
|
100
104
|
const isNative = false
|
|
101
105
|
|
|
102
106
|
let usingComponents = [].concat(Object.keys(mpx.usingComponents))
|
|
107
|
+
let componentPlaceholder = []
|
|
103
108
|
|
|
104
109
|
let componentGenerics = {}
|
|
105
110
|
|
|
@@ -110,6 +115,9 @@ module.exports = function (content) {
|
|
|
110
115
|
fixUsingComponent(ret.usingComponents, mode)
|
|
111
116
|
usingComponents = usingComponents.concat(Object.keys(ret.usingComponents))
|
|
112
117
|
}
|
|
118
|
+
if (ret.componentPlaceholder) {
|
|
119
|
+
componentPlaceholder = componentPlaceholder.concat(Object.values(ret.componentPlaceholder))
|
|
120
|
+
}
|
|
113
121
|
if (ret.componentGenerics) {
|
|
114
122
|
componentGenerics = Object.assign({}, ret.componentGenerics)
|
|
115
123
|
}
|
|
@@ -218,11 +226,6 @@ module.exports = function (content) {
|
|
|
218
226
|
return callback(new Error(`Current ${ctorType} [${this.resourcePath}] is issued by [${issuer.resource}], which is not allowed!`))
|
|
219
227
|
}
|
|
220
228
|
|
|
221
|
-
if (ctorType === 'app') {
|
|
222
|
-
const appName = getEntryName(this)
|
|
223
|
-
this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
|
|
224
|
-
}
|
|
225
|
-
|
|
226
229
|
// 注入模块id及资源路径
|
|
227
230
|
output += `global.currentModuleId = ${JSON.stringify(moduleId)}\n`
|
|
228
231
|
if (!isProduction) {
|
|
@@ -279,7 +282,8 @@ module.exports = function (content) {
|
|
|
279
282
|
hasComment,
|
|
280
283
|
isNative,
|
|
281
284
|
moduleId,
|
|
282
|
-
usingComponents
|
|
285
|
+
usingComponents,
|
|
286
|
+
componentPlaceholder
|
|
283
287
|
// 添加babel处理渲染函数中可能包含的...展开运算符
|
|
284
288
|
// 由于...运算符应用范围极小以及babel成本极高,先关闭此特性后续看情况打开
|
|
285
289
|
// needBabel: true
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module.exports = function (el, binding) {
|
|
2
|
+
const newActions = binding && binding.value && binding.value.actions
|
|
3
|
+
if (el.actions === newActions) {
|
|
4
|
+
Promise.resolve().then(() => {
|
|
5
|
+
Object.assign(el.style, el.lastDynamicStyle)
|
|
6
|
+
})
|
|
7
|
+
return
|
|
8
|
+
}
|
|
9
|
+
el.actions = newActions
|
|
10
|
+
if (typeof el.setAnimation === 'function') {
|
|
11
|
+
el.removeEventListener('transitionend', el.setAnimation, false)
|
|
12
|
+
el.setAnimation = undefined
|
|
13
|
+
}
|
|
14
|
+
el.dynamicStyleQueue = []
|
|
15
|
+
el.lastDynamicStyle = undefined
|
|
16
|
+
if (Array.isArray(newActions) && newActions.length) {
|
|
17
|
+
newActions.forEach((item) => {
|
|
18
|
+
const property = []
|
|
19
|
+
const { animates, option } = item
|
|
20
|
+
// 存储动画需要改变的样式属性
|
|
21
|
+
const dynamicStyle = {
|
|
22
|
+
transform: ''
|
|
23
|
+
}
|
|
24
|
+
animates.forEach((itemAnimation) => {
|
|
25
|
+
switch (itemAnimation.type) {
|
|
26
|
+
case 'style':
|
|
27
|
+
const [key, value] = itemAnimation.args
|
|
28
|
+
dynamicStyle[key] = value
|
|
29
|
+
property.push(key)
|
|
30
|
+
break
|
|
31
|
+
default:
|
|
32
|
+
dynamicStyle.transform += `${itemAnimation.type}(${itemAnimation.args}) `
|
|
33
|
+
if (!property.includes('transform')) {
|
|
34
|
+
property.push('transform')
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
Object.assign(dynamicStyle, {
|
|
39
|
+
transition: `${parseInt(option.duration)}ms ${option.timingFunction} ${parseInt(option.delay)}ms`,
|
|
40
|
+
transitionProperty: `${property}`,
|
|
41
|
+
transformOrigin: option.transformOrigin
|
|
42
|
+
})
|
|
43
|
+
el.dynamicStyleQueue.push(dynamicStyle)
|
|
44
|
+
})
|
|
45
|
+
el.setAnimation = function () {
|
|
46
|
+
if (!el.dynamicStyleQueue.length) {
|
|
47
|
+
el.removeEventListener('transitionend', el.setAnimation, false)
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
const dynamicStyle = el.dynamicStyleQueue.shift()
|
|
51
|
+
Object.assign(el.style, dynamicStyle)
|
|
52
|
+
el.lastDynamicStyle = dynamicStyle
|
|
53
|
+
}
|
|
54
|
+
// 首次动画属性设置
|
|
55
|
+
setTimeout(el.setAnimation, 0)
|
|
56
|
+
// 在transitionend事件内设置动画样式
|
|
57
|
+
el.addEventListener('transitionend', el.setAnimation, false)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
<div class="wheel" v-for="(data, index) in pickerData" :key="index">
|
|
19
19
|
<ul class="wheel-scroll">
|
|
20
20
|
<li
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
v-for="item in data" :key="item"
|
|
22
|
+
class="wheel-item">{{item}}
|
|
23
23
|
</li>
|
|
24
24
|
</ul>
|
|
25
25
|
</div>
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
import { type } from './util'
|
|
40
40
|
import { getCustomEvent } from './getInnerListeners'
|
|
41
41
|
|
|
42
|
-
const startYear =
|
|
42
|
+
const startYear = 1900
|
|
43
43
|
const modeOptions = {
|
|
44
44
|
time: [23, 59],
|
|
45
|
-
date: [
|
|
45
|
+
date: [200, 11, 30]
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
BScroll.use(Wheel)
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
let months = []
|
|
74
74
|
let days = []
|
|
75
75
|
|
|
76
|
-
for (let i = 0; i <=
|
|
76
|
+
for (let i = 0; i <= 200; i++) {
|
|
77
77
|
years.push(`${startYear + i}年`)
|
|
78
78
|
}
|
|
79
79
|
if (fields === 'year') {
|
|
@@ -127,11 +127,17 @@
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
|
-
start:
|
|
131
|
-
|
|
130
|
+
start: {
|
|
131
|
+
type: String,
|
|
132
|
+
default: '1970-01-01'
|
|
133
|
+
},
|
|
134
|
+
end: {
|
|
135
|
+
type: String,
|
|
136
|
+
default: '2100-01-01'
|
|
137
|
+
},
|
|
132
138
|
fields: {
|
|
133
139
|
type: String,
|
|
134
|
-
|
|
140
|
+
default: 'day'
|
|
135
141
|
}
|
|
136
142
|
},
|
|
137
143
|
data () {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { inBrowser } from '../utils/env'
|
|
2
|
+
import transRpxStyle from './transRpxStyle'
|
|
3
|
+
import animation from './animation'
|
|
2
4
|
|
|
3
5
|
export default function processOption (
|
|
4
6
|
option,
|
|
@@ -12,6 +14,7 @@ export default function processOption (
|
|
|
12
14
|
componentGenerics,
|
|
13
15
|
genericsInfo,
|
|
14
16
|
mixin,
|
|
17
|
+
hasApp,
|
|
15
18
|
Vue,
|
|
16
19
|
VueRouter,
|
|
17
20
|
i18n
|
|
@@ -26,108 +29,11 @@ export default function processOption (
|
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
Vue.directive('animation', (el, binding) => {
|
|
29
|
-
|
|
30
|
-
if (el.actions === newActions) {
|
|
31
|
-
Promise.resolve().then(() => {
|
|
32
|
-
Object.assign(el.style, el.lastDynamicStyle)
|
|
33
|
-
})
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
el.actions = newActions
|
|
37
|
-
if (typeof el.setAnimation === 'function') {
|
|
38
|
-
el.removeEventListener('transitionend', el.setAnimation, false)
|
|
39
|
-
el.setAnimation = undefined
|
|
40
|
-
}
|
|
41
|
-
el.dynamicStyleQueue = []
|
|
42
|
-
el.lastDynamicStyle = undefined
|
|
43
|
-
if (Array.isArray(newActions) && newActions.length) {
|
|
44
|
-
newActions.forEach((item) => {
|
|
45
|
-
const property = []
|
|
46
|
-
const { animates, option } = item
|
|
47
|
-
// 存储动画需要改变的样式属性
|
|
48
|
-
const dynamicStyle = {
|
|
49
|
-
transform: ''
|
|
50
|
-
}
|
|
51
|
-
animates.forEach((itemAnimation) => {
|
|
52
|
-
switch (itemAnimation.type) {
|
|
53
|
-
case 'style':
|
|
54
|
-
const [key, value] = itemAnimation.args
|
|
55
|
-
dynamicStyle[key] = value
|
|
56
|
-
property.push(key)
|
|
57
|
-
break
|
|
58
|
-
default:
|
|
59
|
-
dynamicStyle.transform += `${itemAnimation.type}(${itemAnimation.args}) `
|
|
60
|
-
if (!property.includes('transform')) {
|
|
61
|
-
property.push('transform')
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
Object.assign(dynamicStyle, {
|
|
66
|
-
transition: `${parseInt(option.duration)}ms ${option.timingFunction} ${parseInt(option.delay)}ms`,
|
|
67
|
-
transitionProperty: `${property}`,
|
|
68
|
-
transformOrigin: option.transformOrigin
|
|
69
|
-
})
|
|
70
|
-
el.dynamicStyleQueue.push(dynamicStyle)
|
|
71
|
-
})
|
|
72
|
-
el.setAnimation = function () {
|
|
73
|
-
if (!el.dynamicStyleQueue.length) {
|
|
74
|
-
el.removeEventListener('transitionend', el.setAnimation, false)
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
const dynamicStyle = el.dynamicStyleQueue.shift()
|
|
78
|
-
Object.assign(el.style, dynamicStyle)
|
|
79
|
-
el.lastDynamicStyle = dynamicStyle
|
|
80
|
-
}
|
|
81
|
-
// 首次动画属性设置
|
|
82
|
-
setTimeout(el.setAnimation, 0)
|
|
83
|
-
// 在transitionend事件内设置动画样式
|
|
84
|
-
el.addEventListener('transitionend', el.setAnimation, false)
|
|
85
|
-
}
|
|
32
|
+
return animation(el, binding)
|
|
86
33
|
})
|
|
87
34
|
|
|
88
35
|
Vue.filter('transRpxStyle', style => {
|
|
89
|
-
|
|
90
|
-
const rpx2vwRatio = +(100 / 750).toFixed(8)
|
|
91
|
-
return '' + ($1 * rpx2vwRatio) + 'vw'
|
|
92
|
-
}
|
|
93
|
-
const transRpxFn = global.__mpxTransRpxFn || defaultTransRpxFn
|
|
94
|
-
const parsedStyleObj = {}
|
|
95
|
-
const rpxRegExpG = /\b(\d+(\.\d+)?)rpx\b/g
|
|
96
|
-
const parseStyleText = (cssText) => {
|
|
97
|
-
const listDelimiter = /;(?![^(]*\))/g
|
|
98
|
-
const propertyDelimiter = /:(.+)/
|
|
99
|
-
if (typeof cssText === 'string') {
|
|
100
|
-
cssText.split(listDelimiter).forEach((item) => {
|
|
101
|
-
if (item) {
|
|
102
|
-
var tmp = item.split(propertyDelimiter)
|
|
103
|
-
tmp.length > 1 && (parsedStyleObj[tmp[0].trim()] = tmp[1].trim())
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
} else if (typeof cssText === 'object') {
|
|
107
|
-
if (Array.isArray(cssText)) {
|
|
108
|
-
cssText.forEach(cssItem => {
|
|
109
|
-
parseStyleText(cssItem)
|
|
110
|
-
})
|
|
111
|
-
} else {
|
|
112
|
-
Object.assign(parsedStyleObj, cssText)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const transRpxStyleFn = (val) => {
|
|
117
|
-
if (typeof val === 'string' && val.indexOf('rpx') > 0) {
|
|
118
|
-
return val.replace(rpxRegExpG, transRpxFn).replace(/"/g, '')
|
|
119
|
-
}
|
|
120
|
-
return val
|
|
121
|
-
}
|
|
122
|
-
if (style) {
|
|
123
|
-
style.forEach(item => {
|
|
124
|
-
parseStyleText(item)
|
|
125
|
-
for (let key in parsedStyleObj) {
|
|
126
|
-
parsedStyleObj[key] = transRpxStyleFn(parsedStyleObj[key])
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
}
|
|
130
|
-
return parsedStyleObj
|
|
36
|
+
return transRpxStyle(style)
|
|
131
37
|
})
|
|
132
38
|
|
|
133
39
|
const routes = []
|
|
@@ -376,6 +282,10 @@ registered in parent context!`)
|
|
|
376
282
|
if (ctorType === 'page') {
|
|
377
283
|
option.__mpxPageConfig = Object.assign({}, global.__mpxPageConfig, pageConfig)
|
|
378
284
|
}
|
|
285
|
+
if (!hasApp) {
|
|
286
|
+
option.directives = { animation }
|
|
287
|
+
option.filters = { transRpxStyle }
|
|
288
|
+
}
|
|
379
289
|
}
|
|
380
290
|
|
|
381
291
|
if (option.mixins) {
|
|
@@ -387,7 +297,6 @@ registered in parent context!`)
|
|
|
387
297
|
if (outputPath) {
|
|
388
298
|
option.componentPath = '/' + outputPath
|
|
389
299
|
}
|
|
390
|
-
|
|
391
300
|
return option
|
|
392
301
|
}
|
|
393
302
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module.exports = function (style) {
|
|
2
|
+
const defaultTransRpxFn = function (match, $1) {
|
|
3
|
+
const rpx2vwRatio = +(100 / 750).toFixed(8)
|
|
4
|
+
return '' + ($1 * rpx2vwRatio) + 'vw'
|
|
5
|
+
}
|
|
6
|
+
const transRpxFn = global.__mpxTransRpxFn || defaultTransRpxFn
|
|
7
|
+
const parsedStyleObj = {}
|
|
8
|
+
const rpxRegExpG = /\b(\d+(\.\d+)?)rpx\b/g
|
|
9
|
+
const parseStyleText = (cssText) => {
|
|
10
|
+
const listDelimiter = /;(?![^(]*\))/g
|
|
11
|
+
const propertyDelimiter = /:(.+)/
|
|
12
|
+
if (typeof cssText === 'string') {
|
|
13
|
+
cssText.split(listDelimiter).forEach((item) => {
|
|
14
|
+
if (item) {
|
|
15
|
+
var tmp = item.split(propertyDelimiter)
|
|
16
|
+
tmp.length > 1 && (parsedStyleObj[tmp[0].trim()] = tmp[1].trim())
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
} else if (typeof cssText === 'object') {
|
|
20
|
+
if (Array.isArray(cssText)) {
|
|
21
|
+
cssText.forEach(cssItem => {
|
|
22
|
+
parseStyleText(cssItem)
|
|
23
|
+
})
|
|
24
|
+
} else {
|
|
25
|
+
Object.assign(parsedStyleObj, cssText)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const transRpxStyleFn = (val) => {
|
|
30
|
+
if (typeof val === 'string' && val.indexOf('rpx') > 0) {
|
|
31
|
+
return val.replace(rpxRegExpG, transRpxFn).replace(/"/g, '')
|
|
32
|
+
}
|
|
33
|
+
return val
|
|
34
|
+
}
|
|
35
|
+
if (style) {
|
|
36
|
+
style.forEach(item => {
|
|
37
|
+
parseStyleText(item)
|
|
38
|
+
for (let key in parsedStyleObj) {
|
|
39
|
+
parsedStyleObj[key] = transRpxStyleFn(parsedStyleObj[key])
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
return parsedStyleObj
|
|
44
|
+
}
|
|
@@ -835,10 +835,14 @@ function parse (template, options) {
|
|
|
835
835
|
Array.isArray(val.errorArray) && val.errorArray.forEach(item => error$1(item))
|
|
836
836
|
})
|
|
837
837
|
|
|
838
|
-
if (!tagNames.has('component')) {
|
|
838
|
+
if (!tagNames.has('component') && options.checkUsingComponents) {
|
|
839
|
+
const arr = []
|
|
839
840
|
options.usingComponents.forEach((item) => {
|
|
840
|
-
if (!tagNames.has(item) && !options.globalComponents.includes(item) && options.
|
|
841
|
+
if (!tagNames.has(item) && !options.globalComponents.includes(item) && !options.componentPlaceholder.includes(item)) {
|
|
842
|
+
arr.push(item)
|
|
843
|
+
}
|
|
841
844
|
})
|
|
845
|
+
arr.length && warn$1(`\n ${options.filePath} \n 组件 ${arr.join(' | ')} 注册了,但是未被对应的模板引用,建议删除!`)
|
|
842
846
|
}
|
|
843
847
|
|
|
844
848
|
return {
|
|
@@ -21,6 +21,7 @@ module.exports = function (raw) {
|
|
|
21
21
|
const componentsMap = mpx.componentsMap[packageName]
|
|
22
22
|
const wxsContentMap = mpx.wxsContentMap
|
|
23
23
|
const usingComponents = queryObj.usingComponents || []
|
|
24
|
+
const componentPlaceholder = queryObj.componentPlaceholder || []
|
|
24
25
|
const hasComment = queryObj.hasComment
|
|
25
26
|
const isNative = queryObj.isNative
|
|
26
27
|
const hasScoped = queryObj.hasScoped
|
|
@@ -42,6 +43,7 @@ module.exports = function (raw) {
|
|
|
42
43
|
warn,
|
|
43
44
|
error,
|
|
44
45
|
usingComponents,
|
|
46
|
+
componentPlaceholder,
|
|
45
47
|
hasComment,
|
|
46
48
|
isNative,
|
|
47
49
|
isComponent: !!componentsMap[resourcePath],
|
|
@@ -56,7 +58,7 @@ module.exports = function (raw) {
|
|
|
56
58
|
// 这里需传递resourcePath和wxsContentMap保持一致
|
|
57
59
|
filePath: resourcePath,
|
|
58
60
|
i18n,
|
|
59
|
-
checkUsingComponents: mpx.
|
|
61
|
+
checkUsingComponents: matchCondition(resourcePath, mpx.checkUsingComponentsRules),
|
|
60
62
|
globalComponents: Object.keys(mpx.usingComponents),
|
|
61
63
|
forceProxyEvent: matchCondition(resourcePath, mpx.forceProxyEventRules),
|
|
62
64
|
hasVirtualHost: matchCondition(resourcePath, mpx.autoVirtualHostRules)
|
package/lib/web/processJSON.js
CHANGED
|
@@ -263,9 +263,7 @@ module.exports = function (json, {
|
|
|
263
263
|
if (components) {
|
|
264
264
|
async.eachOf(components, (component, name, callback) => {
|
|
265
265
|
processComponent(component, context, {}, (err, { resource, outputPath } = {}) => {
|
|
266
|
-
if (err === RESOLVE_IGNORED_ERR)
|
|
267
|
-
return callback()
|
|
268
|
-
}
|
|
266
|
+
if (err) return callback(err === RESOLVE_IGNORED_ERR ? null : err)
|
|
269
267
|
const { resourcePath, queryObj } = parseRequest(resource)
|
|
270
268
|
componentsMap[resourcePath] = outputPath
|
|
271
269
|
loaderContext._module && loaderContext._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'component', outputPath))
|
package/lib/web/processScript.js
CHANGED
|
@@ -48,9 +48,9 @@ module.exports = function (script, {
|
|
|
48
48
|
const {
|
|
49
49
|
i18n,
|
|
50
50
|
projectRoot,
|
|
51
|
-
webConfig
|
|
51
|
+
webConfig,
|
|
52
|
+
appInfo
|
|
52
53
|
} = loaderContext.getMpx()
|
|
53
|
-
|
|
54
54
|
const { getRequire } = createHelpers(loaderContext)
|
|
55
55
|
const tabBar = jsonConfig.tabBar
|
|
56
56
|
|
|
@@ -153,6 +153,10 @@ module.exports = function (script, {
|
|
|
153
153
|
\n`
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
+
let hasApp = true
|
|
157
|
+
if (!appInfo.name) {
|
|
158
|
+
hasApp = false
|
|
159
|
+
}
|
|
156
160
|
// 注入wxs模块
|
|
157
161
|
content += ' const wxsModules = {}\n'
|
|
158
162
|
if (wxsModuleMap) {
|
|
@@ -238,7 +242,6 @@ module.exports = function (script, {
|
|
|
238
242
|
// @ts-ignore
|
|
239
243
|
global.__tabBarPagesMap = ${shallowStringify(tabBarPagesMap)}\n`
|
|
240
244
|
}
|
|
241
|
-
|
|
242
245
|
// 配置平台转换通过createFactory在core中convertor中定义和进行
|
|
243
246
|
// 通过processOption进行组件注册和路由注入
|
|
244
247
|
content += ` export default processOption(
|
|
@@ -254,7 +257,8 @@ module.exports = function (script, {
|
|
|
254
257
|
${JSON.stringify(tabBarMap)},
|
|
255
258
|
${JSON.stringify(componentGenerics)},
|
|
256
259
|
${JSON.stringify(genericsInfo)},
|
|
257
|
-
getWxsMixin(wxsModules)
|
|
260
|
+
getWxsMixin(wxsModules),
|
|
261
|
+
${hasApp}`
|
|
258
262
|
if (ctorType === 'app') {
|
|
259
263
|
content += `,
|
|
260
264
|
Vue,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module.exports = class CssSyntaxError extends Error {
|
|
2
|
+
constructor (error) {
|
|
3
|
+
super(error)
|
|
4
|
+
|
|
5
|
+
const { reason, line, column, file } = error
|
|
6
|
+
|
|
7
|
+
this.name = 'CssSyntaxError'
|
|
8
|
+
|
|
9
|
+
// Based on https://github.com/postcss/postcss/blob/master/lib/css-syntax-error.es6#L132
|
|
10
|
+
// We don't need `plugin` and `file` properties.
|
|
11
|
+
this.message = `${this.name}\n\n`
|
|
12
|
+
|
|
13
|
+
if (typeof line !== 'undefined') {
|
|
14
|
+
this.message += `(${line}:${column}) `
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
this.message += file ? `${file} ` : '<css input> '
|
|
18
|
+
this.message += `${reason}`
|
|
19
|
+
|
|
20
|
+
const code = error.showSourceCode()
|
|
21
|
+
|
|
22
|
+
if (code) {
|
|
23
|
+
this.message += `\n\n${code}\n`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
|
|
27
|
+
this.stack = false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module.exports = class Warning extends Error {
|
|
2
|
+
constructor (warning) {
|
|
3
|
+
super(warning)
|
|
4
|
+
|
|
5
|
+
const { text, line, column } = warning
|
|
6
|
+
|
|
7
|
+
this.name = 'Warning'
|
|
8
|
+
|
|
9
|
+
// Based on https://github.com/postcss/postcss/blob/master/lib/warning.es6#L74
|
|
10
|
+
// We don't need `plugin` properties.
|
|
11
|
+
this.message = `${this.name}\n\n`
|
|
12
|
+
|
|
13
|
+
if (typeof line !== 'undefined') {
|
|
14
|
+
this.message += `(${line}:${column}) `
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
this.message += `${text}`
|
|
18
|
+
|
|
19
|
+
// We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
|
|
20
|
+
this.stack = false
|
|
21
|
+
}
|
|
22
|
+
}
|