@dcloudio/uni-cli-shared 3.0.0-alpha-3060720221017002 → 3.0.0-alpha-3060720221018002

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.
@@ -5,7 +5,7 @@ declare type Defines = {
5
5
  interface Exports {
6
6
  [name: string]: Define | Defines | false;
7
7
  }
8
- export declare function parseUniExtApis(): Injects;
8
+ export declare function parseUniExtApis(vite?: boolean): Injects;
9
9
  declare type Injects = {
10
10
  [name: string]: string | string[] | false;
11
11
  };
@@ -30,6 +30,6 @@ declare type Injects = {
30
30
  * @param define
31
31
  * @returns
32
32
  */
33
- export declare function parseInjects(platform: UniApp.PLATFORM, source: string, exports?: Exports): Injects;
34
- export declare function parseInject(source: string, globalObject: string, define: Define): Injects;
33
+ export declare function parseInjects(vite: boolean | undefined, platform: UniApp.PLATFORM, source: string, exports?: Exports): Injects;
34
+ export declare function parseInject(vite: boolean | undefined, source: string, globalObject: string, define: Define): Injects;
35
35
  export {};
@@ -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]}
@@ -59,7 +59,7 @@ function isJsFile(id) {
59
59
  if (isJs) {
60
60
  return true;
61
61
  }
62
- const isVueJs = constants_1.EXTNAME_VUE.includes(path_1.default.extname(filename)) && !query.vue;
62
+ const isVueJs = constants_1.EXTNAME_VUE.includes(path_1.default.extname(filename)) && (!query.vue || query.setup);
63
63
  if (isVueJs) {
64
64
  return true;
65
65
  }
package/lib/.DS_Store ADDED
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3060720221017002",
3
+ "version": "3.0.0-alpha-3060720221018002",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "@babel/core": "^7.18.13",
26
26
  "@babel/parser": "^7.18.13",
27
27
  "@babel/types": "^7.17.0",
28
- "@dcloudio/uni-i18n": "3.0.0-alpha-3060720221017002",
29
- "@dcloudio/uni-shared": "3.0.0-alpha-3060720221017002",
28
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3060720221018002",
29
+ "@dcloudio/uni-shared": "3.0.0-alpha-3060720221018002",
30
30
  "@intlify/core-base": "9.1.9",
31
31
  "@intlify/shared": "9.1.9",
32
32
  "@intlify/vue-devtools": "9.1.9",