@dcloudio/vue-cli-plugin-uni 2.0.1-33920220314003 → 2.0.1-34720220422002

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/generator.js CHANGED
@@ -19,6 +19,7 @@ module.exports = (api, options, rootOptions) => {
19
19
  'dev:mp-kuaishou': 'cross-env NODE_ENV=development UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build --watch',
20
20
  'dev:mp-lark': 'cross-env NODE_ENV=development UNI_PLATFORM=mp-lark vue-cli-service uni-build --watch',
21
21
  'dev:mp-jd': 'cross-env NODE_ENV=development UNI_PLATFORM=mp-jd vue-cli-service uni-build --watch',
22
+ 'dev:mp-xhs': 'cross-env NODE_ENV=development UNI_PLATFORM=mp-xhs vue-cli-service uni-build --watch',
22
23
  'dev:quickapp-native': 'cross-env NODE_ENV=development UNI_PLATFORM=quickapp-native vue-cli-service uni-build --watch',
23
24
  'dev:quickapp-webview': 'cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview vue-cli-service uni-build --watch',
24
25
  'dev:quickapp-webview-huawei': 'cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build --watch',
@@ -32,6 +33,7 @@ module.exports = (api, options, rootOptions) => {
32
33
  'build:mp-kuaishou': 'cross-env NODE_ENV=production UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build',
33
34
  'build:mp-lark': 'cross-env NODE_ENV=production UNI_PLATFORM=mp-lark vue-cli-service uni-build',
34
35
  'build:mp-jd': 'cross-env NODE_ENV=production UNI_PLATFORM=mp-jd vue-cli-service uni-build',
36
+ 'build:mp-xhs': 'cross-env NODE_ENV=production UNI_PLATFORM=mp-xhs vue-cli-service uni-build',
35
37
  'build:quickapp-native': 'cross-env NODE_ENV=production UNI_PLATFORM=quickapp-native vue-cli-service uni-build',
36
38
  'build:quickapp-webview': 'cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview vue-cli-service uni-build',
37
39
  'build:quickapp-webview-huawei': 'cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build',
@@ -60,6 +62,7 @@ module.exports = (api, options, rootOptions) => {
60
62
  '@dcloudio/uni-mp-toutiao': version,
61
63
  '@dcloudio/uni-mp-lark': version,
62
64
  '@dcloudio/uni-mp-jd': version,
65
+ '@dcloudio/uni-mp-xhs': version,
63
66
  '@dcloudio/uni-mp-360': version,
64
67
  '@dcloudio/uni-mp-kuaishou': version,
65
68
  '@dcloudio/uni-quickapp-native': version,
@@ -2,7 +2,8 @@ const path = require('path')
2
2
  const webpack = require('webpack')
3
3
 
4
4
  const {
5
- getMainEntry
5
+ getMainEntry,
6
+ getPlatformStat
6
7
  } = require('@dcloudio/uni-cli-shared')
7
8
 
8
9
  const vueLoader = require('@dcloudio/uni-cli-shared/lib/vue-loader')
@@ -58,7 +59,7 @@ const v3 = {
58
59
  const isAppService = !!vueOptions.pluginOptions['uni-app-plus'].service
59
60
  const isAppView = !!vueOptions.pluginOptions['uni-app-plus'].view
60
61
 
61
- const statCode = process.env.UNI_USING_STAT ? 'import \'@dcloudio/uni-stat\';' : ''
62
+ const statCode = getPlatformStat()
62
63
 
63
64
  const beforeCode = 'import \'uni-pages\';'
64
65
 
@@ -323,9 +323,6 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
323
323
  .UNI_INPUT_DIR), // css中的'@/static/logo.png'会被转换成'./@/static/logo.png'加载
324
324
  vue$: getPlatformVue(vueOptions),
325
325
  'uni-pages': path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'),
326
- '@dcloudio/uni-stat': process.env.UNI_USING_VUE3 ? require.resolve(
327
- '@dcloudio/vue-cli-plugin-uni/packages/uni-stat') : require
328
- .resolve('@dcloudio/uni-stat'),
329
326
  'uni-stat-config': path.resolve(process.env.UNI_INPUT_DIR, 'pages.json') +
330
327
  '?' +
331
328
  JSON.stringify({
package/lib/env.js CHANGED
@@ -50,7 +50,8 @@ process.env.UNI_USING_V3_SCOPED = true
50
50
  process.env.UNI_CLOUD_PROVIDER = JSON.stringify([])
51
51
 
52
52
  // 导出到小程序插件
53
- process.env.UNI_MP_PLUGIN_EXPORT = JSON.stringify(Object.keys(platformOptions.plugins || {}).map(pluginName => platformOptions.plugins[pluginName].export))
53
+ process.env.UNI_MP_PLUGIN_EXPORT = JSON.stringify(Object.keys(platformOptions.plugins || {}).map(pluginName =>
54
+ platformOptions.plugins[pluginName].export))
54
55
 
55
56
  const isH5 = !process.env.UNI_SUB_PLATFORM && process.env.UNI_PLATFORM === 'h5'
56
57
  const isProduction = process.env.NODE_ENV === 'production'
@@ -293,8 +294,8 @@ const modes = ['legacy', 'auto', 'augmented']
293
294
  const scopedSlotsCompiler = !platformOptions.scopedSlotsCompiler && platformOptions.betterScopedSlots ? modes[2]
294
295
  : platformOptions.scopedSlotsCompiler
295
296
  process.env.SCOPED_SLOTS_COMPILER = modes.includes(scopedSlotsCompiler) ? scopedSlotsCompiler : modes[1]
296
- // 快手小程序抽象组件编译报错,如未指定 legacy 固定为 augmented 模式
297
- if (process.env.UNI_PLATFORM === 'mp-kuaishou' && process.env.SCOPED_SLOTS_COMPILER !== modes[0]) {
297
+ // 快手小程序、小红书小程序 抽象组件编译报错,如未指定 legacy 固定为 augmented 模式
298
+ if ((process.env.UNI_PLATFORM === 'mp-kuaishou' || process.env.UNI_PLATFORM === 'mp-xhs') && process.env.SCOPED_SLOTS_COMPILER !== modes[0]) {
298
299
  process.env.SCOPED_SLOTS_COMPILER = modes[2]
299
300
  }
300
301
 
@@ -308,7 +309,7 @@ if (
308
309
  )
309
310
 
310
311
  if (uniStatistics.enable === true) {
311
- process.env.UNI_USING_STAT = true
312
+ process.env.UNI_USING_STAT = uniStatistics.version === '2' ? '2' : '1'
312
313
  if (!process.UNI_STAT_CONFIG.appid && process.env.NODE_ENV === 'production') {
313
314
  console.log()
314
315
  console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', {
@@ -399,9 +400,9 @@ moduleAlias.addAlias('vue-template-compiler', '@dcloudio/vue-cli-plugin-uni/pack
399
400
  moduleAlias.addAlias('@megalo/template-compiler', '@dcloudio/vue-cli-plugin-uni/packages/@megalo/template-compiler')
400
401
  moduleAlias.addAlias('mpvue-template-compiler', '@dcloudio/vue-cli-plugin-uni/packages/mpvue-template-compiler')
401
402
  // vue-loader
402
- moduleAlias.addAlias('vue-loader', '@dcloudio/vue-cli-plugin-uni/packages/vue-loader')
403
+ moduleAlias.addAlias('vue-loader', '@dcloudio/vue-cli-plugin-uni/packages/vue-loader')
403
404
  // sass-loader
404
- moduleAlias.addAlias('sass-loader', '@dcloudio/vue-cli-plugin-uni/packages/sass-loader')
405
+ moduleAlias.addAlias('sass-loader', '@dcloudio/vue-cli-plugin-uni/packages/sass-loader')
405
406
 
406
407
  if (process.env.UNI_USING_V3 && process.env.UNI_PLATFORM === 'app-plus') {
407
408
  moduleAlias.addAlias('./runtime/getUrl.js', '@dcloudio/vue-cli-plugin-uni/lib/app-plus/getUrl.js')
@@ -501,4 +502,4 @@ runByHBuilderX && console.log(uniI18n.__('compiling'))
501
502
 
502
503
  module.exports = {
503
504
  manifestPlatformOptions: platformOptions
504
- }
505
+ }
@@ -10,8 +10,9 @@ function isFunction (expr) {
10
10
  try {
11
11
  const body = parser.parse(`(${expr})`).program.body[0]
12
12
  const expression = body.expression
13
- return t.isFunctionDeclaration(body) || t.isArrowFunctionExpression(expression) || t.isFunctionExpression(expression)
14
- } catch (error) { }
13
+ return t.isFunctionDeclaration(body) || t.isArrowFunctionExpression(expression) || t.isFunctionExpression(
14
+ expression)
15
+ } catch (error) {}
15
16
  }
16
17
 
17
18
  function processEvent (expr, filterModules) {
@@ -80,31 +81,39 @@ module.exports = {
80
81
  })
81
82
  }
82
83
  }
83
- if (el.events) {
84
+ if (el.events || el.nativeEvents) {
84
85
  filterModules = filterModules || []
85
86
  const {
86
87
  events: eventsMap
87
88
  } = deprecated
88
89
  // const warnLogs = new Set()
89
- Object.keys(el.events).forEach(name => {
90
- // 过时事件类型转换
91
- if (eventsMap[name]) {
92
- el.events[eventsMap[name]] = el.events[name]
93
- delete el.events[name]
94
- // warnLogs.add(`警告:事件${name}已过时,推荐使用${eventsMap[name]}代替`)
95
- name = eventsMap[name]
96
- }
97
-
98
- const handlers = el.events[name]
99
- if (Array.isArray(handlers)) {
100
- handlers.forEach(handler => {
101
- handler.value = processEvent(handler.value, filterModules)
102
- })
103
- } else {
104
- handlers.value = processEvent(handlers.value, filterModules)
105
- }
106
- })
90
+ normalizeEvent(el.events, eventsMap, filterModules)
91
+ normalizeEvent(el.nativeEvents, eventsMap, filterModules)
107
92
  }
108
93
  }
109
94
  }]
110
95
  }
96
+
97
+ function normalizeEvent (events, eventsMap, filterModules) {
98
+ if (!events) {
99
+ return
100
+ }
101
+ Object.keys(events).forEach(name => {
102
+ // 过时事件类型转换
103
+ if (eventsMap[name]) {
104
+ events[eventsMap[name]] = events[name]
105
+ delete events[name]
106
+ // warnLogs.add(`警告:事件${name}已过时,推荐使用${eventsMap[name]}代替`)
107
+ name = eventsMap[name]
108
+ }
109
+
110
+ const handlers = events[name]
111
+ if (Array.isArray(handlers)) {
112
+ handlers.forEach(handler => {
113
+ handler.value = processEvent(handler.value, filterModules)
114
+ })
115
+ } else {
116
+ handlers.value = processEvent(handlers.value, filterModules)
117
+ }
118
+ })
119
+ }
package/lib/h5/index.js CHANGED
@@ -4,7 +4,8 @@ const webpack = require('webpack')
4
4
 
5
5
  const {
6
6
  getMainEntry,
7
- getH5Options
7
+ getH5Options,
8
+ getPlatformStat
8
9
  } = require('@dcloudio/uni-cli-shared')
9
10
 
10
11
  const {
@@ -91,7 +92,7 @@ module.exports = {
91
92
  webpackConfig (webpackConfig) {
92
93
  let useBuiltIns = 'usage'
93
94
 
94
- const statCode = process.env.UNI_USING_STAT ? 'import \'@dcloudio/uni-stat\';' : ''
95
+ const statCode = getPlatformStat()
95
96
 
96
97
  try {
97
98
  const babelConfig = require(path.resolve(process.env.UNI_CLI_CONTEXT, 'babel.config.js'))
package/lib/mp/index.js CHANGED
@@ -6,7 +6,8 @@ const {
6
6
  getMainEntry,
7
7
  normalizePath,
8
8
  getPlatformExts,
9
- getPlatformCssnano
9
+ getPlatformCssnano,
10
+ getPlatformStat
10
11
  } = require('@dcloudio/uni-cli-shared')
11
12
 
12
13
  const WebpackUniAppPlugin = require('../../packages/webpack-uni-app-loader/plugin/index')
@@ -162,7 +163,7 @@ module.exports = {
162
163
 
163
164
  parseEntry()
164
165
 
165
- const statCode = process.env.UNI_USING_STAT ? 'import \'@dcloudio/uni-stat\';' : ''
166
+ const statCode = getPlatformStat()
166
167
 
167
168
  let beforeCode = 'import \'uni-pages\';'
168
169
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/vue-cli-plugin-uni",
3
- "version": "2.0.1-33920220314003",
3
+ "version": "2.0.1-34720220422002",
4
4
  "description": "uni-app plugin for vue-cli 3",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -17,7 +17,7 @@
17
17
  "author": "fxy060608",
18
18
  "license": "Apache-2.0",
19
19
  "dependencies": {
20
- "@dcloudio/uni-stat": "^2.0.1-33920220314003",
20
+ "@dcloudio/uni-stat": "^2.0.1-34720220422002",
21
21
  "buffer-json": "^2.0.0",
22
22
  "clone-deep": "^4.0.1",
23
23
  "copy-webpack-plugin": "^5.1.1",
@@ -39,5 +39,5 @@
39
39
  "wrap-loader": "^0.2.0",
40
40
  "xregexp": "4.0.0"
41
41
  },
42
- "gitHead": "e367d8b4acffd31f7b4377e8f564ac5bad167016"
42
+ "gitHead": "6577bf36e4d78c84bb8ceedc63bfbd463cb36b4d"
43
43
  }
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Vue.js v2.6.11
3
- * (c) 2014-2021 Evan You
3
+ * (c) 2014-2022 Evan You
4
4
  * Released under the MIT License.
5
5
  */
6
6
  'use strict';
@@ -6784,7 +6784,8 @@ function updateWxsProps(oldVnode, vnode) {
6784
6784
  context.$getComponentDescriptor(context, true),
6785
6785
  vnode.elm.__vue__.$getComponentDescriptor(vnode.elm.__vue__, false)
6786
6786
  );
6787
- }, {
6787
+ }, {
6788
+ immediate: true, // 当 prop 的值被设置 WXS 函数就会触发,而不只是值发生改变,所以在页面初始化的时候会调用一次 WxsPropObserver 的函数
6788
6789
  deep: true
6789
6790
  });
6790
6791
  });