@dcloudio/vite-plugin-uni 3.0.0-5000520260324001 → 3.0.0-5000520260324002

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.
@@ -48,8 +48,7 @@ async function runDev(options) {
48
48
  options.minify = true;
49
49
  }
50
50
  (0, utils_1.initEnv)('dev', options);
51
- if (process.env.UNI_APP_X === 'true' &&
52
- process.env.UNI_UTS_PLATFORM === 'app-android') {
51
+ if ((0, uni_cli_shared_1.isUniAppXAndroidNative)()) {
53
52
  return (0, uvue_1.runUVueAndroidDev)(options);
54
53
  }
55
54
  const createLogger = await Promise.resolve().then(() => __importStar(require('vite'))).then(({ createLogger }) => createLogger);
@@ -101,11 +100,12 @@ async function runDev(options) {
101
100
  }
102
101
  const utsChanged = process.env.UNI_APP_UTS_CHANGED === 'true';
103
102
  process.env.UNI_APP_UTS_CHANGED = '';
103
+ let changedFiles = '';
104
104
  if (options.platform === 'app') {
105
105
  const files = process.env.UNI_APP_CHANGED_FILES;
106
106
  const pages = process.env.UNI_APP_CHANGED_PAGES;
107
107
  const dex = process.env.UNI_APP_UTS_CHANGED_FILES;
108
- const changedFiles = pages || files;
108
+ changedFiles = pages || files;
109
109
  process.env.UNI_APP_CHANGED_PAGES = '';
110
110
  process.env.UNI_APP_CHANGED_FILES = '';
111
111
  process.env.UNI_APP_UTS_CHANGED_FILES = '';
@@ -138,7 +138,10 @@ async function runDev(options) {
138
138
  utsChanged) {
139
139
  return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end']);
140
140
  }
141
- return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['uvue.dev.watching.end.empty']);
141
+ // 没有cpp/uts插件变更,且没有增量js文件变更,就输出无变更
142
+ if (!changedFiles) {
143
+ return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['uvue.dev.watching.end.empty']);
144
+ }
142
145
  }
143
146
  return (0, uni_cli_shared_1.output)('log', uni_cli_shared_1.M['dev.watching.end']);
144
147
  }
@@ -174,8 +177,7 @@ async function runDev(options) {
174
177
  exports.runDev = runDev;
175
178
  async function runBuild(options) {
176
179
  (0, utils_1.initEnv)('build', options);
177
- if (process.env.UNI_APP_X === 'true' &&
178
- process.env.UNI_UTS_PLATFORM === 'app-android') {
180
+ if ((0, uni_cli_shared_1.isUniAppXAndroidNative)()) {
179
181
  return (0, uvue_1.runUVueAndroidBuild)(options);
180
182
  }
181
183
  try {
package/dist/cli/utils.js CHANGED
@@ -176,7 +176,7 @@ function initEnv(type, options) {
176
176
  manifestJson['app-plus']?.['utsCompilerVersion'] === 'v1') {
177
177
  process.env.UNI_APP_X_TSC = 'false';
178
178
  }
179
- if (manifestJson['uni-app-x']?.['styleIsolationVersion'] === '2') {
179
+ if (manifestJson['uni-app-x']?.['styleIsolationVersion'] == 2) {
180
180
  process.env.UNI_APP_STYLE_ISOLATION_VERSION = '2';
181
181
  }
182
182
  }
@@ -226,14 +226,12 @@ function initEnv(type, options) {
226
226
  ? 'true'
227
227
  : 'false';
228
228
  (0, uni_cli_shared_1.initPreContext)(process.env.UNI_PLATFORM, process.env.UNI_CUSTOM_CONTEXT, process.env.UNI_UTS_PLATFORM, process.env.UNI_APP_X === 'true');
229
- // 应该全平台都显示吧,当初为啥只在部分平台显示?
230
- if (process.env.UNI_PLATFORM === 'app' ||
231
- process.env.UNI_PLATFORM === 'web' ||
232
- process.env.UNI_PLATFORM === 'h5' ||
233
- process.env.UNI_PLATFORM === 'app-harmony') {
234
- console.log(uni_cli_shared_1.M['app.compiler.version'].replace('{version}', process.env.UNI_COMPILER_VERSION +
235
- `(${process.env.UNI_APP_X === 'true' ? 'uni-app x' : 'vue3'})` +
236
- (process.env.UNI_APP_X_DOM2 === 'true' ? '蒸汽模式' : '')));
229
+ const isX = (0, uni_cli_shared_1.isUniAppX)();
230
+ console.log(uni_cli_shared_1.M['app.compiler.version'].replace('{version}', process.env.UNI_COMPILER_VERSION +
231
+ `(${isX ? 'uni-app x' : 'vue3'})` +
232
+ (process.env.UNI_APP_X_DOM2 === 'true' ? '蒸汽模式' : '')));
233
+ if (isX && !(0, uni_cli_shared_1.isUniAppXVapor)()) {
234
+ console.log(uni_cli_shared_1.M['style.isolation.version'].replace('{version}', (process.env.UNI_APP_STYLE_ISOLATION_VERSION || '1') + '.0'));
237
235
  }
238
236
  console.log(uni_cli_shared_1.M['compiling']);
239
237
  }
package/dist/cli/uvue.js CHANGED
@@ -26,8 +26,8 @@ function initUVueEnv() {
26
26
  }
27
27
  if (process.env.UNI_PLATFORM === 'app') {
28
28
  process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE = 'native';
29
- // 如果是app-ios,目前强制使用js引擎
30
- if (process.env.UNI_UTS_PLATFORM === 'app-ios') {
29
+ // App X iOS 与 Android Vapor 统一使用 JS 引擎
30
+ if ((0, uni_cli_shared_1.isUniAppXIOS)() || (0, uni_cli_shared_1.isUniAppXAndroidVapor)()) {
31
31
  process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE = 'js';
32
32
  }
33
33
  }
package/dist/index.d.ts CHANGED
@@ -25,3 +25,4 @@ export interface VitePluginUniResolvedOptions extends VitePluginUniOptions {
25
25
  }
26
26
  export { runDev, runBuild } from './cli/action';
27
27
  export default function uniPlugin(rawOptions?: VitePluginUniOptions): Plugin[];
28
+ export declare function shouldMoveSourceMapFromCache(): boolean | "";
package/dist/index.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.runBuild = exports.runDev = void 0;
6
+ exports.shouldMoveSourceMapFromCache = exports.runBuild = exports.runDev = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const vite_1 = __importDefault(require("unplugin-auto-import/vite"));
9
9
  const plugin_vue_jsx_1 = __importDefault(require("@vitejs/plugin-vue-jsx"));
@@ -41,13 +41,11 @@ function uniPlugin(rawOptions = {}) {
41
41
  };
42
42
  options.platform = process.env.UNI_PLATFORM || 'h5';
43
43
  options.inputDir = process.env.UNI_INPUT_DIR;
44
- const plugins = process.env.UNI_APP_X === 'true' &&
45
- process.env.UNI_UTS_PLATFORM === 'app-android'
44
+ const plugins = (0, uni_cli_shared_1.isUniAppXAndroidNative)()
46
45
  ? createUVueAndroidPlugins(options)
47
46
  : createPlugins(options);
48
47
  // x 提供 auto import(非android、android自行处理)
49
- if (process.env.UNI_APP_X === 'true' &&
50
- process.env.UNI_UTS_PLATFORM !== 'app-android') {
48
+ if (process.env.UNI_APP_X === 'true' && !(0, uni_cli_shared_1.isUniAppXAndroidNative)()) {
51
49
  plugins.unshift((0, vite_1.default)((0, uni_cli_shared_1.initAutoImportOptions)(process.env.UNI_UTS_PLATFORM, options.autoImportOptions || {})));
52
50
  }
53
51
  plugins.unshift((0, uni_cli_shared_1.uniJsonPlugin)());
@@ -63,7 +61,9 @@ function createPlugins(options) {
63
61
  // iOS 暂不使用该机制
64
62
  process.env.UNI_UTS_PLATFORM !== 'app-ios' &&
65
63
  // harmony 同 iOS
66
- process.env.UNI_UTS_PLATFORM !== 'app-harmony') {
64
+ process.env.UNI_UTS_PLATFORM !== 'app-harmony' &&
65
+ // Android Vapor 暂不使用该机制(只有 Android Native 会进入该方法,不需要额外判断)
66
+ process.env.UNI_UTS_PLATFORM !== 'app-android') {
67
67
  plugins.push((0, uni_cli_shared_1.uniUTSExtApiReplace)());
68
68
  }
69
69
  else {
@@ -135,10 +135,7 @@ function createPlugins(options) {
135
135
  if (fs_1.default.existsSync(sourceMapPath)) {
136
136
  (0, uni_cli_shared_1.emptyDir)(sourceMapPath);
137
137
  }
138
- if (process.env.UNI_APP_X === 'true' &&
139
- process.env.UNI_UTS_PLATFORM === 'app-ios' &&
140
- process.env.UNI_APP_X_CACHE_DIR &&
141
- process.env.NODE_ENV !== 'development') {
138
+ if (shouldMoveSourceMapFromCache()) {
142
139
  plugins.push((0, move_1.uniMovePlugin)({
143
140
  apply: 'build',
144
141
  enforce: 'post',
@@ -190,3 +187,10 @@ function createUVueAndroidPlugins(options) {
190
187
  function resolveSourceMapDirByCacheDir() {
191
188
  return path_1.default.resolve(process.env.UNI_APP_X_CACHE_DIR, 'sourcemap');
192
189
  }
190
+ function shouldMoveSourceMapFromCache() {
191
+ return (process.env.UNI_APP_X === 'true' &&
192
+ process.env.UNI_APP_X_CACHE_DIR &&
193
+ process.env.NODE_ENV !== 'development' &&
194
+ ((0, uni_cli_shared_1.isUniAppXIOS)() || (0, uni_cli_shared_1.isUniAppXAndroidJsEngine)()));
195
+ }
196
+ exports.shouldMoveSourceMapFromCache = shouldMoveSourceMapFromCache;
@@ -12,9 +12,8 @@ const debugCopy = (0, debug_1.default)('uni:copy');
12
12
  function uniCopyPlugin({ outputDir, copyOptions, }) {
13
13
  const staticDir = uni_cli_shared_1.PUBLIC_DIR + '/**/*';
14
14
  const uniModulesStaticDir = 'uni_modules/*/' + uni_cli_shared_1.PUBLIC_DIR + '/**/*';
15
- const isDom2Harmony = process.env.UNI_APP_X_DOM2 === 'true' &&
16
- process.env.UNI_PLATFORM === 'app-harmony';
17
- const uniModulesCppDir = isDom2Harmony ? 'uni_modules/*/cppsdk/**/*' : '';
15
+ const isDom2 = process.env.UNI_APP_X_DOM2 === 'true';
16
+ const uniModulesCppDir = isDom2 ? 'uni_modules/*/cppsdk/**/*' : '';
18
17
  const assets = [staticDir, uniModulesStaticDir];
19
18
  const cppAssets = [];
20
19
  if (uniModulesCppDir) {
@@ -67,10 +66,10 @@ function uniCopyPlugin({ outputDir, copyOptions, }) {
67
66
  },
68
67
  ];
69
68
  targets.push(...copyOptions.targets);
70
- if (process.env.UNI_APP_HARMONY_DOM2_CPP_DIR && cppAssets.length) {
69
+ if (process.env.UNI_APP_X_DOM2_CPP_DIR && cppAssets.length) {
71
70
  targets.push({
72
71
  src: cppAssets,
73
- dest: process.env.UNI_APP_HARMONY_DOM2_CPP_DIR,
72
+ dest: process.env.UNI_APP_X_DOM2_CPP_DIR,
74
73
  watchOptions: {
75
74
  readyTimeout: getReadyTimeout(),
76
75
  ignored(path) {
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.initPluginViteLegacyOptions = exports.initPluginVueJsxOptions = exports.initPluginVueOptions = exports.createPluginVueInstance = void 0;
7
- const path_1 = __importDefault(require("path"));
8
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
8
  const shared_1 = require("@vue/shared");
10
9
  const uni_shared_1 = require("@dcloudio/uni-shared");
@@ -53,10 +52,9 @@ function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
53
52
  }
54
53
  const templateOptions = vueOptions.template || (vueOptions.template = {});
55
54
  const compilerOptions = templateOptions.compilerOptions || (templateOptions.compilerOptions = {});
56
- const isDom2Harmony = process.env.UNI_APP_X_DOM2 === 'true' &&
57
- process.env.UNI_PLATFORM === 'app-harmony';
55
+ const isDom2 = process.env.UNI_APP_X_DOM2 === 'true';
58
56
  compilerOptions.isX = process.env.UNI_APP_X === 'true';
59
- compilerOptions.dom2 = isDom2Harmony;
57
+ compilerOptions.dom2 = isDom2;
60
58
  // 默认就移除comments节点
61
59
  compilerOptions.comments = false;
62
60
  const { compiler, styleOptions: { postcssPlugins }, compilerOptions: { miniProgram, isNativeTag, isVoidTag, isCustomElement, nodeTransforms, directiveTransforms, whitespace, }, } = uniPluginOptions;
@@ -145,7 +143,7 @@ function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
145
143
  };
146
144
  }
147
145
  if (options.platform !== 'h5' && options.platform !== 'web') {
148
- compilerOptions.nodeTransforms.push(...(0, uni_cli_shared_1.getBaseNodeTransforms)(options.base, isDom2Harmony ? (0, uni_cli_shared_1.createResolveStaticAsset)(options.inputDir) : undefined));
146
+ compilerOptions.nodeTransforms.push(...(0, uni_cli_shared_1.getBaseNodeTransforms)(options.base, isDom2 ? (0, uni_cli_shared_1.createResolveStaticAsset)(options.inputDir) : undefined));
149
147
  }
150
148
  if (nodeTransforms) {
151
149
  compilerOptions.nodeTransforms.push(...nodeTransforms);
@@ -216,7 +214,7 @@ function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
216
214
  if (!vueOptions.script.babelParserPlugins.includes('decorators')) {
217
215
  vueOptions.script.babelParserPlugins.push('decorators');
218
216
  }
219
- if (isDom2Harmony) {
217
+ if (isDom2) {
220
218
  const appVue = (0, uni_cli_shared_1.resolveAppVue)(process.env.UNI_INPUT_DIR);
221
219
  function isAppVue(id) {
222
220
  return (0, uni_cli_shared_1.normalizePath)(id) === appVue;
@@ -231,6 +229,8 @@ function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
231
229
  vueOptions.script.extraOptions = (descriptor) => {
232
230
  return {
233
231
  isWatch: process.env.NODE_ENV === 'development',
232
+ // TODO 目前使用全局开关,后续可能是页面级别的开关?
233
+ dynamicSharedData: process.env.UNI_APP_X_DOM2_DYNAMIC === 'true',
234
234
  helper: (0, uni_cli_shared_1.requireUniHelpers)(),
235
235
  componentType: (0, uni_cli_shared_1.isUniPageFile)(descriptor.filename)
236
236
  ? 'page'
@@ -239,31 +239,8 @@ function initPluginVueOptions(options, UniVitePlugins, uniPluginOptions) {
239
239
  : 'component',
240
240
  };
241
241
  };
242
- let disableStaticStyle = false;
243
- if (isDevX && process.env.NODE_ENV === 'development') {
244
- if (process.env.UNI_UTS_PLATFORM === 'app-harmony') {
245
- // 开发版本、开发模式下,非鸿蒙release模式打包
246
- disableStaticStyle =
247
- process.env.UNI_APP_HARMONY_RUN_MODE !== 'release';
248
- }
249
- }
250
- ;
251
242
  vueOptions.template.compilerOptions.extraOptions = (descriptor) => {
252
- const filename = (0, uni_cli_shared_1.normalizePath)(descriptor.filename.split('?')[0]);
253
- const relativeFilename = (0, uni_cli_shared_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename));
254
- return {
255
- root: (0, uni_cli_shared_1.normalizePath)(process.env.UNI_INPUT_DIR),
256
- platform: process.env.UNI_UTS_PLATFORM,
257
- componentType: (0, uni_cli_shared_1.isUniPageFile)(filename) ? 'page' : 'component',
258
- relativeFilename,
259
- helper: (0, uni_cli_shared_1.requireUniHelpers)(),
260
- scriptCppBlocks: descriptor.scriptCppBlocks,
261
- genVueId: !!process.env.UNI_AUTOMATOR_WS_ENDPOINT,
262
- disableStaticStyle,
263
- onVueTemplateCompileLog(type, error) {
264
- return (0, uni_cli_shared_1.onVueTemplateCompileLog)(type, error, descriptor.source, relativeFilename);
265
- },
266
- };
243
+ return (0, uni_cli_shared_1.initVueTemplateCompilerExtraOptions)(descriptor);
267
244
  };
268
245
  }
269
246
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/vite-plugin-uni",
3
- "version": "3.0.0-5000520260324001",
3
+ "version": "3.0.0-5000520260324002",
4
4
  "description": "uni-app vite plugin",
5
5
  "bin": {
6
6
  "uni": "bin/uni.js"
@@ -44,9 +44,9 @@
44
44
  "picocolors": "1.1.0",
45
45
  "terser": "^5.4.0",
46
46
  "unplugin-auto-import": "19.1.0",
47
- "@dcloudio/uni-shared": "3.0.0-5000520260324001",
48
- "@dcloudio/uni-cli-shared": "3.0.0-5000520260324001",
49
- "@dcloudio/uni-nvue-styler": "3.0.0-5000520260324001"
47
+ "@dcloudio/uni-cli-shared": "3.0.0-5000520260324002",
48
+ "@dcloudio/uni-nvue-styler": "3.0.0-5000520260324002",
49
+ "@dcloudio/uni-shared": "3.0.0-5000520260324002"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/debug": "4.1.12",