@dcloudio/uni-cli-shared 3.0.0-alpha-3090220231010001 → 3.0.0-alpha-3090320231017002

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/dist/index.d.ts CHANGED
@@ -21,7 +21,7 @@ export * from './esbuild';
21
21
  export * from './resolve';
22
22
  export * from './scripts';
23
23
  export * from './platform';
24
- export { parseUniExtApis, parseInjects } from './uni_modules';
24
+ export { parseUniExtApis, parseInjects, Define, DefineOptions, Defines, } from './uni_modules';
25
25
  export { M } from './messages';
26
26
  export * from './exports';
27
27
  export { checkUpdate } from './checkUpdate';
@@ -185,7 +185,7 @@ async function parseTemplateDescriptor(filename, ast, options) {
185
185
  exports.parseTemplateDescriptor = parseTemplateDescriptor;
186
186
  async function parseGlobalDescriptor(filename, ast, resolve) {
187
187
  // 外置时查找所有 vue component import
188
- const imports = (await parseVueComponentImports(filename, ast.body.filter((node) => (0, types_1.isImportDeclaration)(node)), resolve)).filter((item) => !(0, utils_2.cleanUrl)(item.source.value).endsWith('App.vue'));
188
+ const imports = (await parseVueComponentImports(filename, ast.body.filter((node) => (0, types_1.isImportDeclaration)(node)), resolve)).filter((item) => !(0, utils_1.isAppVue)((0, utils_2.cleanUrl)(item.source.value)));
189
189
  return {
190
190
  bindingComponents: parseGlobalComponents(ast),
191
191
  imports,
package/dist/resolve.js CHANGED
@@ -102,11 +102,12 @@ exports.resolveVueI18nRuntime = resolveVueI18nRuntime;
102
102
  let componentsLibPath = '';
103
103
  function resolveComponentsLibPath() {
104
104
  if (!componentsLibPath) {
105
+ const dir = process.env.UNI_APP_X === 'true' ? '../lib-x' : '../lib';
105
106
  if ((0, env_1.isInHBuilderX)()) {
106
- componentsLibPath = path_1.default.join(resolveBuiltIn('@dcloudio/uni-components/package.json'), '../lib');
107
+ componentsLibPath = path_1.default.join(resolveBuiltIn('@dcloudio/uni-components/package.json'), dir);
107
108
  }
108
109
  else {
109
- componentsLibPath = path_1.default.join(resolveWithSymlinks('@dcloudio/uni-components/package.json', process.env.UNI_INPUT_DIR), '../lib');
110
+ componentsLibPath = path_1.default.join(resolveWithSymlinks('@dcloudio/uni-components/package.json', process.env.UNI_INPUT_DIR), dir);
110
111
  }
111
112
  }
112
113
  return componentsLibPath;
@@ -1,5 +1,5 @@
1
1
  import type { UTSTargetLanguage } from './uts';
2
- type DefineOptions = {
2
+ export type DefineOptions = {
3
3
  name?: string;
4
4
  app?: boolean | {
5
5
  js?: boolean;
@@ -8,8 +8,8 @@ type DefineOptions = {
8
8
  };
9
9
  [key: string]: any;
10
10
  };
11
- type Define = string | string[] | Record<string, string | DefineOptions> | false;
12
- type Defines = {
11
+ export type Define = string | string[] | Record<string, string | DefineOptions> | false;
12
+ export type Defines = {
13
13
  [name: string]: Define;
14
14
  };
15
15
  export interface Exports {
package/dist/utils.d.ts CHANGED
@@ -18,3 +18,5 @@ export declare function pathToGlob(pathString: string, glob: string, options?: {
18
18
  }): string;
19
19
  export declare function resolveSourceMapPath(outputDir?: string, platform?: UniApp.PLATFORM): string;
20
20
  export declare function installDepTips(type: 'dependencies' | 'devDependencies', module: string, version?: string): string;
21
+ export declare function isAppVue(filename: string): boolean;
22
+ export declare function resolveAppVue(inputDir: string): string;
package/dist/utils.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.installDepTips = exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.version = exports.hash = void 0;
6
+ exports.resolveAppVue = exports.isAppVue = exports.installDepTips = exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.version = exports.hash = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -112,3 +112,15 @@ function installDepTips(type, module, version) {
112
112
  Please run \`${picocolors_1.default.cyan(`${getInstallCommand(process.cwd())} ${module + (version ? '@' + version : '')}${type === 'devDependencies' ? ' -D' : ''}`)}\` and try again.`;
113
113
  }
114
114
  exports.installDepTips = installDepTips;
115
+ function isAppVue(filename) {
116
+ return filename.endsWith('App.vue') || filename.endsWith('App.uvue');
117
+ }
118
+ exports.isAppVue = isAppVue;
119
+ function resolveAppVue(inputDir) {
120
+ const appUVue = path_1.default.resolve(inputDir, 'App.uvue');
121
+ if (fs_1.default.existsSync(appUVue)) {
122
+ return normalizePath(appUVue);
123
+ }
124
+ return normalizePath(path_1.default.resolve(inputDir, 'App.vue'));
125
+ }
126
+ exports.resolveAppVue = resolveAppVue;
@@ -37,8 +37,9 @@ function uniViteCopyPlugin({ targets, verbose, }) {
37
37
  cwd: process.env.UNI_INPUT_DIR,
38
38
  ...watchOptions,
39
39
  }, (watcher) => {
40
- if (process.env.NODE_ENV !== 'development') {
41
- // 生产模式下,延迟 close,否则会影响 chokidar 初始化的 add 等事件
40
+ if (process.env.NODE_ENV !== 'development' ||
41
+ process.env.UNI_AUTOMATOR_CONFIG) {
42
+ // 生产或自动化测试模式下,延迟 close,否则会影响 chokidar 初始化的 add 等事件
42
43
  setTimeout(() => {
43
44
  watcher.close().then(() => resolve(void 0));
44
45
  }, 2000);
@@ -9,6 +9,7 @@ const debug_1 = __importDefault(require("debug"));
9
9
  const constants_1 = require("../../constants");
10
10
  const preprocess_1 = require("../../preprocess");
11
11
  const parse_1 = require("../../vue/parse");
12
+ const utils_1 = require("../../utils");
12
13
  const debugScoped = (0, debug_1.default)('uni:scoped');
13
14
  const SCOPED_RE = /<style\s[^>]*scoped[^>]*>/i;
14
15
  function addScoped(code) {
@@ -60,7 +61,7 @@ function uniCssScopedPlugin({ filter } = { filter: () => false }) {
60
61
  if (!constants_1.EXTNAME_VUE.includes(path_1.default.extname(ctx.file))) {
61
62
  return;
62
63
  }
63
- const scoped = !ctx.file.endsWith('App.vue');
64
+ const scoped = !(0, utils_1.isAppVue)(ctx.file);
64
65
  debugScoped('hmr', ctx.file);
65
66
  const oldRead = ctx.read;
66
67
  ctx.read = async () => {
@@ -5,7 +5,8 @@ export * from './mainJs';
5
5
  export * from './jsonJs';
6
6
  export * from './console';
7
7
  export * from './dynamicImportPolyfill';
8
- export * from './utsPlugin';
8
+ export * from './uts/app';
9
+ export * from './uts/h5';
9
10
  export { assetPlugin, parseAssets, getAssetHash } from './vitejs/plugins/asset';
10
11
  export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, } from './vitejs/plugins/css';
11
12
  export { generateCodeFrame, locToStartAndEnd } from './vitejs/utils';
@@ -22,7 +22,8 @@ __exportStar(require("./mainJs"), exports);
22
22
  __exportStar(require("./jsonJs"), exports);
23
23
  __exportStar(require("./console"), exports);
24
24
  __exportStar(require("./dynamicImportPolyfill"), exports);
25
- __exportStar(require("./utsPlugin"), exports);
25
+ __exportStar(require("./uts/app"), exports);
26
+ __exportStar(require("./uts/h5"), exports);
26
27
  var asset_1 = require("./vitejs/plugins/asset");
27
28
  Object.defineProperty(exports, "assetPlugin", { enumerable: true, get: function () { return asset_1.assetPlugin; } });
28
29
  Object.defineProperty(exports, "parseAssets", { enumerable: true, get: function () { return asset_1.parseAssets; } });
@@ -4,5 +4,5 @@ interface UniUTSPluginOptions {
4
4
  extApis?: Record<string, [string, string]>;
5
5
  }
6
6
  export declare const utsPlugins: Set<string>;
7
- export declare function uniUTSPlugin(options?: UniUTSPluginOptions): Plugin;
7
+ export declare function uniUTSAppPlugin(options?: UniUTSPluginOptions): Plugin;
8
8
  export {};
@@ -3,18 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.uniUTSPlugin = exports.utsPlugins = void 0;
6
+ exports.uniUTSAppPlugin = exports.utsPlugins = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const uni_shared_1 = require("@dcloudio/uni-shared");
9
- const uts_1 = require("../../uts");
10
- const utils_1 = require("../utils");
9
+ const uts_1 = require("../../../uts");
10
+ const utils_1 = require("../../utils");
11
11
  const UTSProxyRE = /\?uts-proxy$/;
12
12
  function isUTSProxy(id) {
13
13
  return UTSProxyRE.test(id);
14
14
  }
15
15
  const utsModuleCaches = new Map();
16
16
  exports.utsPlugins = new Set();
17
- function uniUTSPlugin(options = {}) {
17
+ function uniUTSAppPlugin(options = {}) {
18
18
  process.env.UNI_UTS_USING_ROLLUP = 'true';
19
19
  return {
20
20
  name: 'uni:uts',
@@ -86,4 +86,4 @@ function uniUTSPlugin(options = {}) {
86
86
  },
87
87
  };
88
88
  }
89
- exports.uniUTSPlugin = uniUTSPlugin;
89
+ exports.uniUTSAppPlugin = uniUTSAppPlugin;
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function uniUTSJsPlugin(options?: {}): Plugin;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uniUTSJsPlugin = void 0;
4
+ const vue_1 = require("../../../vue");
5
+ function uniUTSJsPlugin(options = {}) {
6
+ process.env.UNI_UTS_USING_ROLLUP = 'true';
7
+ return {
8
+ name: 'uni:uts',
9
+ enforce: 'pre',
10
+ configResolved(config) {
11
+ // 移除自带的 esbuild 处理 ts 文件
12
+ const index = config.plugins.findIndex((p) => p.name === 'vite:esbuild');
13
+ if (index > -1) {
14
+ // @ts-expect-error
15
+ config.plugins.splice(index, 1);
16
+ }
17
+ },
18
+ transform(code, id) {
19
+ if (!(0, vue_1.isVueSfcFile)(id)) {
20
+ return;
21
+ }
22
+ return code.replace(/<script([^>]*)>/gi, (match, attributes) => {
23
+ // 如果 <script> 标签中没有 lang 属性,添加 lang="uts"
24
+ if (!/lang=["']?[^"']*["']?/.test(attributes)) {
25
+ return `<script${attributes} lang="uts">`;
26
+ }
27
+ // 否则,将现有的 lang 属性替换为 lang="uts"
28
+ return match.replace(/lang=["']?ts["']?/, 'lang="uts"');
29
+ });
30
+ },
31
+ };
32
+ }
33
+ exports.uniUTSJsPlugin = uniUTSJsPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3090220231010001",
3
+ "version": "3.0.0-alpha-3090320231017002",
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.21.3",
26
26
  "@babel/parser": "^7.16.4",
27
27
  "@babel/types": "^7.20.7",
28
- "@dcloudio/uni-i18n": "3.0.0-alpha-3090220231010001",
29
- "@dcloudio/uni-shared": "3.0.0-alpha-3090220231010001",
28
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3090320231017002",
29
+ "@dcloudio/uni-shared": "3.0.0-alpha-3090320231017002",
30
30
  "@intlify/core-base": "9.1.9",
31
31
  "@intlify/shared": "9.1.9",
32
32
  "@intlify/vue-devtools": "9.1.9",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
66
66
  "devDependencies": {
67
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-3090220231010001",
67
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-3090320231017002",
68
68
  "@types/babel__core": "^7.1.19",
69
69
  "@types/debug": "^4.1.7",
70
70
  "@types/estree": "^0.0.51",