@dcloudio/uni-cli-shared 3.0.0-alpha-1000920260909822 → 3.0.0-alpha-5020620260914001

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.
Files changed (69) hide show
  1. package/dist/dom2/script.js +0 -2
  2. package/dist/hbx/index.d.ts +1 -1
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.js +0 -1
  5. package/dist/json/manifest.d.ts +0 -3
  6. package/dist/json/manifest.js +1 -13
  7. package/dist/json/uni-x/index.d.ts +0 -1
  8. package/dist/json/uni-x/index.js +0 -4
  9. package/dist/logs/console.js +1 -12
  10. package/dist/resolve.js +0 -5
  11. package/dist/uasm.d.ts +0 -1
  12. package/dist/uasm.js +5 -11
  13. package/dist/vite/autoImport.js +2 -8
  14. package/dist/vite/cloud.js +9 -10
  15. package/dist/vite/extApi.js +2 -2
  16. package/dist/vite/index.d.ts +4 -9
  17. package/dist/vite/plugins/console.js +1 -2
  18. package/dist/vite/plugins/dynamicImportPolyfill.d.ts +1 -8
  19. package/dist/vite/plugins/index.d.ts +0 -1
  20. package/dist/vite/plugins/index.js +0 -1
  21. package/dist/vite/plugins/inject.js +1 -1
  22. package/dist/vite/plugins/jsonJs.d.ts +2 -2
  23. package/dist/vite/plugins/mainJs.d.ts +1 -1
  24. package/dist/vite/plugins/sourceMap.js +1 -4
  25. package/dist/vite/plugins/uts/uni_modules.js +15 -9
  26. package/dist/vite/plugins/uts/uvue.js +44 -103
  27. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +5 -12
  28. package/dist/vite/plugins/vitejs/plugins/asset.js +2 -4
  29. package/dist/vue/transforms/transformTeleport.js +1 -15
  30. package/dist/watcher.d.ts +0 -1
  31. package/dist/workers.d.ts +0 -1
  32. package/dist/workers.js +12 -16
  33. package/dist/x.d.ts +0 -1
  34. package/dist/x.js +1 -6
  35. package/lib/@vue/compiler-core/dist/compiler-core.cjs.js +23 -16
  36. package/lib/@vue/compiler-core/dist/compiler-core.cjs.prod.js +23 -16
  37. package/lib/@vue/compiler-core/dist/compiler-core.esm-bundler.js +23 -16
  38. package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +66 -23
  39. package/lib/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +115 -67
  40. package/lib/dom2/app/@vitejs/plugin-vue/dist/index.cjs +2 -6
  41. package/lib/dom2/app/@vitejs/plugin-vue/dist/index.mjs +2 -6
  42. package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.js +237 -249
  43. package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.prod.js +230 -235
  44. package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.d.ts +285 -252
  45. package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.esm-bundler.js +162 -159
  46. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.js +50 -50
  47. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +49 -49
  48. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.d.ts +11 -10
  49. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +214 -210
  50. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +6 -6
  51. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +49 -49
  52. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.js +214 -210
  53. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.prod.js +6 -6
  54. package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +377 -656
  55. package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.d.ts +137 -138
  56. package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +1057 -1222
  57. package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +195 -209
  58. package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.d.ts +356 -364
  59. package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +507 -569
  60. package/lib/dom2/app/@vue/compiler-vapor-dom2/dist/compiler-vapor-dom2.cjs.js +1 -1
  61. package/lib/dom2/app/@vue/shared/dist/shared.cjs.js +20 -41
  62. package/lib/dom2/app/@vue/shared/dist/shared.cjs.prod.js +20 -41
  63. package/lib/dom2/app/@vue/shared/dist/shared.d.ts +235 -235
  64. package/lib/dom2/app/@vue/shared/dist/shared.esm-bundler.js +20 -41
  65. package/package.json +6 -6
  66. package/dist/uts/scriptMacros.d.ts +0 -13
  67. package/dist/uts/scriptMacros.js +0 -52
  68. package/dist/vite/plugins/uts/standardScript.d.ts +0 -15
  69. package/dist/vite/plugins/uts/standardScript.js +0 -137
@@ -4,7 +4,6 @@ exports.uniVaporScriptPlugin = void 0;
4
4
  const uts_1 = require("../uts");
5
5
  const extApi_1 = require("../uts/extApi");
6
6
  const utils_1 = require("../utils");
7
- const scriptMacros_1 = require("../uts/scriptMacros");
8
7
  const sharedData_1 = require("./sharedData");
9
8
  function uniVaporScriptPlugin(options = {}) {
10
9
  const { uasm, ...sharedData } = options;
@@ -15,7 +14,6 @@ function uniVaporScriptPlugin(options = {}) {
15
14
  : undefined;
16
15
  return D2SP({
17
16
  typescript: (0, uts_1.resolveUTSCompiler)().getTypeScript(),
18
- createUniAppXScriptMacrosTransformer: scriptMacros_1.createUniAppXScriptMacrosTransformer,
19
17
  extApi,
20
18
  uasm,
21
19
  sharedData: {
@@ -1,5 +1,5 @@
1
1
  export { formatAtFilename, createErrorWithBlockFlag } from './log';
2
2
  export * from './env';
3
3
  export { initModuleAlias, installHBuilderXPlugin, formatInstallHBuilderXPluginTips, } from './alias';
4
- export declare function uniHBuilderXConsolePlugin(method?: string): import("vite/dist/node").Plugin<any>;
4
+ export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin<any>;
5
5
  export declare function isEnableConsole(): boolean;
package/dist/index.d.ts CHANGED
@@ -7,7 +7,6 @@ export * from './ssr';
7
7
  export * from './vue';
8
8
  export * from './uts';
9
9
  export * from './uts/extApi';
10
- export * from './uts/scriptMacros';
11
10
  export * from './x';
12
11
  export * from './logs';
13
12
  export * from './dom2';
package/dist/index.js CHANGED
@@ -24,7 +24,6 @@ __exportStar(require("./ssr"), exports);
24
24
  __exportStar(require("./vue"), exports);
25
25
  __exportStar(require("./uts"), exports);
26
26
  __exportStar(require("./uts/extApi"), exports);
27
- __exportStar(require("./uts/scriptMacros"), exports);
28
27
  __exportStar(require("./x"), exports);
29
28
  __exportStar(require("./logs"), exports);
30
29
  __exportStar(require("./dom2"), exports);
@@ -1,8 +1,5 @@
1
1
  export declare const parseManifestJson: (inputDir: string) => any;
2
2
  export declare const parseManifestJsonOnce: (inputDir: string) => any;
3
- export type UniAppXVaporScriptLang = 'js' | 'ts' | 'uts';
4
- export declare function resolveUniAppXVaporScriptLang(manifestJson: Record<string, any>): UniAppXVaporScriptLang;
5
- export declare function getUniAppXVaporScriptLang(inputDir?: string): UniAppXVaporScriptLang;
6
3
  export declare const parseRpx2UnitOnce: (inputDir: string, platform?: UniApp.PLATFORM) => any;
7
4
  export declare function getNativeTags(inputDir?: string, platform?: UniApp.PLATFORM): any;
8
5
  interface CompilerCompatConfig {
@@ -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.validateThemeValue = exports.getPlatformManifestJsonOnce = exports.getPlatformManifestJson = exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.hasPushModule = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.getNativeTags = exports.parseRpx2UnitOnce = exports.getUniAppXVaporScriptLang = exports.resolveUniAppXVaporScriptLang = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
6
+ exports.validateThemeValue = exports.getPlatformManifestJsonOnce = exports.getPlatformManifestJson = exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.hasPushModule = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.getNativeTags = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const shared_1 = require("@vue/shared");
@@ -21,18 +21,6 @@ const parseManifestJson = (inputDir) => {
21
21
  };
22
22
  exports.parseManifestJson = parseManifestJson;
23
23
  exports.parseManifestJsonOnce = (0, uni_shared_1.once)(exports.parseManifestJson);
24
- function resolveUniAppXVaporScriptLang(manifestJson) {
25
- const lang = manifestJson['uni-app-x']?.['vapor-default-script-lang'];
26
- return lang === 'js' || lang === 'ts' || lang === 'uts' ? lang : 'ts';
27
- }
28
- exports.resolveUniAppXVaporScriptLang = resolveUniAppXVaporScriptLang;
29
- function getUniAppXVaporScriptLang(inputDir) {
30
- if (!inputDir) {
31
- return 'ts';
32
- }
33
- return resolveUniAppXVaporScriptLang((0, exports.parseManifestJsonOnce)(inputDir));
34
- }
35
- exports.getUniAppXVaporScriptLang = getUniAppXVaporScriptLang;
36
24
  exports.parseRpx2UnitOnce = (0, uni_shared_1.once)((inputDir, platform = 'h5') => {
37
25
  const rpx2unit = platform === 'h5' || platform === 'app' || platform === 'app-harmony'
38
26
  ? uni_shared_1.defaultRpx2Unit
@@ -8,7 +8,6 @@ export interface UniXPageOptions {
8
8
  androidOverscroll?: boolean;
9
9
  androidRefresherColor?: string;
10
10
  backgroundColor?: string;
11
- backgroundTextStyle?: 'dark' | 'light';
12
11
  }
13
12
  export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.PagesJson;
14
13
  export declare function parseUniXPageOptions(filename: string): UniXPageOptions | undefined;
@@ -97,7 +97,6 @@ function updateUniXPageOptions(pagesJson) {
97
97
  function normalizeRootPageOptions(pageStyle, globalStyle) {
98
98
  const androidRefresherColor = pageStyle?.androidRefresherColor ?? globalStyle.androidRefresherColor;
99
99
  const backgroundColor = pageStyle?.backgroundColor ?? globalStyle.backgroundColor;
100
- const backgroundTextStyle = pageStyle?.backgroundTextStyle ?? globalStyle.backgroundTextStyle;
101
100
  return {
102
101
  disableScroll: pageStyle?.disableScroll === true || undefined,
103
102
  enablePullDownRefresh: (pageStyle && isEnablePullDownRefresh(pageStyle)) || undefined,
@@ -112,9 +111,6 @@ function normalizeRootPageOptions(pageStyle, globalStyle) {
112
111
  backgroundColor: backgroundColor?.startsWith('@')
113
112
  ? undefined
114
113
  : backgroundColor,
115
- backgroundTextStyle: backgroundTextStyle?.startsWith('@')
116
- ? undefined
117
- : backgroundTextStyle,
118
114
  };
119
115
  }
120
116
  function initUniXPageOptions() {
@@ -21,24 +21,13 @@ function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
21
21
  return {
22
22
  code: s.toString(),
23
23
  map: sourceMap
24
- ? normalizeSourceMap(s.generateMap({ hires: (0, x_1.shouldUseHighResolutionSourceMap)() }))
24
+ ? s.generateMap({ hires: (0, x_1.shouldUseHighResolutionSourceMap)() })
25
25
  : { mappings: '' },
26
26
  };
27
27
  }
28
28
  return { code, map: null };
29
29
  }
30
30
  exports.rewriteConsoleExpr = rewriteConsoleExpr;
31
- function normalizeSourceMap(map) {
32
- return {
33
- ...map,
34
- file: map.file || '',
35
- names: map.names || [],
36
- sources: map.sources || [],
37
- sourcesContent: map.sourcesContent || [],
38
- toString: () => map.toString(),
39
- toUrl: () => map.toUrl(),
40
- };
41
- }
42
31
  function restoreConsoleExpr(code) {
43
32
  return code.replace(/(?:uni\.)?__f__\('([^']+)','at ([^:]+):(\d+)',/g, 'console.$1(');
44
33
  }
package/dist/resolve.js CHANGED
@@ -47,11 +47,6 @@ exports.resolveMainPathOnce = (0, uni_shared_1.once)((inputDir) => {
47
47
  if (fs_1.default.existsSync(mainTsPath)) {
48
48
  return (0, utils_1.normalizePath)(mainTsPath);
49
49
  }
50
- if (process.env.UNI_APP_X === 'true' &&
51
- process.env.UNI_UTS_PLATFORM === 'app-android' &&
52
- process.env.UNI_APP_X_DOM2 !== 'true') {
53
- throw new Error('uni-app x Android VDOM 模式仅支持 main.uts 或 main.ts 入口文件');
54
- }
55
50
  return (0, utils_1.normalizePath)(path_1.default.resolve(inputDir, 'main.js'));
56
51
  });
57
52
  const ownerModules = [
package/dist/uasm.d.ts CHANGED
@@ -12,7 +12,6 @@ export interface LoadUasmTransformOptions {
12
12
  }
13
13
  export interface LoadUasmTransformerOptions extends LoadUasmTransformOptions {
14
14
  typescript: TypeScriptCompiler;
15
- methodNames?: readonly string[];
16
15
  resolveLoader?: (modulePath: string) => ResolvedUasmLoader | undefined;
17
16
  onSourceEdit?: (edit: UasmSourceEdit) => void;
18
17
  resolveError?: (modulePath: string) => string;
package/dist/uasm.js CHANGED
@@ -68,7 +68,6 @@ function initUasmWebTransformOptions() {
68
68
  createLoadUasmTransformer(options) {
69
69
  return createLoadUasmTransformer({
70
70
  ...options,
71
- methodNames: ['loadUasm'],
72
71
  resolveError(modulePath) {
73
72
  const moduleName = parseUasmModuleName(modulePath);
74
73
  const entry = moduleName
@@ -93,7 +92,6 @@ function createUasmDiagnostic(options, sourceFile, node, messageText) {
93
92
  }
94
93
  function createLoadUasmTransformer(options) {
95
94
  const { typescript, resolve, reportDiagnostic } = options;
96
- const methodNames = new Set(options.methodNames || ['loadUasm', 'loadUasmSync']);
97
95
  const targetArchs = options.targetArchs?.join(', ') || '未指定';
98
96
  return (context) => {
99
97
  const { factory } = context;
@@ -103,14 +101,13 @@ function createLoadUasmTransformer(options) {
103
101
  if (typescript.isCallExpression(node) &&
104
102
  node.arguments.length >= 1 &&
105
103
  typescript.isPropertyAccessExpression(node.expression) &&
106
- methodNames.has(node.expression.name.text) &&
104
+ node.expression.name.escapedText === 'loadUASM' &&
107
105
  typescript.isIdentifier(node.expression.expression) &&
108
106
  node.expression.expression.escapedText === 'uni') {
109
- const methodName = node.expression.name.text;
110
107
  const firstArg = node.arguments[0];
111
108
  if (!typescript.isStringLiteral(firstArg) &&
112
109
  !typescript.isNoSubstitutionTemplateLiteral(firstArg)) {
113
- reportDiagnostic(context, createUasmDiagnostic(options, sourceFile, firstArg, `uni.${methodName}(modulePath) 的 modulePath 参数必须是字符串字面量`));
110
+ reportDiagnostic(context, createUasmDiagnostic(options, sourceFile, firstArg, 'uni.loadUASM(modulePath) 的 modulePath 参数必须是字符串字面量'));
114
111
  return node;
115
112
  }
116
113
  const resolved = resolve(firstArg.text);
@@ -226,7 +223,7 @@ function copyUasmIOSFrameworks(inputDir) {
226
223
  return;
227
224
  }
228
225
  const libraryIdentifier = process.env.HX_RUN_DEVICE_TYPE === 'ios_simulator'
229
- ? 'ios-arm64_x86_64-simulator'
226
+ ? 'ios-arm64-simulator'
230
227
  : 'ios-arm64';
231
228
  const targetDir = node_path_1.default.resolve(dependenciesDir, 'modules');
232
229
  for (const module of Object.values(uasmModules)) {
@@ -341,9 +338,6 @@ function parseUasmModuleName(modulePath) {
341
338
  return /^uni_modules\/([^/]+)$/.exec(normalized)?.[1];
342
339
  }
343
340
  exports.parseUasmModuleName = parseUasmModuleName;
344
- function resolveUasmLibraryFileName(moduleName) {
345
- return `libUasm${(0, utils_1.capitalize)((0, utils_1.camelize)(moduleName))}.so`;
346
- }
347
341
  function resolveUasmWebLoad(modulePath) {
348
342
  const moduleName = parseUasmModuleName(modulePath);
349
343
  const entry = moduleName && uasmModules[moduleName]?.web?.entry;
@@ -365,7 +359,7 @@ function resolveUasmLoadPath(modulePath, platform, isProduction = (process.env.U
365
359
  if (platform === 'app-ios') {
366
360
  return moduleName;
367
361
  }
368
- const libraryName = resolveUasmLibraryFileName(moduleName);
362
+ const libraryName = `lib${moduleName}.so`;
369
363
  if (isProduction) {
370
364
  return libraryName;
371
365
  }
@@ -435,7 +429,7 @@ function scanUasmPlatform(inputDir, moduleName, platform) {
435
429
  return;
436
430
  }
437
431
  const relativeArchDir = (0, utils_1.normalizePath)(node_path_1.default.join(relativeDir, entry.name));
438
- const file = (0, utils_1.normalizePath)(node_path_1.default.join(relativeArchDir, resolveUasmLibraryFileName(moduleName)));
432
+ const file = (0, utils_1.normalizePath)(node_path_1.default.join(relativeArchDir, `lib${moduleName}.so`));
439
433
  if (!fs_extra_1.default.existsSync(node_path_1.default.resolve(inputDir, file))) {
440
434
  return;
441
435
  }
@@ -311,19 +311,13 @@ function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
311
311
  autoImport.push(utsJsPreset);
312
312
  }
313
313
  }
314
- // node_modules 可能包含依赖 auto import 的 uni-app x 源码包,不能恢复 unplugin 的默认排除项。
315
- const exclude = [
316
- /[\\/]\.git[\\/]/,
317
- // @dcloudio 包中的 JS 是自带完整导入的官方产物,正则扫描导出别名或继承类时可能误判,
318
- // 进而产生自引用或重复声明。
319
- /[\\/]@dcloudio[\\/].*\.js$/,
320
- ];
314
+ const exclude = [/[\\/]\.git[\\/]/];
321
315
  if (process.env.UNI_INPUT_DIR) {
322
316
  exclude.push(...(0, workers_1.resolveWorkersDir)(process.env.UNI_INPUT_DIR).map((dir) => (0, utils_1.normalizePath)(path_1.default.join(process.env.UNI_INPUT_DIR, dir, '*'))));
323
317
  }
324
318
  return {
325
319
  ...userOptions,
326
- include: [/\.(?:js|ts|uts)$/, /\.[u]?vue/],
320
+ include: [/\.[u]?ts$/, /\.[u]?vue/],
327
321
  exclude,
328
322
  imports: imports.concat(
329
323
  // 旧版 Android x 仍由专有编译流程处理,Android Vapor 对齐 iOS 走通用自动导入
@@ -74,7 +74,7 @@ function uniEncryptUniModulesPlugin() {
74
74
  apply: 'build',
75
75
  config() {
76
76
  const build = initEncryptUniModulesBuildOptions(process.env.UNI_UTS_PLATFORM, process.env.UNI_INPUT_DIR);
77
- Object.keys(build.rolldownOptions?.input || {}).forEach((key) => {
77
+ Object.keys(build.rollupOptions?.input || {}).forEach((key) => {
78
78
  encryptModuleOutputFiles.push(key + '.js');
79
79
  });
80
80
  return {
@@ -92,7 +92,7 @@ function uniEncryptUniModulesPlugin() {
92
92
  }
93
93
  // 编译组件时,禁用内联资源
94
94
  config.build.assetsInlineLimit = 0;
95
- config.build.rolldownOptions.external = createExternal(config);
95
+ config.build.rollupOptions.external = createExternal(config);
96
96
  resolvedConfig = config;
97
97
  },
98
98
  resolveId(id, importer) {
@@ -132,13 +132,16 @@ function uniEncryptUniModulesPlugin() {
132
132
  }
133
133
  delete bundle[fileName];
134
134
  const pkg = `uni_modules/${uniModuleId}/package.json`;
135
- this.emitFile({
135
+ bundle[pkg] = {
136
136
  type: 'asset',
137
137
  fileName: pkg,
138
+ name: pkg,
139
+ originalFileName: null,
140
+ needsCodeReference: false,
138
141
  source: genUniModulesPackageJson(uniModuleId, process.env.UNI_INPUT_DIR, {
139
142
  env: (0, uni_modules_cloud_1.initCheckEnv)(),
140
143
  }),
141
- });
144
+ };
142
145
  }
143
146
  else if (fileName.endsWith('.js')) {
144
147
  if (isMp) {
@@ -185,18 +188,14 @@ function uniEncryptUniModulesPlugin() {
185
188
  if (uniXKotlinCompiler) {
186
189
  const tscOutputDir = tscOutDir('app-android');
187
190
  const uniModulesDir = path_1.default.resolve(tscOutputDir, 'uni_modules');
188
- const rootFiles = [];
189
191
  if (fs_extra_1.default.existsSync(uniModulesDir)) {
190
192
  for (const plugin of fs_extra_1.default.readdirSync(uniModulesDir)) {
191
193
  const indexFileName = path_1.default.join(uniModulesDir, plugin, 'index.module.uts.ts');
192
194
  if (fs_extra_1.default.existsSync(indexFileName)) {
193
- rootFiles.push(indexFileName);
195
+ await uniXKotlinCompiler.addRootFile(indexFileName);
194
196
  }
195
197
  }
196
198
  }
197
- if (rootFiles.length) {
198
- await uniXKotlinCompiler.addRootFiles([...new Set(rootFiles)]);
199
- }
200
199
  await uniXKotlinCompiler.close();
201
200
  }
202
201
  // 编译所有 uni_modules 插件
@@ -342,7 +341,7 @@ function initEncryptUniModulesBuildOptions(platform, inputDir) {
342
341
  lib: false, // 不使用 lib 模式,lib模式会直接内联资源
343
342
  cssCodeSplit: false,
344
343
  // outDir: process.env.UNI_OUTPUT_DIR,
345
- rolldownOptions: {
344
+ rollupOptions: {
346
345
  preserveEntrySignatures: 'strict',
347
346
  input,
348
347
  output: {
@@ -9,7 +9,7 @@ function uniUniModulesExtApiPlugin() {
9
9
  name: 'uni:uni-modules_ext-api',
10
10
  apply: 'build',
11
11
  config() {
12
- const rolldownOptions = {
12
+ const rollupOptions = {
13
13
  input: (0, resolve_1.resolveMainPathOnce)(process.env.UNI_INPUT_DIR),
14
14
  external: ['vue'],
15
15
  output: {
@@ -25,7 +25,7 @@ function uniUniModulesExtApiPlugin() {
25
25
  if (process.env.UNI_UTS_PLATFORM === 'app-ios' ||
26
26
  process.env.UNI_UTS_PLATFORM === 'app-harmony' ||
27
27
  (0, x_1.isUniAppXAndroidJsEngine)()) {
28
- build.rolldownOptions = rolldownOptions;
28
+ build.rollupOptions = rollupOptions;
29
29
  }
30
30
  return {
31
31
  build,
@@ -1,4 +1,5 @@
1
- import type { Plugin, ResolvedConfig, Rolldown } from 'vite';
1
+ import type { Plugin } from 'vite';
2
+ import type { EmittedAsset } from 'rollup';
2
3
  import type { ExistingRawSourceMap } from 'rollup';
3
4
  import type { ParserOptions } from '@vue/compiler-core';
4
5
  import type { CompilerOptions, SFCStyleCompileOptions, TemplateCompiler } from '@vue/compiler-sfc';
@@ -26,7 +27,7 @@ interface UniVitePluginUniOptions {
26
27
  styleOptions?: Pick<SFCStyleCompileOptions, 'postcssPlugins'>;
27
28
  compilerOptions?: {
28
29
  miniProgram?: {
29
- emitFile?: (emittedFile: Rolldown.EmittedAsset) => string;
30
+ emitFile?: (emittedFile: EmittedAsset) => string;
30
31
  };
31
32
  isNativeTag?: ParserOptions['isNativeTag'];
32
33
  isVoidTag?: ParserOptions['isVoidTag'];
@@ -40,13 +41,7 @@ interface UniVitePluginUniOptions {
40
41
  };
41
42
  copyOptions?: CopyOptions | (() => CopyOptions);
42
43
  }
43
- type UniViteConfigResolvedHook = ((config: ResolvedConfig) => void | Promise<void>) | {
44
- handler: (config: ResolvedConfig) => void | Promise<void>;
45
- order?: 'pre' | 'post' | null;
46
- sequential?: boolean;
47
- };
48
- export interface UniVitePlugin extends Omit<Plugin, 'configResolved'> {
49
- configResolved?: UniViteConfigResolvedHook;
44
+ export interface UniVitePlugin extends Plugin {
50
45
  uni?: UniVitePluginUniOptions;
51
46
  }
52
47
  export * from './utils';
@@ -22,8 +22,7 @@ function uniConsolePlugin(options) {
22
22
  resolvedConfig = config;
23
23
  // 理论上发行模式就不应该有这个逻辑了,只不过为了尽量不引发兼容性问题,目前严谨一些判断是否配置了 drop_console
24
24
  if (process.env.NODE_ENV !== 'development') {
25
- const compressOptions = resolvedConfig.build.terserOptions
26
- ?.compress;
25
+ const compressOptions = resolvedConfig.build.terserOptions?.compress;
27
26
  if (compressOptions && typeof compressOptions === 'object') {
28
27
  dropConsole = !!compressOptions.drop_console;
29
28
  }
@@ -1,9 +1,2 @@
1
1
  import type { Plugin } from 'vite';
2
- interface DynamicImportPolyfillPlugin extends Plugin {
3
- renderDynamicImport(): {
4
- left: string;
5
- right: string;
6
- };
7
- }
8
- export declare function dynamicImportPolyfill(promise?: boolean): DynamicImportPolyfillPlugin;
9
- export {};
2
+ export declare function dynamicImportPolyfill(promise?: boolean): Plugin;
@@ -7,7 +7,6 @@ export * from './console';
7
7
  export * from './dynamicImportPolyfill';
8
8
  export * from './uts/uni_modules';
9
9
  export * from './uts/uvue';
10
- export * from './uts/standardScript';
11
10
  export * from './uts/ext-api';
12
11
  export * from './easycom';
13
12
  export * from './json';
@@ -24,7 +24,6 @@ __exportStar(require("./console"), exports);
24
24
  __exportStar(require("./dynamicImportPolyfill"), exports);
25
25
  __exportStar(require("./uts/uni_modules"), exports);
26
26
  __exportStar(require("./uts/uvue"), exports);
27
- __exportStar(require("./uts/standardScript"), exports);
28
27
  __exportStar(require("./uts/ext-api"), exports);
29
28
  __exportStar(require("./easycom"), exports);
30
29
  __exportStar(require("./json"), exports);
@@ -39,7 +39,7 @@ function uniViteInjectPlugin(name, options) {
39
39
  normalizeModulesMap(modulesMap);
40
40
  normalizeModulesMap(namespaceModulesMap);
41
41
  }
42
- const firstpass = new RegExp(`(?:${Array.from(modulesMap.keys()).map(escape).join('|')})`);
42
+ const firstpass = new RegExp(`(?:${Array.from(modulesMap.keys()).map(escape).join('|')})`, 'g');
43
43
  let sourceMap = options.sourceMap !== false;
44
44
  const callback = options.callback;
45
45
  return {
@@ -1,3 +1,3 @@
1
1
  import type { CreateUniViteFilterPlugin } from '../utils/plugin';
2
- export declare const defineUniPagesJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite/dist/node").Plugin<any>;
3
- export declare const defineUniManifestJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite/dist/node").Plugin<any>;
2
+ export declare const defineUniPagesJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite").Plugin<any>;
3
+ export declare const defineUniManifestJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite").Plugin<any>;
@@ -1,2 +1,2 @@
1
1
  import type { CreateUniViteFilterPlugin } from '../utils/plugin';
2
- export declare function defineUniMainJsPlugin(createUniMainJsPlugin: CreateUniViteFilterPlugin): import("vite/dist/node").Plugin<any>;
2
+ export declare function defineUniMainJsPlugin(createUniMainJsPlugin: CreateUniViteFilterPlugin): import("vite").Plugin<any>;
@@ -24,9 +24,6 @@ function uniSourceMapPlugin(options) {
24
24
  const tasks = Object.entries(bundle)
25
25
  .filter(([file]) => file.endsWith('.js.map'))
26
26
  .map(async ([file, asset]) => {
27
- if (asset.type !== 'asset') {
28
- return;
29
- }
30
27
  const source = asset.source;
31
28
  const targetPath = path_1.default.resolve(options.sourceMapDir, file);
32
29
  // 快速计算内容哈希
@@ -60,7 +57,7 @@ function uniSourceMapPlugin(options) {
60
57
  // 更新引用
61
58
  const jsFile = file.replace('.js.map', '.js');
62
59
  const outputChunk = bundle[jsFile];
63
- if (outputChunk?.type === 'chunk') {
60
+ if (outputChunk) {
64
61
  outputChunk.code = outputChunk.code.replace(/\/\/# sourceMappingURL=.*/, `//# sourceMappingURL=${(0, utils_1.normalizePath)(path_1.default.relative(file, options.relativeSourceMapDir))}/${file}`);
65
62
  }
66
63
  delete bundle[file];
@@ -294,25 +294,31 @@ function uniUTSAppUniModulesPlugin(options = {}) {
294
294
  utsPlugins.add(pluginId);
295
295
  if (uniXKotlinCompiler) {
296
296
  const platform = 'app-android';
297
- const rootFiles = resolveTscUniModuleUTSSDKVueFileNames(platform, pluginDir);
297
+ const vueFiles = resolveTscUniModuleUTSSDKVueFileNames(platform, pluginDir);
298
+ for (const vueFile of vueFiles) {
299
+ await uniXKotlinCompiler.addRootFile(vueFile);
300
+ }
298
301
  const indexFileName = resolveTscUniModuleIndexFileName(platform, pluginDir);
299
- await uniXKotlinCompiler.addRootFiles([
300
- ...new Set([...rootFiles, indexFileName].filter(Boolean)),
301
- ]);
302
+ if (indexFileName) {
303
+ await uniXKotlinCompiler.addRootFile(indexFileName);
304
+ }
302
305
  }
303
306
  if (uniXSwiftCompiler) {
304
307
  const platform = 'app-ios';
305
- const rootFiles = resolveTscUniModuleUTSSDKVueFileNames(platform, pluginDir);
308
+ const vueFiles = resolveTscUniModuleUTSSDKVueFileNames(platform, pluginDir);
309
+ for (const vueFile of vueFiles) {
310
+ await uniXSwiftCompiler.addRootFile(vueFile);
311
+ }
306
312
  const indexFileName = resolveTscUniModuleIndexFileName(platform, pluginDir);
307
- await uniXSwiftCompiler.addRootFiles([
308
- ...new Set([...rootFiles, indexFileName].filter(Boolean)),
309
- ]);
313
+ if (indexFileName) {
314
+ await uniXSwiftCompiler.addRootFile(indexFileName);
315
+ }
310
316
  }
311
317
  if (uniXArkTSCompiler) {
312
318
  const platform = 'app-harmony';
313
319
  const indexFileName = resolveTscUniModuleIndexFileName(platform, pluginDir);
314
320
  if (indexFileName) {
315
- await uniXArkTSCompiler.addRootFiles([indexFileName]);
321
+ await uniXArkTSCompiler.addRootFile(indexFileName);
316
322
  }
317
323
  }
318
324
  }