@mpxjs/webpack-plugin 2.7.0-beta.5 → 2.7.0-beta.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.
@@ -1,28 +1,32 @@
1
1
  const NullDependency = require('webpack/lib/dependencies/NullDependency')
2
2
  const makeSerializable = require('webpack/lib/util/makeSerializable')
3
3
 
4
- class RecordStaticResourceDependency extends NullDependency {
5
- constructor (resourcePath, outputPath, packageRoot = '') {
4
+ class RecordResourceMapDependency extends NullDependency {
5
+ constructor (resourcePath, resourceType, outputPath, packageRoot = '') {
6
6
  super()
7
7
  this.resourcePath = resourcePath
8
+ this.resourceType = resourceType
8
9
  this.outputPath = outputPath
9
10
  this.packageRoot = packageRoot
10
11
  }
11
12
 
12
13
  get type () {
13
- return 'mpx record static resource'
14
+ return 'mpx record resource map'
14
15
  }
15
16
 
16
17
  mpxAction (module, compilation, callback) {
17
18
  const mpx = compilation.__mpx__
18
19
  const packageName = this.packageRoot || 'main'
19
- mpx.staticResourcesMap[packageName][this.resourcePath] = this.outputPath
20
+ const resourceMap = mpx[`${this.resourceType}sMap`] || mpx.otherResourcesMap
21
+ const subResourceMap = resourceMap.main ? resourceMap[packageName] : resourceMap
22
+ subResourceMap[this.resourcePath] = this.outputPath
20
23
  return callback()
21
24
  }
22
25
 
23
26
  serialize (context) {
24
27
  const { write } = context
25
28
  write(this.resourcePath)
29
+ write(this.resourceType)
26
30
  write(this.outputPath)
27
31
  write(this.packageRoot)
28
32
  super.serialize(context)
@@ -31,17 +35,18 @@ class RecordStaticResourceDependency extends NullDependency {
31
35
  deserialize (context) {
32
36
  const { read } = context
33
37
  this.resourcePath = read()
38
+ this.resourceType = read()
34
39
  this.outputPath = read()
35
40
  this.packageRoot = read()
36
41
  super.deserialize(context)
37
42
  }
38
43
  }
39
44
 
40
- RecordStaticResourceDependency.Template = class RecordStaticResourceDependencyTemplate {
45
+ RecordResourceMapDependency.Template = class RecordResourceMapDependencyTemplate {
41
46
  apply () {
42
47
  }
43
48
  }
44
49
 
45
- makeSerializable(RecordStaticResourceDependency, '@mpxjs/webpack-plugin/lib/dependencies/RecordStaticResourceDependency')
50
+ makeSerializable(RecordResourceMapDependency, '@mpxjs/webpack-plugin/lib/dependencies/RecordResourceMapDependency')
46
51
 
47
- module.exports = RecordStaticResourceDependency
52
+ module.exports = RecordResourceMapDependency
@@ -37,8 +37,13 @@ class ResolveDependency extends NullDependency {
37
37
 
38
38
  // resolved可能会动态变更,需用此更新hash
39
39
  updateHash (hash, context) {
40
- const resolved = this.getResolved()
41
- if (resolved) hash.update(resolved)
40
+ this.resolved = this.getResolved()
41
+ const { resource, issuerResource, compilation } = this
42
+ if (this.resolved) {
43
+ hash.update(this.resolved)
44
+ } else {
45
+ compilation.errors.push(new Error(`Path ${resource} is not a page/component/static resource, which is resolved from ${issuerResource}!`))
46
+ }
42
47
  super.updateHash(hash, context)
43
48
  }
44
49
 
@@ -68,12 +73,8 @@ ResolveDependency.Template = class ResolveDependencyTemplate {
68
73
  }
69
74
 
70
75
  getContent (dep) {
71
- const { resource, issuerResource, compilation } = dep
76
+ const { resolved = '', compilation } = dep
72
77
  const publicPath = compilation.outputOptions.publicPath || ''
73
- const resolved = dep.getResolved()
74
- if (!resolved) {
75
- compilation.errors.push(new Error(`Path ${resource} is not a page/component/static resource, which is resolved from ${issuerResource}!`))
76
- }
77
78
  return JSON.stringify(publicPath + resolved)
78
79
  }
79
80
  }
package/lib/extractor.js CHANGED
@@ -3,9 +3,9 @@ const loaderUtils = require('loader-utils')
3
3
  const parseRequest = require('./utils/parse-request')
4
4
  const toPosix = require('./utils/to-posix')
5
5
  const fixRelative = require('./utils/fix-relative')
6
- const normalize = require('./utils/normalize')
7
6
  const addQuery = require('./utils/add-query')
8
7
  const { MPX_DISABLE_EXTRACTOR_CACHE, DEFAULT_RESULT_SOURCE } = require('./utils/const')
8
+ const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
9
9
 
10
10
  module.exports = content => content
11
11
 
@@ -37,10 +37,10 @@ module.exports.pitch = async function (remainingRequest) {
37
37
  })
38
38
 
39
39
  let request = remainingRequest
40
- // static的情况下需要添加recordLoader记录相关静态资源的输出路径
40
+ // static的情况下需要记录相关静态资源的输出路径
41
41
  if (isStatic) {
42
- const recordLoader = normalize.lib('record-loader')
43
- request = `${recordLoader}!${remainingRequest}`
42
+ const packageRoot = queryObj.packageRoot || ''
43
+ this._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'staticResource', file, packageRoot))
44
44
  }
45
45
 
46
46
  let content = await this.importModule(`!!${request}`)
@@ -2,7 +2,7 @@ const path = require('path')
2
2
  const loaderUtils = require('loader-utils')
3
3
  const toPosix = require('./utils/to-posix')
4
4
  const parseRequest = require('./utils/parse-request')
5
- const RecordStaticResourceDependency = require('./dependencies/RecordStaticResourceDependency')
5
+ const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
6
6
 
7
7
  module.exports = function loader (content, prevOptions) {
8
8
  const options = prevOptions || loaderUtils.getOptions(this) || {}
@@ -28,7 +28,7 @@ module.exports = function loader (content, prevOptions) {
28
28
  const { resourcePath, queryObj } = parseRequest(this.resource)
29
29
  const packageRoot = queryObj.packageRoot || ''
30
30
  url = outputPath = toPosix(path.join(packageRoot, outputPath))
31
- this._module.addPresentationalDependency(new RecordStaticResourceDependency(resourcePath, outputPath, packageRoot))
31
+ this._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'staticResource', outputPath, packageRoot))
32
32
  }
33
33
 
34
34
  let publicPath = `__webpack_public_path__ + ${JSON.stringify(url)}`
package/lib/index.js CHANGED
@@ -24,7 +24,7 @@ const PackageEntryPlugin = require('./resolver/PackageEntryPlugin')
24
24
  // const RequireHeaderDependency = require('webpack/lib/dependencies/RequireHeaderDependency')
25
25
  // const RemovedModuleDependency = require('./dependencies/RemovedModuleDependency')
26
26
  const AppEntryDependency = require('./dependencies/AppEntryDependency')
27
- const RecordStaticResourceDependency = require('./dependencies/RecordStaticResourceDependency')
27
+ const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
28
28
  const RecordGlobalComponentsDependency = require('./dependencies/RecordGlobalComponentsDependency')
29
29
  const DynamicEntryDependency = require('./dependencies/DynamicEntryDependency')
30
30
  const FlagPluginDependency = require('./dependencies/FlagPluginDependency')
@@ -416,8 +416,8 @@ class MpxWebpackPlugin {
416
416
  compilation.dependencyFactories.set(RemoveEntryDependency, new NullFactory())
417
417
  compilation.dependencyTemplates.set(RemoveEntryDependency, new RemoveEntryDependency.Template())
418
418
 
419
- compilation.dependencyFactories.set(RecordStaticResourceDependency, new NullFactory())
420
- compilation.dependencyTemplates.set(RecordStaticResourceDependency, new RecordStaticResourceDependency.Template())
419
+ compilation.dependencyFactories.set(RecordResourceMapDependency, new NullFactory())
420
+ compilation.dependencyTemplates.set(RecordResourceMapDependency, new RecordResourceMapDependency.Template())
421
421
 
422
422
  compilation.dependencyFactories.set(RecordGlobalComponentsDependency, new NullFactory())
423
423
  compilation.dependencyTemplates.set(RecordGlobalComponentsDependency, new RecordGlobalComponentsDependency.Template())
@@ -627,8 +627,9 @@ class MpxWebpackPlugin {
627
627
  async.forEach(presentationalDependencies.filter((dep) => dep.mpxAction), (dep, callback) => {
628
628
  dep.mpxAction(module, compilation, callback)
629
629
  }, (err) => {
630
- if (err) return callback(err)
631
- rawProcessModuleDependencies.call(compilation, module, callback)
630
+ rawProcessModuleDependencies.call(compilation, module, (innerErr) => {
631
+ return callback(err || innerErr)
632
+ })
632
633
  })
633
634
  }
634
635
 
@@ -701,17 +702,6 @@ class MpxWebpackPlugin {
701
702
  }
702
703
  })
703
704
 
704
- // todo 统一通过dep+mpx actions处理
705
- compilation.hooks.stillValidModule.tap('MpxWebpackPlugin', (module) => {
706
- const buildInfo = module.buildInfo
707
- if (buildInfo.pagesMap) {
708
- Object.assign(mpx.pagesMap, buildInfo.pagesMap)
709
- }
710
- if (buildInfo.componentsMap && buildInfo.packageName) {
711
- Object.assign(mpx.componentsMap[buildInfo.packageName], buildInfo.componentsMap)
712
- }
713
- })
714
-
715
705
  compilation.hooks.finishModules.tap('MpxWebpackPlugin', (modules) => {
716
706
  // 自动跟进分包配置修改splitChunksPlugin配置
717
707
  if (splitChunksPlugin) {
@@ -1158,7 +1148,7 @@ try {
1158
1148
  if (loader.loader.includes(info[0])) {
1159
1149
  loader.loader = info[1]
1160
1150
  }
1161
- if (loader.loader === info[1]) {
1151
+ if (loader.loader.includes(info[1])) {
1162
1152
  insertBeforeIndex = index
1163
1153
  }
1164
1154
  })
@@ -1193,41 +1183,43 @@ try {
1193
1183
  loader: extractorPath
1194
1184
  })
1195
1185
  }
1196
-
1197
1186
  createData.resource = addQuery(createData.resource, { mpx: MPX_PROCESSED_FLAG }, true)
1198
- createData.request = stringifyLoadersAndResource(loaders, createData.resource)
1199
1187
  }
1200
1188
 
1201
- // const mpxStyleOptions = queryObj.mpxStyleOptions
1202
- // const firstLoader = (data.loaders[0] && data.loaders[0].loader) || ''
1203
- // const isPitcherRequest = firstLoader.includes('vue-loader/lib/loaders/pitcher.js')
1204
- // let cssLoaderIndex = -1
1205
- // let vueStyleLoaderIndex = -1
1206
- // let mpxStyleLoaderIndex = -1
1207
- // data.loaders.forEach((loader, index) => {
1208
- // const currentLoader = loader.loader
1209
- // if (currentLoader.includes('css-loader')) {
1210
- // cssLoaderIndex = index
1211
- // } else if (currentLoader.includes('vue-loader/lib/loaders/stylePostLoader.js')) {
1212
- // vueStyleLoaderIndex = index
1213
- // } else if (currentLoader.includes('@mpxjs/webpack-plugin/lib/style-compiler/index.js')) {
1214
- // mpxStyleLoaderIndex = index
1215
- // }
1216
- // })
1217
- // if (mpxStyleLoaderIndex === -1) {
1218
- // let loaderIndex = -1
1219
- // if (cssLoaderIndex > -1 && vueStyleLoaderIndex === -1) {
1220
- // loaderIndex = cssLoaderIndex
1221
- // } else if (cssLoaderIndex > -1 && vueStyleLoaderIndex > -1 && !isPitcherRequest) {
1222
- // loaderIndex = vueStyleLoaderIndex
1223
- // }
1224
- // if (loaderIndex > -1) {
1225
- // data.loaders.splice(loaderIndex + 1, 0, {
1226
- // loader: normalize.lib('style-compiler/index.js'),
1227
- // options: (mpxStyleOptions && JSON.parse(mpxStyleOptions)) || {}
1228
- // })
1229
- // }
1230
- // }
1189
+ if (mpx.mode === 'web') {
1190
+ const mpxStyleOptions = queryObj.mpxStyleOptions
1191
+ const firstLoader = (loaders[0] && loaders[0].loader) || ''
1192
+ const isPitcherRequest = firstLoader.includes('vue-loader/lib/loaders/pitcher')
1193
+ let cssLoaderIndex = -1
1194
+ let vueStyleLoaderIndex = -1
1195
+ let mpxStyleLoaderIndex = -1
1196
+ loaders.forEach((loader, index) => {
1197
+ const currentLoader = loader.loader
1198
+ if (currentLoader.includes('css-loader')) {
1199
+ cssLoaderIndex = index
1200
+ } else if (currentLoader.includes('vue-loader/lib/loaders/stylePostLoader')) {
1201
+ vueStyleLoaderIndex = index
1202
+ } else if (currentLoader.includes(styleCompilerPath)) {
1203
+ mpxStyleLoaderIndex = index
1204
+ }
1205
+ })
1206
+ if (mpxStyleLoaderIndex === -1) {
1207
+ let loaderIndex = -1
1208
+ if (cssLoaderIndex > -1 && vueStyleLoaderIndex === -1) {
1209
+ loaderIndex = cssLoaderIndex
1210
+ } else if (cssLoaderIndex > -1 && vueStyleLoaderIndex > -1 && !isPitcherRequest) {
1211
+ loaderIndex = vueStyleLoaderIndex
1212
+ }
1213
+ if (loaderIndex > -1) {
1214
+ loaders.splice(loaderIndex + 1, 0, {
1215
+ loader: styleCompilerPath,
1216
+ options: (mpxStyleOptions && JSON.parse(mpxStyleOptions)) || {}
1217
+ })
1218
+ }
1219
+ }
1220
+ }
1221
+
1222
+ createData.request = stringifyLoadersAndResource(loaders, createData.resource)
1231
1223
  // 根据用户传入的modeRules对特定资源添加mode query
1232
1224
  this.runModeRules(createData)
1233
1225
  })
@@ -6,7 +6,7 @@ const parseRequest = require('../utils/parse-request')
6
6
  const loaderUtils = require('loader-utils')
7
7
  const resolve = require('../utils/resolve')
8
8
 
9
- module.exports = function createJSONHelper ({ loaderContext, emitWarning }) {
9
+ module.exports = function createJSONHelper ({ loaderContext, emitWarning, customGetDynamicEntry }) {
10
10
  const mpx = loaderContext.getMpx()
11
11
  const resolveMode = mpx.resolveMode
12
12
  const externals = mpx.externals
@@ -23,6 +23,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning }) {
23
23
  let dynamicEntryCount = 0
24
24
 
25
25
  const getDynamicEntry = (resource, type, outputPath = '', packageRoot = '', relativePath = '') => {
26
+ if (typeof customGetDynamicEntry === 'function') return customGetDynamicEntry(resource, type, outputPath, packageRoot, relativePath)
26
27
  const key = `mpx_dynamic_entry_${dynamicEntryCount++}`
27
28
  const value = `__mpx_dynamic_entry__( ${JSON.stringify(resource)},${JSON.stringify(type)},${JSON.stringify(outputPath)},${JSON.stringify(packageRoot)},${JSON.stringify(relativePath)})`
28
29
  dynamicEntryMap.set(key, value)
@@ -217,14 +217,6 @@ module.exports = function (content) {
217
217
  const localPages = []
218
218
  const subPackagesCfg = {}
219
219
  const pageKeySet = new Set()
220
- // 添加首页标识
221
- if (json.pages && json.pages[0]) {
222
- if (typeof json.pages[0] !== 'string') {
223
- json.pages[0].src = addQuery(json.pages[0].src, { isFirst: true })
224
- } else {
225
- json.pages[0] = addQuery(json.pages[0], { isFirst: true })
226
- }
227
- }
228
220
 
229
221
  const processPages = (pages, context, tarRoot = '', callback) => {
230
222
  if (pages) {
@@ -514,14 +506,22 @@ module.exports = function (content) {
514
506
 
515
507
  async.parallel([
516
508
  (callback) => {
517
- processPlugins(json.plugins, this.context, '', callback)
518
- },
519
- (callback) => {
509
+ // 添加首页标识
510
+ if (json.pages && json.pages[0]) {
511
+ if (typeof json.pages[0] !== 'string') {
512
+ json.pages[0].src = addQuery(json.pages[0].src, { isFirst: true })
513
+ } else {
514
+ json.pages[0] = addQuery(json.pages[0], { isFirst: true })
515
+ }
516
+ }
520
517
  processPages(json.pages, this.context, '', callback)
521
518
  },
522
519
  (callback) => {
523
520
  processComponents(json.usingComponents, this.context, callback)
524
521
  },
522
+ (callback) => {
523
+ processPlugins(json.plugins, this.context, '', callback)
524
+ },
525
525
  (callback) => {
526
526
  processWorkers(json.workers, this.context, callback)
527
527
  },
package/lib/loader.js CHANGED
@@ -15,6 +15,7 @@ const getJSONContent = require('./utils/get-json-content')
15
15
  const normalize = require('./utils/normalize')
16
16
  const getEntryName = require('./utils/get-entry-name')
17
17
  const AppEntryDependency = require('./dependencies/AppEntryDependency')
18
+ const { MPX_APP_MODULE_ID } = require('./utils/const')
18
19
 
19
20
  module.exports = function (content) {
20
21
  this.cacheable()
@@ -27,11 +28,8 @@ module.exports = function (content) {
27
28
  const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
28
29
  const pagesMap = mpx.pagesMap
29
30
  const componentsMap = mpx.componentsMap[packageName]
30
- const resolveMode = mpx.resolveMode
31
- const projectRoot = mpx.projectRoot
32
31
  const mode = mpx.mode
33
32
  const env = mpx.env
34
- const defs = mpx.defs
35
33
  const i18n = mpx.i18n
36
34
  const globalSrcMode = mpx.srcMode
37
35
  const localSrcMode = queryObj.mode
@@ -39,10 +37,10 @@ module.exports = function (content) {
39
37
  const vueContentCache = mpx.vueContentCache
40
38
  const autoScope = matchCondition(resourcePath, mpx.autoScopeRules)
41
39
 
42
- // 支持资源query传入pagecomponent支持页面/组件单独编译
43
- if ((queryObj.component && !componentsMap[resourcePath]) || (queryObj.page && !pagesMap[resourcePath])) {
40
+ // 支持资源query传入isPageisComponent支持页面/组件单独编译
41
+ if ((queryObj.isComponent && !componentsMap[resourcePath]) || (queryObj.isPage && !pagesMap[resourcePath])) {
44
42
  const entryName = getEntryName(this)
45
- if (queryObj.component) {
43
+ if (queryObj.isComponent) {
46
44
  componentsMap[resourcePath] = entryName || 'noEntryComponent'
47
45
  } else {
48
46
  pagesMap[resourcePath] = entryName || 'noEntryPage'
@@ -58,18 +56,11 @@ module.exports = function (content) {
58
56
  ctorType = 'component'
59
57
  }
60
58
 
61
- if (ctorType === 'app') {
62
- const appName = getEntryName(this)
63
- this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
64
- }
65
-
66
59
  const loaderContext = this
67
60
  const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
68
61
  const isProduction = this.minimize || process.env.NODE_ENV === 'production'
69
-
70
62
  const filePath = resourcePath
71
-
72
- const moduleId = 'm' + mpx.pathHash(filePath)
63
+ const moduleId = ctorType === 'app' ? MPX_APP_MODULE_ID : 'm' + mpx.pathHash(filePath)
73
64
 
74
65
  const parts = parseComponent(content, {
75
66
  filePath,
@@ -120,8 +111,8 @@ module.exports = function (content) {
120
111
 
121
112
  // 处理mode为web时输出vue格式文件
122
113
  if (mode === 'web') {
123
- if (ctorType === 'app' && !queryObj.app) {
124
- const request = addQuery(this.resource, { app: true })
114
+ if (ctorType === 'app' && !queryObj.isApp) {
115
+ const request = addQuery(this.resource, { isApp: true })
125
116
  output += `
126
117
  import App from ${stringifyRequest(request)}
127
118
  import Vue from 'vue'
@@ -142,20 +133,15 @@ module.exports = function (content) {
142
133
  async.parallel([
143
134
  (callback) => {
144
135
  processTemplate(parts.template, {
136
+ loaderContext,
145
137
  hasScoped,
146
138
  hasComment,
147
139
  isNative,
148
- mode,
149
140
  srcMode,
150
- defs,
151
- loaderContext,
152
141
  moduleId,
153
142
  ctorType,
154
143
  usingComponents,
155
- componentGenerics,
156
- decodeHTMLText: mpx.decodeHTMLText,
157
- externalClasses: mpx.externalClasses,
158
- checkUsingComponents: mpx.checkUsingComponents
144
+ componentGenerics
159
145
  }, callback)
160
146
  },
161
147
  (callback) => {
@@ -167,15 +153,9 @@ module.exports = function (content) {
167
153
  },
168
154
  (callback) => {
169
155
  processJSON(parts.json, {
170
- mode,
171
- env,
172
- resolveMode,
173
156
  loaderContext,
174
157
  pagesMap,
175
- pagesEntryMap: mpx.pagesEntryMap,
176
- pathHash: mpx.pathHash,
177
- componentsMap,
178
- projectRoot
158
+ componentsMap
179
159
  }, callback)
180
160
  }
181
161
  ], (err, res) => {
@@ -191,23 +171,20 @@ module.exports = function (content) {
191
171
  }
192
172
 
193
173
  processScript(parts.script, {
174
+ loaderContext,
194
175
  ctorType,
195
176
  srcMode,
196
- loaderContext,
197
177
  isProduction,
198
- i18n,
199
178
  componentGenerics,
200
- projectRoot,
201
179
  jsonConfig: jsonRes.jsonObj,
202
- componentId: queryObj.componentId || '',
180
+ outputPath: queryObj.outputPath || '',
203
181
  tabBarMap: jsonRes.tabBarMap,
204
182
  tabBarStr: jsonRes.tabBarStr,
205
183
  builtInComponentsMap: templateRes.builtInComponentsMap,
206
184
  genericsInfo: templateRes.genericsInfo,
207
185
  wxsModuleMap: templateRes.wxsModuleMap,
208
186
  localComponentsMap: jsonRes.localComponentsMap,
209
- localPagesMap: jsonRes.localPagesMap,
210
- forceDisableBuiltInLoader: mpx.forceDisableBuiltInLoader
187
+ localPagesMap: jsonRes.localPagesMap
211
188
  }, callback)
212
189
  }
213
190
  ], (err, scriptRes) => {
@@ -218,6 +195,11 @@ module.exports = function (content) {
218
195
  })
219
196
  }
220
197
 
198
+ if (ctorType === 'app') {
199
+ const appName = getEntryName(this)
200
+ this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
201
+ }
202
+
221
203
  const {
222
204
  getRequire
223
205
  } = createHelpers(loaderContext)
@@ -73,7 +73,12 @@ module.exports = function getSpec ({ warn, error }) {
73
73
  swan: deletePath()
74
74
  },
75
75
  {
76
- test: 'onReachBottomDistance|disableScroll',
76
+ test: 'onReachBottomDistance',
77
+ qq: deletePath(),
78
+ jd: deletePath()
79
+ },
80
+ {
81
+ test: 'disableScroll',
77
82
  ali: deletePath(),
78
83
  qq: deletePath(),
79
84
  jd: deletePath()
@@ -84,7 +89,7 @@ module.exports = function getSpec ({ warn, error }) {
84
89
  swan: deletePath()
85
90
  },
86
91
  {
87
- test: 'navigationBarTextStyle|navigationStyle|backgroundColor|backgroundTextStyle',
92
+ test: 'navigationBarTextStyle|navigationStyle|backgroundTextStyle',
88
93
  ali: deletePath()
89
94
  },
90
95
  {
@@ -44,7 +44,7 @@ module.exports = function ({ print }) {
44
44
  // 如果是个变量,报warning~
45
45
  aliPropLog(attr)
46
46
  } else {
47
- let supportedList = ['navigate', 'redirect', 'switchTab', 'navigateBack', 'reLaunch']
47
+ let supportedList = ['navigate', 'redirect', 'switchTab', 'navigateBack', 'reLaunch', 'exit']
48
48
  if (supportedList.indexOf(attr.value) === -1) {
49
49
  aliValueLogError(attr)
50
50
  }
@@ -120,3 +120,8 @@ html, body, .app {
120
120
  font-family "weui"
121
121
  src url('data:application/octet-stream;base64,AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzJAKEx+AAABfAAAAFZjbWFw65cFHQAAAhwAAAJQZ2x5ZvCRR/EAAASUAAAKtGhlYWQLKIN9AAAA4AAAADZoaGVhCCwD+gAAALwAAAAkaG10eEJo//8AAAHUAAAASGxvY2EYqhW6AAAEbAAAACZtYXhwASEAVQAAARgAAAAgbmFtZeNcHtgAAA9IAAAB5nBvc3T6bLhLAAARMAAAAOYAAQAAA+gAAABaA+j/////A+kAAQAAAAAAAAAAAAAAAAAAABIAAQAAAAEAACkCj3dfDzz1AAsD6AAAAADUER9XAAAAANQRH1f//wAAA+kD6gAAAAgAAgAAAAAAAAABAAAAEgBJAAUAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQOwAZAABQAIAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA6gHqEQPoAAAAWgPqAAAAAAABAAAAAAAAAAAAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+j//wPoAAAD6AAAAAA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Nlc3MOc3VjY2Vzcy1jaXJjbGURc3VjY2Vzcy1uby1jaXJjbGUHd2FpdGluZw53YWl0aW5nLWNpcmNsZQR3YXJuC2luZm8tY2lyY2xlBmNhbmNlbAZzZWFyY2gFY2xlYXIEYmFjawZkZWxldGUAAAAA') format('truetype')
122
122
  }
123
+
124
+ .mpx-root-view {
125
+ display: inline
126
+ line-height: normal
127
+ }
@@ -1,4 +1,5 @@
1
1
  import { isEmptyObject } from './util'
2
+ const isTouchDevice = 'ontouchstart' in document.documentElement
2
3
 
3
4
  function processModel (listeners, context) {
4
5
  // 该函数只有wx:model的情况下才调用,而且默认e.detail.value有值
@@ -54,58 +55,63 @@ function processTap (listeners, context) {
54
55
  })
55
56
  if (isEmptyObject(listenerMap)) return
56
57
  context.__mpxTapInfo = context.__mpxTapInfo || {}
57
- let events = {
58
- touchstart (e) {
59
- context.__mpxTapInfo.detail = {
60
- x: e.changedTouches[0].pageX,
61
- y: e.changedTouches[0].pageY
62
- }
63
- context.__mpxTapInfo.startTimer = null
64
- context.__mpxTapInfo.needTap = true
65
- context.__mpxTapInfo.hadTouch = true
66
- if (listenerMap.longpress || listenerMap.longtap) {
67
- context.__mpxTapInfo.startTimer = setTimeout(() => {
58
+ let events
59
+ if (isTouchDevice) {
60
+ events = {
61
+ touchstart (e) {
62
+ context.__mpxTapInfo.detail = {
63
+ x: e.changedTouches[0].pageX,
64
+ y: e.changedTouches[0].pageY
65
+ }
66
+ context.__mpxTapInfo.startTimer = null
67
+ context.__mpxTapInfo.needTap = true
68
+ if (listenerMap.longpress || listenerMap.longtap) {
69
+ context.__mpxTapInfo.startTimer = setTimeout(() => {
70
+ context.__mpxTapInfo.needTap = false
71
+ if (listenerMap.longpress) {
72
+ const re = inheritEvent('longpress', e, context.__mpxTapInfo.detail)
73
+ context.$emit('longpress', re)
74
+ }
75
+ if (listenerMap.longtap) {
76
+ const re = inheritEvent('longtap', e, context.__mpxTapInfo.detail)
77
+ context.$emit('longtap', re)
78
+ }
79
+ }, 350)
80
+ }
81
+ },
82
+ touchmove (e) {
83
+ const tapDetailInfo = context.__mpxTapInfo.detail || {}
84
+ const currentPageX = e.changedTouches[0].pageX
85
+ const currentPageY = e.changedTouches[0].pageY
86
+ if (Math.abs(currentPageX - tapDetailInfo.x) > 1 || Math.abs(currentPageY - tapDetailInfo.y) > 1) {
68
87
  context.__mpxTapInfo.needTap = false
69
- if (listenerMap.longpress) {
70
- const re = inheritEvent('longpress', e, context.__mpxTapInfo.detail)
71
- context.$emit('longpress', re)
72
- }
73
- if (listenerMap.longtap) {
74
- const re = inheritEvent('longtap', e, context.__mpxTapInfo.detail)
75
- context.$emit('longtap', re)
76
- }
77
- }, 350)
78
- }
79
- },
80
- touchmove (e) {
81
- const tapDetailInfo = context.__mpxTapInfo.detail || {}
82
- const currentPageX = e.changedTouches[0].pageX
83
- const currentPageY = e.changedTouches[0].pageY
84
- if (Math.abs(currentPageX - tapDetailInfo.x) > 1 || Math.abs(currentPageY - tapDetailInfo.y) > 1) {
85
- context.__mpxTapInfo.needTap = false
88
+ context.__mpxTapInfo.startTimer && clearTimeout(context.__mpxTapInfo.startTimer)
89
+ context.__mpxTapInfo.startTimer = null
90
+ }
91
+ },
92
+ touchend (e) {
86
93
  context.__mpxTapInfo.startTimer && clearTimeout(context.__mpxTapInfo.startTimer)
87
- context.__mpxTapInfo.startTimer = null
88
- }
89
- },
90
- touchend (e) {
91
- context.__mpxTapInfo.startTimer && clearTimeout(context.__mpxTapInfo.startTimer)
92
- if (listenerMap.tap && context.__mpxTapInfo.needTap) {
93
- const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
94
- context.$emit('tap', re)
94
+ if (listenerMap.tap && context.__mpxTapInfo.needTap) {
95
+ const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
96
+ context.$emit('tap', re)
97
+ }
95
98
  }
96
- },
97
- click (e) {
98
- if (listenerMap.tap && !context.__mpxTapInfo.hadTouch) {
99
- context.__mpxTapInfo.detail = {
100
- x: e.pageX,
101
- y: e.pageY
99
+ }
100
+ } else {
101
+ events = {
102
+ click (e) {
103
+ if (listenerMap.tap) {
104
+ context.__mpxTapInfo.detail = {
105
+ x: e.pageX,
106
+ y: e.pageY
107
+ }
108
+ const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
109
+ context.$emit('tap', re)
102
110
  }
103
- const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
104
- context.$emit('tap', re)
105
111
  }
106
- context.__mpxTapInfo.hadTouch = false
107
112
  }
108
113
  }
114
+
109
115
  mergeListeners(listeners, events, {
110
116
  force: true
111
117
  })