@dcloudio/vue-cli-plugin-uni 2.0.1-34720220422001 → 2.0.1-34920220607002

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.
@@ -2,8 +2,9 @@ const path = require('path')
2
2
  const webpack = require('webpack')
3
3
 
4
4
  const {
5
- getMainEntry,
6
- getPlatformStat
5
+ getMainEntry,
6
+ getPlatformStat,
7
+ getPlatformPush
7
8
  } = require('@dcloudio/uni-cli-shared')
8
9
 
9
10
  const vueLoader = require('@dcloudio/uni-cli-shared/lib/vue-loader')
@@ -60,6 +61,7 @@ const v3 = {
60
61
  const isAppView = !!vueOptions.pluginOptions['uni-app-plus'].view
61
62
 
62
63
  const statCode = getPlatformStat()
64
+ const pushCode = getPlatformPush()
63
65
 
64
66
  const beforeCode = 'import \'uni-pages\';'
65
67
 
@@ -154,7 +156,7 @@ const v3 = {
154
156
  options: {
155
157
  compiler: vueLoader.compiler,
156
158
  before: [
157
- beforeCode + require('../util').getAutomatorCode() + statCode +
159
+ beforeCode + require('../util').getAutomatorCode() + statCode + pushCode +
158
160
  getGlobalUsingComponentsCode()
159
161
  ]
160
162
  }
@@ -99,10 +99,16 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
99
99
  'process.env.UNI_APP_ID': JSON.stringify(process.env.UNI_APP_ID),
100
100
  'process.env.UNI_APP_NAME': JSON.stringify(process.env.UNI_APP_NAME),
101
101
  'process.env.UNI_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM),
102
+ 'process.env.UNI_SUB_PLATFORM': JSON.stringify(process.env.UNI_SUB_PLATFORM),
102
103
  'process.env.UNI_CLOUD_PROVIDER': process.env.UNI_CLOUD_PROVIDER,
103
104
  'process.env.UNICLOUD_DEBUG': process.env.UNICLOUD_DEBUG,
104
105
  'process.env.RUN_BY_HBUILDERX': process.env.RUN_BY_HBUILDERX,
105
- 'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT)
106
+ 'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT),
107
+ 'process.env.UNI_STAT_UNI_CLOUD': process.env.UNI_STAT_UNI_CLOUD || '',
108
+ 'process.env.UNI_STAT_DEBUG': process.env.UNI_STAT_DEBUG || '',
109
+ 'process.env.UNI_COMPILER_VERSION': JSON.stringify(process.env.UNI_COMPILER_VERSION),
110
+ 'process.env.UNI_APP_VERSION_NAME': JSON.stringify(process.env.UNI_APP_VERSION_NAME),
111
+ 'process.env.UNI_APP_VERSION_CODE': JSON.stringify(process.env.UNI_APP_VERSION_CODE)
106
112
  }
107
113
  if (process.env.UNI_USING_VUE3) {
108
114
  Object.assign(defines, {
@@ -145,4 +151,4 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
145
151
  webpackConfig.plugins.delete('progress')
146
152
  }
147
153
  }
148
- }
154
+ }
package/lib/env.js CHANGED
@@ -6,6 +6,7 @@ const uniI18n = require('@dcloudio/uni-cli-i18n')
6
6
  const moduleAlias = require('module-alias')
7
7
 
8
8
  require('./error-reporting')
9
+ require('../util/console')
9
10
 
10
11
  const hasOwnProperty = Object.prototype.hasOwnProperty
11
12
 
@@ -19,11 +20,19 @@ if (process.env.UNI_INPUT_DIR && process.env.UNI_INPUT_DIR.indexOf('./') === 0)
19
20
  }
20
21
  process.env.UNI_INPUT_DIR = process.env.UNI_INPUT_DIR || path.resolve(process.cwd(), defaultInputDir)
21
22
 
22
- const manifestJsonObj = require('@dcloudio/uni-cli-shared/lib/manifest').getManifestJson()
23
+ const {
24
+ getManifestJson,
25
+ isEnableUniPushV2,
26
+ isUniPushOffline
27
+ } = require('@dcloudio/uni-cli-shared/lib/manifest')
28
+
29
+ const manifestJsonObj = getManifestJson()
23
30
 
24
31
  process.env.UNI_APP_ID = manifestJsonObj.appid || ''
25
32
  process.env.UNI_APP_NAME = manifestJsonObj.name || ''
26
33
  process.env.UNI_PLATFORM = process.env.UNI_PLATFORM || 'h5'
34
+ process.env.UNI_APP_VERSION_NAME = manifestJsonObj.versionName
35
+ process.env.UNI_APP_VERSION_CODE = manifestJsonObj.versionCode
27
36
 
28
37
  // 小程序 vue3 标记
29
38
  if (process.env.UNI_PLATFORM.indexOf('mp-') === 0) {
@@ -32,6 +41,13 @@ if (process.env.UNI_PLATFORM.indexOf('mp-') === 0) {
32
41
  process.env.UNI_USING_VUE3_OPTIONS_API = true
33
42
  }
34
43
  }
44
+ // v2 uni-push
45
+ if (isEnableUniPushV2(manifestJsonObj, process.env.UNI_PLATFORM)) {
46
+ process.env.UNI_PUSH_V2 = true
47
+ if (process.env.UNI_PLATFORM === 'app-plus' && isUniPushOffline(manifestJsonObj)) {
48
+ process.env.UNI_PUSH_V2_OFFLINE = true
49
+ }
50
+ }
35
51
 
36
52
  // 初始化全局插件对象
37
53
  global.uniPlugin = require('@dcloudio/uni-cli-shared/lib/plugin').init()
@@ -87,6 +103,9 @@ if (process.env.UNI_CLOUD_SPACES) {
87
103
  }
88
104
 
89
105
  process.env.UNI_CLOUD_PROVIDER = JSON.stringify(spaces.map(space => {
106
+ if (space.provider === 'tcb') {
107
+ space.provider = 'tencent'
108
+ }
90
109
  if (space.clientSecret) {
91
110
  return {
92
111
  provider: space.provider || 'aliyun',
@@ -295,10 +314,13 @@ const scopedSlotsCompiler = !platformOptions.scopedSlotsCompiler && platformOpti
295
314
  : platformOptions.scopedSlotsCompiler
296
315
  process.env.SCOPED_SLOTS_COMPILER = modes.includes(scopedSlotsCompiler) ? scopedSlotsCompiler : modes[1]
297
316
  // 快手小程序、小红书小程序 抽象组件编译报错,如未指定 legacy 固定为 augmented 模式
298
- if ((process.env.UNI_PLATFORM === 'mp-kuaishou' || process.env.UNI_PLATFORM === 'mp-xhs') && process.env.SCOPED_SLOTS_COMPILER !== modes[0]) {
317
+ if ((process.env.UNI_PLATFORM === 'mp-kuaishou' || process.env.UNI_PLATFORM === 'mp-xhs') && process.env
318
+ .SCOPED_SLOTS_COMPILER !== modes[0]) {
299
319
  process.env.SCOPED_SLOTS_COMPILER = modes[2]
300
320
  }
301
321
 
322
+ process.env.UNI_STAT_UNI_CLOUD = ''
323
+ process.env.UNI_STAT_DEBUG = ''
302
324
  if (
303
325
  process.env.UNI_USING_COMPONENTS ||
304
326
  process.env.UNI_PLATFORM === 'h5'
@@ -310,12 +332,43 @@ if (
310
332
 
311
333
  if (uniStatistics.enable === true) {
312
334
  process.env.UNI_USING_STAT = uniStatistics.version === '2' ? '2' : '1'
313
- if (!process.UNI_STAT_CONFIG.appid && process.env.NODE_ENV === 'production') {
314
- console.log()
315
- console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', {
316
- 0: 'https://ask.dcloud.net.cn/article/36303'
317
- }))
318
- console.log()
335
+ // 获取服务空间配置信息
336
+ const uniCloudConfig = uniStatistics.uniCloud || {}
337
+ process.env.UNI_STAT_UNI_CLOUD = JSON.stringify(uniCloudConfig)
338
+ process.env.UNI_STAT_DEBUG = uniStatistics.debug === true ? 'true' : 'false'
339
+
340
+ if (process.env.NODE_ENV === 'production') {
341
+ if (!process.UNI_STAT_CONFIG.appid) {
342
+ console.log()
343
+ console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', {
344
+ 0: 'https://ask.dcloud.net.cn/article/36303'
345
+ }))
346
+ console.log()
347
+ } else {
348
+ if (!uniStatistics.version) {
349
+ console.log()
350
+ console.warn(uniI18n.__('pluginUni.uniStatisticsNoVersion', {
351
+ 0: 'https://uniapp.dcloud.io/uni-stat-v2.html'
352
+ }))
353
+ console.log()
354
+ } else {
355
+ console.log()
356
+ console.warn(`已开启 uni统计${uniStatistics.version}.0 版本`)
357
+ console.log()
358
+ }
359
+ }
360
+ } else {
361
+ if (!uniStatistics.version) {
362
+ console.log()
363
+ console.warn(uniI18n.__('pluginUni.uniStatisticsNoVersion', {
364
+ 0: 'https://uniapp.dcloud.io/uni-stat-v2.html'
365
+ }))
366
+ console.log()
367
+ } else {
368
+ console.log()
369
+ console.warn(`已开启 uni统计${uniStatistics.version}.0 版本`)
370
+ console.log()
371
+ }
319
372
  }
320
373
  }
321
374
  }
@@ -340,6 +393,11 @@ const warningMsg =
340
393
  const needWarning = !platformOptions.usingComponents || usingComponentsAbsent
341
394
  let hasNVue = false
342
395
  // 输出编译器版本等信息
396
+ const pagesPkg = require('@dcloudio/webpack-uni-pages-loader/package.json')
397
+ process.env.UNI_COMPILER_VERSION = ''
398
+ if (pagesPkg) {
399
+ process.env.UNI_COMPILER_VERSION = pagesPkg['uni-app'].compilerVersion
400
+ }
343
401
  const compileModeUrl = 'https://ask.dcloud.net.cn/article/36074'
344
402
  if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
345
403
  const compileMode = (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + ':' + (isNVueCompiler ? 'uni-app' : 'weex')
@@ -349,12 +407,8 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
349
407
  }))
350
408
  } else if (process.env.UNI_PLATFORM !== 'h5' && process.env.UNI_PLATFORM !== 'quickapp-native') {
351
409
  try {
352
- let info = ''
410
+ const info = process.env.UNI_COMPILER_VERSION
353
411
  if (process.env.UNI_PLATFORM === 'app-plus') {
354
- const pagesPkg = require('@dcloudio/webpack-uni-pages-loader/package.json')
355
- if (pagesPkg) {
356
- info = uniI18n.__('compilerVersion') + ':' + pagesPkg['uni-app'].compilerVersion
357
- }
358
412
  if (process.env.UNI_USING_V3) {
359
413
  console.log(info)
360
414
  } else {
@@ -502,4 +556,4 @@ runByHBuilderX && console.log(uniI18n.__('compiling'))
502
556
 
503
557
  module.exports = {
504
558
  manifestPlatformOptions: platformOptions
505
- }
559
+ }
package/lib/h5/index.js CHANGED
@@ -4,8 +4,9 @@ const webpack = require('webpack')
4
4
 
5
5
  const {
6
6
  getMainEntry,
7
- getH5Options,
8
- getPlatformStat
7
+ getH5Options,
8
+ getPlatformStat,
9
+ getPlatformPush
9
10
  } = require('@dcloudio/uni-cli-shared')
10
11
 
11
12
  const {
@@ -93,7 +94,7 @@ module.exports = {
93
94
  let useBuiltIns = 'usage'
94
95
 
95
96
  const statCode = getPlatformStat()
96
-
97
+ const pushCode = getPlatformPush()
97
98
  try {
98
99
  const babelConfig = require(path.resolve(process.env.UNI_CLI_CONTEXT, 'babel.config.js'))
99
100
  useBuiltIns = babelConfig.presets[0][1].useBuiltIns
@@ -117,7 +118,7 @@ module.exports = {
117
118
  loader: path.resolve(__dirname, '../../packages/wrap-loader'),
118
119
  options: {
119
120
  before: [
120
- beforeCode + require('../util').getAutomatorCode() + statCode +
121
+ beforeCode + require('../util').getAutomatorCode() + statCode + pushCode +
121
122
  getGlobalUsingComponentsCode()
122
123
  ]
123
124
  }
package/lib/mp/index.js CHANGED
@@ -6,8 +6,9 @@ const {
6
6
  getMainEntry,
7
7
  normalizePath,
8
8
  getPlatformExts,
9
- getPlatformCssnano,
10
- getPlatformStat
9
+ getPlatformCssnano,
10
+ getPlatformStat,
11
+ getPlatformPush
11
12
  } = require('@dcloudio/uni-cli-shared')
12
13
 
13
14
  const WebpackUniAppPlugin = require('../../packages/webpack-uni-app-loader/plugin/index')
@@ -23,6 +24,8 @@ function createUniMPPlugin () {
23
24
  return new WebpackUniMPPlugin()
24
25
  }
25
26
 
27
+ const createWxMpIndependentPlugins = require('@dcloudio/uni-mp-weixin/lib/createIndependentPlugin')
28
+
26
29
  function getProvides () {
27
30
  const uniPath = require('@dcloudio/uni-cli-shared/lib/platform').getMPRuntimePath()
28
31
  const uniCloudPath = path.resolve(__dirname, '../../packages/uni-cloud/dist/index.js')
@@ -164,13 +167,15 @@ module.exports = {
164
167
  parseEntry()
165
168
 
166
169
  const statCode = getPlatformStat()
170
+ const pushCode = getPlatformPush()
167
171
 
168
172
  let beforeCode = 'import \'uni-pages\';'
169
173
 
170
174
  const plugins = [
171
175
  new WebpackUniAppPlugin(),
172
176
  createUniMPPlugin(),
173
- new webpack.ProvidePlugin(getProvides())
177
+ new webpack.ProvidePlugin(getProvides()),
178
+ ...createWxMpIndependentPlugins()
174
179
  ]
175
180
 
176
181
  if ((process.env.UNI_SUBPACKGE || process.env.UNI_MP_PLUGIN) && process.env.UNI_SUBPACKGE !== 'main') {
@@ -233,7 +238,7 @@ module.exports = {
233
238
  loader: path.resolve(__dirname, '../../packages/wrap-loader'),
234
239
  options: {
235
240
  before: [
236
- beforeCode + require('../util').getAutomatorCode() + statCode
241
+ beforeCode + require('../util').getAutomatorCode() + statCode + pushCode
237
242
  ]
238
243
  }
239
244
  }, {
package/lib/options.js CHANGED
@@ -23,10 +23,12 @@ module.exports = function initOptions (options) {
23
23
  options.transpileDependencies.push(genTranspileDepRegex(path.resolve(process.env.UNI_INPUT_DIR, 'node_modules')))
24
24
  options.transpileDependencies.push('@dcloudio/uni-' + process.env.UNI_PLATFORM)
25
25
  options.transpileDependencies.push('@dcloudio/uni-i18n')
26
- options.transpileDependencies.push('@dcloudio/uni-stat')
26
+ options.transpileDependencies.push('@dcloudio/uni-stat')
27
+ options.transpileDependencies.push('@dcloudio/uni-push')
27
28
  options.transpileDependencies.push('@dcloudio/vue-cli-plugin-uni/packages/uni-app')
28
29
  options.transpileDependencies.push('@dcloudio/vue-cli-plugin-uni/packages/uni-cloud')
29
- options.transpileDependencies.push('@dcloudio/vue-cli-plugin-uni/packages/uni-stat')
30
+ options.transpileDependencies.push('@dcloudio/vue-cli-plugin-uni/packages/uni-stat')
31
+ options.transpileDependencies.push('@dcloudio/vue-cli-plugin-uni/packages/uni-push')
30
32
 
31
33
  if (process.env.UNI_PLATFORM !== 'mp-weixin') { // mp runtime
32
34
  options.transpileDependencies.push('@dcloudio/uni-mp-weixin')
@@ -4,6 +4,13 @@ const {
4
4
  normalizePath
5
5
  } = require('@dcloudio/uni-cli-shared')
6
6
 
7
+ const subPkgsInfo = Object.values(process.UNI_SUBPACKAGES)
8
+ const normalFilter = ({ independent }) => !independent
9
+ const independentFilter = ({ independent }) => independent
10
+ const map2Root = ({ root }) => root + '/'
11
+ const normalSubPackageRoots = subPkgsInfo.filter(normalFilter).map(map2Root)
12
+ const independentSubpackageRoots = subPkgsInfo.filter(independentFilter).map(map2Root)
13
+
7
14
  function createCacheGroups () {
8
15
  const cacheGroups = {}
9
16
  if (process.UNI_CONFUSION) { // 加密
@@ -152,7 +159,7 @@ module.exports = function getSplitChunks () {
152
159
  const findSubPackages = function (chunks) {
153
160
  return chunks.reduce((pkgs, item) => {
154
161
  const name = normalizePath(item.name)
155
- const pkgRoot = subPackageRoots.find(root => name.indexOf(root) === 0)
162
+ const pkgRoot = normalSubPackageRoots.find(root => name.indexOf(root) === 0)
156
163
  pkgRoot && pkgs.add(pkgRoot)
157
164
  return pkgs
158
165
  }, new Set())
@@ -178,7 +185,12 @@ module.exports = function getSplitChunks () {
178
185
  console.log('move module to main chunk:', module.resource,
179
186
  'from', subPackageRoot, 'for component in main package:', resource)
180
187
  }
181
- return true
188
+
189
+ // 独立分包除外
190
+ const independentRoot = independentSubpackageRoots.find(root => resource.indexOf(root) >= 0)
191
+ if (!independentRoot) {
192
+ return true
193
+ }
182
194
  }
183
195
  } else {
184
196
  return hasMainPackageComponent(m.module, subPackageRoot)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/vue-cli-plugin-uni",
3
- "version": "2.0.1-34720220422001",
3
+ "version": "2.0.1-34920220607002",
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-34720220422001",
20
+ "@dcloudio/uni-stat": "^2.0.1-34920220607002",
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": "021b138a8234345830ee7fa11c3eec0b98f1c073"
42
+ "gitHead": "6a578780ba74bfe8139ab81613f3f73957e3eda9"
43
43
  }
@@ -6778,11 +6778,13 @@ function updateWxsProps(oldVnode, vnode) {
6778
6778
  }
6779
6779
 
6780
6780
  vnode.$wxsWatches[prop] = oldWxsWatches[prop] || vnode.context.$watch(watchProp, function(newVal, oldVal) {
6781
+ // vue component / web component
6782
+ var component = vnode.elm.__vue__ || vnode.elm;
6781
6783
  wxsProps[prop](
6782
6784
  newVal,
6783
6785
  oldVal,
6784
6786
  context.$getComponentDescriptor(context, true),
6785
- vnode.elm.__vue__.$getComponentDescriptor(vnode.elm.__vue__, false)
6787
+ component.$getComponentDescriptor && component.$getComponentDescriptor(component, false)
6786
6788
  );
6787
6789
  }, {
6788
6790
  immediate: true, // 当 prop 的值被设置 WXS 函数就会触发,而不只是值发生改变,所以在页面初始化的时候会调用一次 WxsPropObserver 的函数