@mpxjs/webpack-plugin 2.8.1 → 2.8.6
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/index.js +2 -2
- package/lib/json-compiler/index.js +1 -1
- package/lib/loader.js +5 -6
- package/lib/native-loader.js +1 -1
- package/lib/resolver/FixDescriptionInfoPlugin.js +1 -0
- package/lib/runtime/animation.js +60 -0
- package/lib/runtime/optionProcessor.js +9 -101
- package/lib/runtime/transRpxStyle.js +44 -0
- package/lib/script-setup-compiler/index.js +1 -1
- package/lib/utils/get-json-content.js +7 -3
- package/lib/web/processJSON.js +2 -4
- 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 +234 -132
- 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 +25 -0
- package/lib/wxss/utils.js +1312 -0
- package/package.json +2 -2
- package/lib/wxss/url/escape.js +0 -16
package/lib/index.js
CHANGED
|
@@ -45,7 +45,7 @@ const { matchCondition } = require('./utils/match-condition')
|
|
|
45
45
|
const processDefs = require('./utils/process-defs')
|
|
46
46
|
const config = require('./config')
|
|
47
47
|
const hash = require('hash-sum')
|
|
48
|
-
const wxssLoaderPath = normalize.lib('wxss/
|
|
48
|
+
const wxssLoaderPath = normalize.lib('wxss/index')
|
|
49
49
|
const wxmlLoaderPath = normalize.lib('wxml/loader')
|
|
50
50
|
const wxsLoaderPath = normalize.lib('wxs/loader')
|
|
51
51
|
const styleCompilerPath = normalize.lib('style-compiler/index')
|
|
@@ -197,7 +197,7 @@ class MpxWebpackPlugin {
|
|
|
197
197
|
|
|
198
198
|
static wxssLoader (options) {
|
|
199
199
|
return {
|
|
200
|
-
loader: normalize.lib('wxss/
|
|
200
|
+
loader: normalize.lib('wxss/index'),
|
|
201
201
|
options
|
|
202
202
|
}
|
|
203
203
|
}
|
|
@@ -274,7 +274,7 @@ module.exports = function (content) {
|
|
|
274
274
|
})
|
|
275
275
|
// 对于通过.mpx文件声明的独立分包,默认将其自身的script block视为init module
|
|
276
276
|
if (queryObj.independent === true) queryObj.independent = result
|
|
277
|
-
getJSONContent(parts.json || {}, this, (err, content) => {
|
|
277
|
+
getJSONContent(parts.json || {}, result, this, (err, content) => {
|
|
278
278
|
callback(err, result, content)
|
|
279
279
|
})
|
|
280
280
|
} else {
|
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'
|
|
@@ -87,7 +91,7 @@ module.exports = function (content) {
|
|
|
87
91
|
|
|
88
92
|
async.waterfall([
|
|
89
93
|
(callback) => {
|
|
90
|
-
getJSONContent(parts.json || {}, loaderContext, (err, content) => {
|
|
94
|
+
getJSONContent(parts.json || {}, null, loaderContext, (err, content) => {
|
|
91
95
|
if (err) return callback(err)
|
|
92
96
|
if (parts.json) parts.json.content = content
|
|
93
97
|
callback()
|
|
@@ -221,11 +225,6 @@ module.exports = function (content) {
|
|
|
221
225
|
return callback(new Error(`Current ${ctorType} [${this.resourcePath}] is issued by [${issuer.resource}], which is not allowed!`))
|
|
222
226
|
}
|
|
223
227
|
|
|
224
|
-
if (ctorType === 'app') {
|
|
225
|
-
const appName = getEntryName(this)
|
|
226
|
-
this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
|
|
227
|
-
}
|
|
228
|
-
|
|
229
228
|
// 注入模块id及资源路径
|
|
230
229
|
output += `global.currentModuleId = ${JSON.stringify(moduleId)}\n`
|
|
231
230
|
if (!isProduction) {
|
package/lib/native-loader.js
CHANGED
|
@@ -4,6 +4,7 @@ module.exports = class FixDescriptionInfoPlugin {
|
|
|
4
4
|
apply (resolver) {
|
|
5
5
|
resolver.hooks.result.tap('FixDescriptionInfoPlugin', (request) => {
|
|
6
6
|
const { path: resourcePath } = request
|
|
7
|
+
if (!resourcePath) return
|
|
7
8
|
const segments = resourcePath.split(path.sep)
|
|
8
9
|
let rootIndex = -1
|
|
9
10
|
for (let i = segments.length - 1; i >= 0; i--) {
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
}
|
|
32
|
+
default:
|
|
33
|
+
dynamicStyle.transform += `${itemAnimation.type}(${itemAnimation.args}) `
|
|
34
|
+
if (!property.includes('transform')) {
|
|
35
|
+
property.push('transform')
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
Object.assign(dynamicStyle, {
|
|
40
|
+
transition: `${parseInt(option.duration)}ms ${option.timingFunction} ${parseInt(option.delay)}ms`,
|
|
41
|
+
transitionProperty: `${property}`,
|
|
42
|
+
transformOrigin: option.transformOrigin
|
|
43
|
+
})
|
|
44
|
+
el.dynamicStyleQueue.push(dynamicStyle)
|
|
45
|
+
})
|
|
46
|
+
el.setAnimation = function () {
|
|
47
|
+
if (!el.dynamicStyleQueue.length) {
|
|
48
|
+
el.removeEventListener('transitionend', el.setAnimation, false)
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
const dynamicStyle = el.dynamicStyleQueue.shift()
|
|
52
|
+
Object.assign(el.style, dynamicStyle)
|
|
53
|
+
el.lastDynamicStyle = dynamicStyle
|
|
54
|
+
}
|
|
55
|
+
// 首次动画属性设置
|
|
56
|
+
setTimeout(el.setAnimation, 0)
|
|
57
|
+
// 在transitionend事件内设置动画样式
|
|
58
|
+
el.addEventListener('transitionend', el.setAnimation, false)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { isBrowser } from './env'
|
|
2
2
|
import { hasOwn } from './utils'
|
|
3
|
+
import transRpxStyle from './transRpxStyle'
|
|
4
|
+
import animation from './animation'
|
|
3
5
|
|
|
4
6
|
export default function processOption (
|
|
5
7
|
option,
|
|
@@ -13,6 +15,7 @@ export default function processOption (
|
|
|
13
15
|
componentGenerics,
|
|
14
16
|
genericsInfo,
|
|
15
17
|
mixin,
|
|
18
|
+
hasApp,
|
|
16
19
|
Vue,
|
|
17
20
|
VueRouter
|
|
18
21
|
) {
|
|
@@ -26,109 +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
|
-
}
|
|
59
|
-
default:
|
|
60
|
-
dynamicStyle.transform += `${itemAnimation.type}(${itemAnimation.args}) `
|
|
61
|
-
if (!property.includes('transform')) {
|
|
62
|
-
property.push('transform')
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
Object.assign(dynamicStyle, {
|
|
67
|
-
transition: `${parseInt(option.duration)}ms ${option.timingFunction} ${parseInt(option.delay)}ms`,
|
|
68
|
-
transitionProperty: `${property}`,
|
|
69
|
-
transformOrigin: option.transformOrigin
|
|
70
|
-
})
|
|
71
|
-
el.dynamicStyleQueue.push(dynamicStyle)
|
|
72
|
-
})
|
|
73
|
-
el.setAnimation = function () {
|
|
74
|
-
if (!el.dynamicStyleQueue.length) {
|
|
75
|
-
el.removeEventListener('transitionend', el.setAnimation, false)
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
const dynamicStyle = el.dynamicStyleQueue.shift()
|
|
79
|
-
Object.assign(el.style, dynamicStyle)
|
|
80
|
-
el.lastDynamicStyle = dynamicStyle
|
|
81
|
-
}
|
|
82
|
-
// 首次动画属性设置
|
|
83
|
-
setTimeout(el.setAnimation, 0)
|
|
84
|
-
// 在transitionend事件内设置动画样式
|
|
85
|
-
el.addEventListener('transitionend', el.setAnimation, false)
|
|
86
|
-
}
|
|
32
|
+
return animation(el, binding)
|
|
87
33
|
})
|
|
88
34
|
|
|
89
35
|
Vue.filter('transRpxStyle', style => {
|
|
90
|
-
|
|
91
|
-
const rpx2vwRatio = +(100 / 750).toFixed(8)
|
|
92
|
-
return '' + ($1 * rpx2vwRatio) + 'vw'
|
|
93
|
-
}
|
|
94
|
-
const transRpxFn = global.__mpxTransRpxFn || defaultTransRpxFn
|
|
95
|
-
const parsedStyleObj = {}
|
|
96
|
-
const rpxRegExpG = /\b(\d+(\.\d+)?)rpx\b/g
|
|
97
|
-
const parseStyleText = (cssText) => {
|
|
98
|
-
const listDelimiter = /;(?![^(]*\))/g
|
|
99
|
-
const propertyDelimiter = /:(.+)/
|
|
100
|
-
if (typeof cssText === 'string') {
|
|
101
|
-
cssText.split(listDelimiter).forEach((item) => {
|
|
102
|
-
if (item) {
|
|
103
|
-
const tmp = item.split(propertyDelimiter)
|
|
104
|
-
tmp.length > 1 && (parsedStyleObj[tmp[0].trim()] = tmp[1].trim())
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
} else if (typeof cssText === 'object') {
|
|
108
|
-
if (Array.isArray(cssText)) {
|
|
109
|
-
cssText.forEach(cssItem => {
|
|
110
|
-
parseStyleText(cssItem)
|
|
111
|
-
})
|
|
112
|
-
} else {
|
|
113
|
-
Object.assign(parsedStyleObj, cssText)
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
const transRpxStyleFn = (val) => {
|
|
118
|
-
if (typeof val === 'string' && val.indexOf('rpx') > 0) {
|
|
119
|
-
return val.replace(rpxRegExpG, transRpxFn).replace(/"/g, '')
|
|
120
|
-
}
|
|
121
|
-
return val
|
|
122
|
-
}
|
|
123
|
-
if (style) {
|
|
124
|
-
style.forEach(item => {
|
|
125
|
-
parseStyleText(item)
|
|
126
|
-
for (const key in parsedStyleObj) {
|
|
127
|
-
parsedStyleObj[key] = transRpxStyleFn(parsedStyleObj[key])
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
return parsedStyleObj
|
|
36
|
+
return transRpxStyle(style)
|
|
132
37
|
})
|
|
133
38
|
|
|
134
39
|
const routes = []
|
|
@@ -378,6 +283,10 @@ registered in parent context!`)
|
|
|
378
283
|
if (ctorType === 'page') {
|
|
379
284
|
option.__mpxPageConfig = Object.assign({}, global.__mpxPageConfig, pageConfig)
|
|
380
285
|
}
|
|
286
|
+
if (!hasApp) {
|
|
287
|
+
option.directives = { animation }
|
|
288
|
+
option.filters = { transRpxStyle }
|
|
289
|
+
}
|
|
381
290
|
}
|
|
382
291
|
|
|
383
292
|
if (option.mixins) {
|
|
@@ -389,7 +298,6 @@ registered in parent context!`)
|
|
|
389
298
|
if (outputPath) {
|
|
390
299
|
option.componentPath = '/' + outputPath
|
|
391
300
|
}
|
|
392
|
-
|
|
393
301
|
return option
|
|
394
302
|
}
|
|
395
303
|
|
|
@@ -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
|
+
const 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 (const key in parsedStyleObj) {
|
|
39
|
+
parsedStyleObj[key] = transRpxStyleFn(parsedStyleObj[key])
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
return parsedStyleObj
|
|
44
|
+
}
|
|
@@ -361,7 +361,7 @@ function compileScriptSetup (
|
|
|
361
361
|
if (node.trailingComments && node.trailingComments.length > 0) {
|
|
362
362
|
const lastCommentNode =
|
|
363
363
|
node.trailingComments[node.trailingComments.length - 1]
|
|
364
|
-
end = lastCommentNode.end
|
|
364
|
+
end = lastCommentNode.end
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
// locate the end of whitespace between this statement and the next
|
|
@@ -3,14 +3,18 @@ const evalJSONJS = require('./eval-json-js')
|
|
|
3
3
|
const resolve = require('./resolve')
|
|
4
4
|
const async = require('async')
|
|
5
5
|
const { JSON_JS_EXT } = require('./const')
|
|
6
|
+
const path = require('path')
|
|
6
7
|
|
|
7
|
-
module.exports = function getJSONContent (json, loaderContext, callback) {
|
|
8
|
+
module.exports = function getJSONContent (json, filename, loaderContext, callback) {
|
|
8
9
|
if (!loaderContext._compiler) return callback(null, '{}')
|
|
9
10
|
const fs = loaderContext._compiler.inputFileSystem
|
|
11
|
+
filename = filename || loaderContext.resourcePath
|
|
12
|
+
const context = path.dirname(filename)
|
|
13
|
+
|
|
10
14
|
async.waterfall([
|
|
11
15
|
(callback) => {
|
|
12
16
|
if (json.src) {
|
|
13
|
-
resolve(
|
|
17
|
+
resolve(context, json.src, loaderContext, (err, result) => {
|
|
14
18
|
if (err) return callback(err)
|
|
15
19
|
const { rawResourcePath: resourcePath } = parseRequest(result)
|
|
16
20
|
fs.readFile(resourcePath, (err, content) => {
|
|
@@ -27,7 +31,7 @@ module.exports = function getJSONContent (json, loaderContext, callback) {
|
|
|
27
31
|
callback(null, {
|
|
28
32
|
content: json.content,
|
|
29
33
|
useJSONJS: json.useJSONJS,
|
|
30
|
-
filename
|
|
34
|
+
filename
|
|
31
35
|
})
|
|
32
36
|
}
|
|
33
37
|
},
|
package/lib/web/processJSON.js
CHANGED
|
@@ -139,7 +139,7 @@ module.exports = function (json, {
|
|
|
139
139
|
mode,
|
|
140
140
|
env
|
|
141
141
|
})
|
|
142
|
-
getJSONContent(parts.json || {}, loaderContext, (err, content) => {
|
|
142
|
+
getJSONContent(parts.json || {}, result, loaderContext, (err, content) => {
|
|
143
143
|
callback(err, result, content)
|
|
144
144
|
})
|
|
145
145
|
} else {
|
|
@@ -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
|
@@ -49,9 +49,9 @@ module.exports = function (script, {
|
|
|
49
49
|
const {
|
|
50
50
|
i18n,
|
|
51
51
|
projectRoot,
|
|
52
|
-
webConfig
|
|
52
|
+
webConfig,
|
|
53
|
+
appInfo
|
|
53
54
|
} = loaderContext.getMpx()
|
|
54
|
-
|
|
55
55
|
const { getRequire } = createHelpers(loaderContext)
|
|
56
56
|
const tabBar = jsonConfig.tabBar
|
|
57
57
|
|
|
@@ -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) {
|
|
@@ -239,7 +243,6 @@ module.exports = function (script, {
|
|
|
239
243
|
// @ts-ignore
|
|
240
244
|
global.__tabBarPagesMap = ${shallowStringify(tabBarPagesMap)}\n`
|
|
241
245
|
}
|
|
242
|
-
|
|
243
246
|
// 配置平台转换通过createFactory在core中convertor中定义和进行
|
|
244
247
|
// 通过processOption进行组件注册和路由注入
|
|
245
248
|
content += ` export default processOption(
|
|
@@ -255,7 +258,8 @@ module.exports = function (script, {
|
|
|
255
258
|
${JSON.stringify(tabBarMap)},
|
|
256
259
|
${JSON.stringify(componentGenerics)},
|
|
257
260
|
${JSON.stringify(genericsInfo)},
|
|
258
|
-
getWxsMixin(wxsModules)
|
|
261
|
+
getWxsMixin(wxsModules),
|
|
262
|
+
${hasApp}`
|
|
259
263
|
if (ctorType === 'app') {
|
|
260
264
|
content += `,
|
|
261
265
|
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
|
+
}
|