@dcloudio/uni-cli-shared 2.0.1-alpha-36720221017003 → 2.0.1-alpha-36720221018002

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.
@@ -7,7 +7,7 @@ exports.parseInject = exports.parseInjects = exports.parseUniExtApis = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const merge_1 = require("merge");
10
- function parseUniExtApis() {
10
+ function parseUniExtApis(vite = true) {
11
11
  const uniModulesDir = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'uni_modules');
12
12
  if (!fs_extra_1.default.existsSync(uniModulesDir)) {
13
13
  return {};
@@ -25,7 +25,10 @@ function parseUniExtApis() {
25
25
  }
26
26
  const exports = (_b = (_a = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))) === null || _a === void 0 ? void 0 : _a.uni_modules) === null || _b === void 0 ? void 0 : _b['uni-ext-api'];
27
27
  if (exports) {
28
- Object.assign(injects, parseInjects(process.env.UNI_PLATFORM === 'h5' ? 'web' : process.env.UNI_PLATFORM, `@/uni_modules/${uniModuleDir}`, exports));
28
+ Object.assign(injects, parseInjects(vite, process.env.UNI_PLATFORM === 'h5' ? 'web' : process.env.UNI_PLATFORM, `@/uni_modules/${uniModuleDir}` +
29
+ (vite || !process.env.UNI_UTS_PLATFORM
30
+ ? ''
31
+ : `/utssdk/${process.env.UNI_UTS_PLATFORM}/index`), exports));
29
32
  }
30
33
  });
31
34
  return injects;
@@ -52,7 +55,7 @@ exports.parseUniExtApis = parseUniExtApis;
52
55
  * @param define
53
56
  * @returns
54
57
  */
55
- function parseInjects(platform, source, exports = {}) {
58
+ function parseInjects(vite = true, platform, source, exports = {}) {
56
59
  let rootDefines = {};
57
60
  Object.keys(exports).forEach((name) => {
58
61
  if (name.startsWith('uni')) {
@@ -69,18 +72,18 @@ function parseInjects(platform, source, exports = {}) {
69
72
  }
70
73
  const injects = {};
71
74
  for (const key in rootDefines) {
72
- Object.assign(injects, parseInject(source, 'uni', rootDefines[key]));
75
+ Object.assign(injects, parseInject(vite, source, 'uni', rootDefines[key]));
73
76
  }
74
77
  return injects;
75
78
  }
76
79
  exports.parseInjects = parseInjects;
77
- function parseInject(source, globalObject, define) {
80
+ function parseInject(vite = true, source, globalObject, define) {
78
81
  const injects = {};
79
82
  if (define === false) {
80
83
  }
81
84
  else if (typeof define === 'string') {
82
85
  // {'uni.getBatteryInfo' : '@dcloudio/uni-getbatteryinfo'}
83
- injects[globalObject + '.' + define] = source;
86
+ injects[globalObject + '.' + define] = vite ? source : [source, 'default'];
84
87
  }
85
88
  else if (Array.isArray(define)) {
86
89
  // {'uni.getBatteryInfo' : ['@dcloudio/uni-getbatteryinfo','getBatteryInfo]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.1-alpha-36720221017003",
3
+ "version": "2.0.1-alpha-36720221018002",
4
4
  "description": "uni-cli-shared",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -25,5 +25,5 @@
25
25
  "postcss-urlrewrite": "^0.2.2",
26
26
  "strip-json-comments": "^2.0.1"
27
27
  },
28
- "gitHead": "146ab03a2bdebbdcc44e99dfc540cefca15cebe4"
28
+ "gitHead": "595dafce3471cb9a16766b6b6feaccf752481dc3"
29
29
  }