@dcloudio/vue-cli-plugin-uni 2.0.1-alpha-34620220415002 → 2.0.1-alpha-34820220424001

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
  }
@@ -102,7 +102,9 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
102
102
  'process.env.UNI_CLOUD_PROVIDER': process.env.UNI_CLOUD_PROVIDER,
103
103
  'process.env.UNICLOUD_DEBUG': process.env.UNICLOUD_DEBUG,
104
104
  '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)
105
+ 'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT),
106
+ 'process.env.UNI_STAT_UNI_CLOUD': process.env.UNI_STAT_UNI_CLOUD || '',
107
+ 'process.env.UNI_STAT_DEBUG': process.env.UNI_STAT_DEBUG || ''
106
108
  }
107
109
  if (process.env.UNI_USING_VUE3) {
108
110
  Object.assign(defines, {
@@ -145,4 +147,4 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
145
147
  webpackConfig.plugins.delete('progress')
146
148
  }
147
149
  }
148
- }
150
+ }
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,7 +20,13 @@ 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 || ''
@@ -32,6 +39,13 @@ if (process.env.UNI_PLATFORM.indexOf('mp-') === 0) {
32
39
  process.env.UNI_USING_VUE3_OPTIONS_API = true
33
40
  }
34
41
  }
42
+ // v2 uni-push
43
+ if (isEnableUniPushV2(manifestJsonObj, process.env.UNI_PLATFORM)) {
44
+ process.env.UNI_PUSH_V2 = true
45
+ if (process.env.UNI_PLATFORM === 'app-plus' && isUniPushOffline(manifestJsonObj)) {
46
+ process.env.UNI_PUSH_V2_OFFLINE = true
47
+ }
48
+ }
35
49
 
36
50
  // 初始化全局插件对象
37
51
  global.uniPlugin = require('@dcloudio/uni-cli-shared/lib/plugin').init()
@@ -295,10 +309,13 @@ const scopedSlotsCompiler = !platformOptions.scopedSlotsCompiler && platformOpti
295
309
  : platformOptions.scopedSlotsCompiler
296
310
  process.env.SCOPED_SLOTS_COMPILER = modes.includes(scopedSlotsCompiler) ? scopedSlotsCompiler : modes[1]
297
311
  // 快手小程序、小红书小程序 抽象组件编译报错,如未指定 legacy 固定为 augmented 模式
298
- if ((process.env.UNI_PLATFORM === 'mp-kuaishou' || process.env.UNI_PLATFORM === 'mp-xhs') && process.env.SCOPED_SLOTS_COMPILER !== modes[0]) {
312
+ if ((process.env.UNI_PLATFORM === 'mp-kuaishou' || process.env.UNI_PLATFORM === 'mp-xhs') && process.env
313
+ .SCOPED_SLOTS_COMPILER !== modes[0]) {
299
314
  process.env.SCOPED_SLOTS_COMPILER = modes[2]
300
315
  }
301
316
 
317
+ process.env.UNI_STAT_UNI_CLOUD = ''
318
+ process.env.UNI_STAT_DEBUG = ''
302
319
  if (
303
320
  process.env.UNI_USING_COMPONENTS ||
304
321
  process.env.UNI_PLATFORM === 'h5'
@@ -310,11 +327,32 @@ if (
310
327
 
311
328
  if (uniStatistics.enable === true) {
312
329
  process.env.UNI_USING_STAT = uniStatistics.version === '2' ? '2' : '1'
313
- if (!process.UNI_STAT_CONFIG.appid && process.env.NODE_ENV === 'production') {
330
+ // 获取服务空间配置信息
331
+ const uniCloudConfig = uniStatistics.uniCloud || {}
332
+ process.env.UNI_STAT_UNI_CLOUD = JSON.stringify(uniCloudConfig)
333
+ process.env.UNI_STAT_DEBUG = uniStatistics.debug === true ? 'true' : 'false'
334
+
335
+ if (process.env.NODE_ENV === 'production') {
336
+ if (!process.UNI_STAT_CONFIG.appid) {
337
+ console.log()
338
+ console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', {
339
+ 0: 'https://ask.dcloud.net.cn/article/36303'
340
+ }))
341
+ console.log()
342
+ } else {
343
+ if (!uniStatistics.version) {
344
+ console.log()
345
+ console.warn(uniI18n.__('pluginUni.uniStatisticsNoVersion', {
346
+ 0: 'https://uniapp.dcloud.io/uni-stat-v2.html'
347
+ }))
348
+ }
349
+ console.log()
350
+ console.warn(`已开启 uni统计${uniStatistics.version}.0 版本`)
351
+ console.log()
352
+ }
353
+ } else {
314
354
  console.log()
315
- console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', {
316
- 0: 'https://ask.dcloud.net.cn/article/36303'
317
- }))
355
+ console.warn(`已开启 uni统计${uniStatistics.version}.0 版本`)
318
356
  console.log()
319
357
  }
320
358
  }
@@ -502,4 +540,4 @@ runByHBuilderX && console.log(uniI18n.__('compiling'))
502
540
 
503
541
  module.exports = {
504
542
  manifestPlatformOptions: platformOptions
505
- }
543
+ }
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-alpha-34620220415002",
3
+ "version": "2.0.1-alpha-34820220424001",
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-alpha-34620220415002",
20
+ "@dcloudio/uni-stat": "^2.0.1-alpha-34820220424001",
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": "c2c5b0345d72c1cfb51645719ce260a5c1d0d0f7"
42
+ "gitHead": "51f66abf553ddaa38092bc8560bf358ef8837448"
43
43
  }