@dcloudio/uni-cli-shared 3.0.0-alpha-4010720240511002 → 3.0.0-alpha-4010820240516001

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/easycom.js CHANGED
@@ -188,7 +188,12 @@ function initAutoScanEasycom(dir, rootDir, extensions) {
188
188
  const ext = extensions[i];
189
189
  if (files.includes(name + ext)) {
190
190
  easycoms[`^${name}$`] = is_encrypt_uni_modules
191
- ? (0, utils_1.normalizePath)(path_1.default.join(rootDir, `uni_modules/${uni_modules_plugin_id}?uni_helpers`))
191
+ ? (0, utils_1.normalizePath)(path_1.default.join(rootDir, `uni_modules/${uni_modules_plugin_id}?${
192
+ // android 走 proxy
193
+ process.env.UNI_APP_X === 'true' &&
194
+ process.env.UNI_UTS_PLATFORM === 'app-android'
195
+ ? 'uts-proxy'
196
+ : 'uni_helpers'}`))
192
197
  : `${importDir}/${name}${ext}`;
193
198
  break;
194
199
  }
@@ -80,7 +80,11 @@ export declare function parseUniModulesWithComponents(inputDir: string): Record<
80
80
  */
81
81
  export declare function parseEasyComComponents(pluginId: string, inputDir: string, detectBinary?: boolean): string[];
82
82
  export declare function findEncryptUniModules(inputDir: string, cacheDir?: string): Record<string, EncryptPackageJson | undefined>;
83
- export declare function findUploadEncryptUniModulesFiles(uniModules: Record<string, EncryptPackageJson | undefined>, platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string): string[];
83
+ export declare function findUploadEncryptUniModulesFiles(uniModules: Record<string, EncryptPackageJson | undefined>, platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string): Record<string, string[]>;
84
+ export declare function packUploadEncryptUniModules(uniModules: Record<string, EncryptPackageJson | undefined>, platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string, cacheDir: string): {
85
+ zipFile: string;
86
+ modules: string[];
87
+ };
84
88
  interface EncryptPackageJson {
85
89
  id: string;
86
90
  version: string;
@@ -3,11 +3,12 @@ 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.checkEncryptUniModules = exports.resolveEncryptUniModule = exports.initCheckEnv = exports.findUploadEncryptUniModulesFiles = exports.findEncryptUniModules = exports.parseEasyComComponents = exports.parseUniModulesWithComponents = exports.genEncryptEasyComModuleIndex = exports.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.parseInjects = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = exports.getUniExtApiPlugins = exports.getUniExtApiProviders = void 0;
6
+ exports.checkEncryptUniModules = exports.resolveEncryptUniModule = exports.initCheckEnv = exports.packUploadEncryptUniModules = exports.findUploadEncryptUniModulesFiles = exports.findEncryptUniModules = exports.parseEasyComComponents = exports.parseUniModulesWithComponents = exports.genEncryptEasyComModuleIndex = exports.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.parseInjects = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = exports.getUniExtApiPlugins = exports.getUniExtApiProviders = void 0;
7
7
  // 重要:此文件编译后的js,需同步至 vue2 编译器中 uni-cli-shared/lib/uts/uni_modules.js
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
10
10
  const fast_glob_1 = require("fast-glob");
11
+ const utils_1 = require("./utils");
11
12
  const extApiProviders = [];
12
13
  const extApiPlugins = new Set();
13
14
  function getUniExtApiProviders() {
@@ -27,11 +28,7 @@ function getUniExtApiProviderRegisters() {
27
28
  result.push({
28
29
  name: provider.name,
29
30
  service: provider.service,
30
- class: `uts.sdk.modules.${(0, exports.camelize)(provider.plugin)}.${(0, exports.capitalize)((0, exports.camelize)('uni-ext-api-' +
31
- provider.service +
32
- '-' +
33
- provider.name +
34
- '-provider'))}`,
31
+ class: `uts.sdk.modules.${(0, exports.camelize)(provider.plugin)}.${(0, exports.capitalize)((0, exports.camelize)('uni-' + provider.service + '-' + provider.name + '-provider'))}`,
35
32
  });
36
33
  }
37
34
  });
@@ -353,29 +350,40 @@ function findEncryptUniModules(inputDir, cacheDir = '') {
353
350
  }
354
351
  exports.findEncryptUniModules = findEncryptUniModules;
355
352
  function findUploadEncryptUniModulesFiles(uniModules, platform, inputDir) {
356
- const files = [];
353
+ const modules = {};
357
354
  Object.keys(uniModules).forEach((uniModuleId) => {
358
355
  if (!uniModules[uniModuleId]) {
359
- files.push(...findUniModuleFiles(platform, uniModuleId, inputDir));
356
+ modules[uniModuleId] = findUniModuleFiles(platform, uniModuleId, inputDir);
360
357
  }
361
358
  });
362
- return files;
359
+ return modules;
363
360
  }
364
361
  exports.findUploadEncryptUniModulesFiles = findUploadEncryptUniModulesFiles;
365
362
  function packUploadEncryptUniModules(uniModules, platform, inputDir, cacheDir) {
366
- const files = findUploadEncryptUniModulesFiles(uniModules, platform, inputDir);
367
- if (files.length) {
363
+ const modules = findUploadEncryptUniModulesFiles(uniModules, platform, inputDir);
364
+ const uploadModuleIds = Object.keys(modules);
365
+ if (uploadModuleIds.length) {
368
366
  // 延迟 require,避免 vue2 编译器需要安装此依赖,目前该方法仅在 vite 编译器中使用
369
367
  const AdmZip = require('adm-zip');
370
368
  const zip = new AdmZip();
371
- files.forEach((file) => {
372
- zip.addLocalFile(file);
369
+ uploadModuleIds.forEach((moduleId) => {
370
+ modules[moduleId].forEach((file) => {
371
+ zip.addLocalFile(file, path_1.default.dirname(path_1.default.relative(inputDir, file)));
372
+ });
373
373
  });
374
- const zipFile = path_1.default.resolve(cacheDir, 'uni_modules.upload.zip');
374
+ const zipFile = path_1.default.resolve(cacheDir, 'cloud-compile-plugins.zip');
375
375
  zip.writeZip(zipFile);
376
- return zipFile;
376
+ return {
377
+ zipFile,
378
+ modules: uploadModuleIds,
379
+ };
377
380
  }
381
+ return {
382
+ zipFile: '',
383
+ modules: [],
384
+ };
378
385
  }
386
+ exports.packUploadEncryptUniModules = packUploadEncryptUniModules;
379
387
  function isEnvExpired(value, other) {
380
388
  const valueKeys = Object.keys(value);
381
389
  const otherKeys = Object.keys(other);
@@ -396,7 +404,7 @@ function findEncryptUniModuleCache(uniModuleId, cacheDir, options) {
396
404
  const pkg = require(path_1.default.resolve(uniModuleCacheDir, 'package.json'));
397
405
  // 插件版本以及各种环境一致
398
406
  if (pkg.version === options.version &&
399
- !isEnvExpired(pkg.env, options.env)) {
407
+ !isEnvExpired(pkg.uni_modules?.artifacts?.env || {}, options.env)) {
400
408
  return pkg;
401
409
  }
402
410
  // 已过期的插件,删除缓存
@@ -432,6 +440,7 @@ const KNOWN_ASSET_TYPES = [
432
440
  function findUniModuleFiles(platform, id, inputDir) {
433
441
  return (0, fast_glob_1.sync)(`uni_modules/${id}/**/*`, {
434
442
  cwd: inputDir,
443
+ absolute: true,
435
444
  ignore: [
436
445
  '**/*.md',
437
446
  ...(platform !== 'app-android' // 非 android 平台不需要扫描 assets
@@ -463,7 +472,7 @@ function resolveEncryptUniModule(id, platform, isX = true) {
463
472
  const uniModuleId = parts[index + 1];
464
473
  if (uniModuleId in encryptUniModules) {
465
474
  // 原生平台走旧的uts-proxy
466
- return `@/uni_modules/${uniModuleId}?${isX && platform === 'app-android' ? 'uts-proxy' : 'uni_helpers'}`;
475
+ return (0, utils_1.normalizePath)(path_1.default.join(process.env.UNI_INPUT_DIR, `uni_modules/${uniModuleId}?${isX && platform === 'app-android' ? 'uts-proxy' : 'uni_helpers'}`));
467
476
  }
468
477
  }
469
478
  }
@@ -478,15 +487,16 @@ async function checkEncryptUniModules(inputDir, params) {
478
487
  return {};
479
488
  }
480
489
  const cacheDir = process.env.UNI_MODULES_ENCRYPT_CACHE_DIR;
481
- const zipFile = packUploadEncryptUniModules(encryptUniModules, process.env.UNI_UTS_PLATFORM, inputDir, cacheDir);
490
+ const { zipFile, modules } = packUploadEncryptUniModules(encryptUniModules, process.env.UNI_UTS_PLATFORM, inputDir, cacheDir);
482
491
  if (zipFile) {
483
492
  const downloadFile = path_1.default.resolve(cacheDir, 'uni_modules.download.zip');
484
- const { U, D } = require(path_1.default.join(process.env.UNI_HBUILDERX_PLUGINS, 'uni_helpers'));
493
+ const { U, D, R } = require(path_1.default.join(process.env.UNI_HBUILDERX_PLUGINS, 'uni_helpers'));
485
494
  try {
486
- console.log(await U({
487
- ...params,
488
- }));
489
- const downloadUrl = '';
495
+ console.log(`正在云编译插件:${modules.join(',')}...`);
496
+ const downloadUrl = await U({
497
+ params,
498
+ attachment: zipFile,
499
+ });
490
500
  await D(downloadUrl, downloadFile);
491
501
  // unzip
492
502
  const AdmZip = require('adm-zip');
@@ -494,6 +504,11 @@ async function checkEncryptUniModules(inputDir, params) {
494
504
  zip.extractAllTo(cacheDir, true);
495
505
  fs_extra_1.default.unlinkSync(zipFile);
496
506
  fs_extra_1.default.unlinkSync(downloadFile);
507
+ R({
508
+ dir: process.env.UNI_INPUT_DIR,
509
+ cacheDir: process.env.UNI_MODULES_ENCRYPT_CACHE_DIR,
510
+ });
511
+ console.log(`云编译完成,继续本地编译中...`);
497
512
  }
498
513
  catch (e) {
499
514
  fs_extra_1.default.existsSync(zipFile) && fs_extra_1.default.unlinkSync(zipFile);
@@ -502,6 +517,16 @@ async function checkEncryptUniModules(inputDir, params) {
502
517
  process.exit(0);
503
518
  }
504
519
  }
520
+ else {
521
+ // android 平台需要在这里初始化
522
+ if (params.platform === 'app-android') {
523
+ const { R } = require(path_1.default.join(process.env.UNI_HBUILDERX_PLUGINS, 'uni_helpers'));
524
+ R({
525
+ dir: process.env.UNI_INPUT_DIR,
526
+ cacheDir: process.env.UNI_MODULES_ENCRYPT_CACHE_DIR,
527
+ });
528
+ }
529
+ }
505
530
  encryptUniModules = findEncryptUniModules(inputDir, process.env.UNI_MODULES_ENCRYPT_CACHE_DIR);
506
531
  }
507
532
  exports.checkEncryptUniModules = checkEncryptUniModules;
@@ -96,6 +96,9 @@ function uniEncryptUniModulesPlugin() {
96
96
  isPlugin: false,
97
97
  sourceMap: false,
98
98
  uni_modules: [],
99
+ transform: {
100
+ uvueClassNamePrefix: 'Gen',
101
+ },
99
102
  });
100
103
  if (result) {
101
104
  const apis = result.inject_apis;
@@ -3,6 +3,7 @@ import type { EmittedAsset } from 'rollup';
3
3
  import type { ParserOptions } from '@vue/compiler-core';
4
4
  import type { CompilerOptions, SFCStyleCompileOptions, TemplateCompiler } from '@vue/compiler-sfc';
5
5
  import type { UniViteCopyPluginOptions } from './plugins/copy';
6
+ export { getIsStaticFile } from './plugins/vitejs/plugins/static';
6
7
  export declare const cssTarget = "chrome53";
7
8
  export interface CopyOptions {
8
9
  /**
@@ -17,9 +17,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.rewriteExistsSyncHasRootFile = exports.cssTarget = void 0;
20
+ exports.rewriteExistsSyncHasRootFile = exports.cssTarget = exports.getIsStaticFile = void 0;
21
21
  const fs_1 = __importDefault(require("fs"));
22
22
  const path_1 = __importDefault(require("path"));
23
+ var static_1 = require("./plugins/vitejs/plugins/static");
24
+ Object.defineProperty(exports, "getIsStaticFile", { enumerable: true, get: function () { return static_1.getIsStaticFile; } });
23
25
  exports.cssTarget = 'chrome53';
24
26
  __exportStar(require("./utils"), exports);
25
27
  __exportStar(require("./plugins"), exports);
@@ -13,4 +13,5 @@ export declare function resolveExtApiProvider(pkg: Record<string, any>): {
13
13
  service: string;
14
14
  servicePlugin: string;
15
15
  } | undefined;
16
+ export declare function uniDecryptUniModulesPlugin(): Plugin;
16
17
  export {};
@@ -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.resolveExtApiProvider = exports.buildUniExtApis = exports.uniUTSUniModulesPlugin = exports.utsPlugins = void 0;
6
+ exports.uniDecryptUniModulesPlugin = exports.resolveExtApiProvider = exports.buildUniExtApis = exports.uniUTSUniModulesPlugin = exports.utsPlugins = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const uni_shared_1 = require("@dcloudio/uni-shared");
@@ -72,36 +72,14 @@ function uniUTSUniModulesPlugin(options = {}) {
72
72
  }
73
73
  }
74
74
  };
75
- const isX = process.env.UNI_APP_X === 'true';
76
75
  return {
77
76
  name: 'uni:uts-uni_modules',
78
77
  apply: 'build',
79
78
  enforce: 'pre',
80
- async configResolved() {
81
- if (isX) {
82
- const manifest = (0, json_1.parseManifestJsonOnce)(inputDir);
83
- await (0, uni_modules_1.checkEncryptUniModules)(inputDir, {
84
- mode: process.env.NODE_ENV !== 'development'
85
- ? 'production'
86
- : 'development',
87
- compilerVersion: process.env.UNI_COMPILER_VERSION,
88
- appid: manifest.appid,
89
- appname: manifest.name,
90
- platform: process.env.UNI_UTS_PLATFORM,
91
- 'uni-app-x': isX,
92
- });
93
- }
94
- },
95
79
  resolveId(id, importer) {
96
80
  if (isUTSProxy(id) || isUniHelpers(id)) {
97
81
  return id;
98
82
  }
99
- if (isX && process.env.UNI_COMPILE_TARGET !== 'uni_modules') {
100
- const resolvedId = (0, uni_modules_1.resolveEncryptUniModule)(id, process.env.UNI_UTS_PLATFORM, process.env.UNI_APP_X === 'true');
101
- if (resolvedId) {
102
- return resolvedId;
103
- }
104
- }
105
83
  const module = (0, uts_1.resolveUTSAppModule)(id, importer ? path_1.default.dirname(importer) : inputDir, options.x !== true);
106
84
  if (module) {
107
85
  // app-js 会直接返回 index.uts 路径,不需要 uts-proxy
@@ -180,3 +158,38 @@ function resolveExtApiProvider(pkg) {
180
158
  }
181
159
  }
182
160
  exports.resolveExtApiProvider = resolveExtApiProvider;
161
+ function uniDecryptUniModulesPlugin() {
162
+ const inputDir = process.env.UNI_INPUT_DIR;
163
+ const isX = process.env.UNI_APP_X === 'true';
164
+ return {
165
+ name: 'uni:uni_modules-d',
166
+ enforce: 'pre',
167
+ async configResolved() {
168
+ if (isX) {
169
+ const manifest = (0, json_1.parseManifestJsonOnce)(inputDir);
170
+ await (0, uni_modules_1.checkEncryptUniModules)(inputDir, {
171
+ mode: process.env.NODE_ENV !== 'development'
172
+ ? 'production'
173
+ : 'development',
174
+ compilerVersion: process.env.UNI_COMPILER_VERSION,
175
+ appid: manifest.appid,
176
+ appname: manifest.name,
177
+ platform: process.env.UNI_UTS_PLATFORM,
178
+ 'uni-app-x': isX,
179
+ });
180
+ }
181
+ },
182
+ resolveId(id) {
183
+ if (isUTSProxy(id) || isUniHelpers(id)) {
184
+ return id;
185
+ }
186
+ if (isX && process.env.UNI_COMPILE_TARGET !== 'uni_modules') {
187
+ const resolvedId = (0, uni_modules_1.resolveEncryptUniModule)(id, process.env.UNI_UTS_PLATFORM, process.env.UNI_APP_X === 'true');
188
+ if (resolvedId) {
189
+ return resolvedId;
190
+ }
191
+ }
192
+ },
193
+ };
194
+ }
195
+ exports.uniDecryptUniModulesPlugin = uniDecryptUniModulesPlugin;
@@ -8,12 +8,12 @@ export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>
8
8
  * Also supports loading plain strings with import text from './foo.txt?raw'
9
9
  */
10
10
  export declare function assetPlugin(config: ResolvedConfig, options?: {
11
- isAndroidX: boolean;
11
+ isAndroidX?: boolean;
12
12
  }): Plugin;
13
13
  export declare function parseAssets(config: ResolvedConfig, code: string): string;
14
14
  export declare function registerAssetToChunk(chunk: RenderedChunk, file: string): void;
15
15
  export declare function checkPublicFile(url: string, { publicDir }: ResolvedConfig): string | undefined;
16
- export declare function fileToUrl(id: string, config: ResolvedConfig, ctx: PluginContext, canInline?: boolean): string;
16
+ export declare function fileToUrl(id: string, config: ResolvedConfig, ctx: PluginContext, canInline: boolean | undefined, isStaticFile: (file: string) => boolean): string;
17
17
  export declare function getAssetFilename(hash: string, config: ResolvedConfig): string | undefined;
18
18
  /**
19
19
  * converts the source filepath of the asset to the output filename based on the assetFileNames option. \
@@ -40,4 +40,4 @@ export declare function getAssetFilename(hash: string, config: ResolvedConfig):
40
40
  */
41
41
  export declare function assetFileNamesToFileName(assetFileNames: Exclude<OutputOptions['assetFileNames'], undefined>, file: string, contentHash: string, content: string | Buffer): string;
42
42
  export declare function getAssetHash(content: Buffer | string): string;
43
- export declare function urlToBuiltUrl(url: string, importer: string, config: ResolvedConfig, pluginContext: PluginContext): string;
43
+ export declare function urlToBuiltUrl(url: string, importer: string, config: ResolvedConfig, pluginContext: PluginContext, isStaticFile: (file: string) => boolean): string;
@@ -37,6 +37,7 @@ const shared_1 = require("@vue/shared");
37
37
  const utils_1 = require("../utils");
38
38
  const utils_2 = require("../../../../vite/utils/utils");
39
39
  const utils_3 = require("../../../../utils");
40
+ const static_1 = require("./static");
40
41
  exports.assetUrlRE = /__VITE_ASSET__([a-z\d]{8})__(?:\$_(.*?)__)?/g;
41
42
  const rawRE = /(\?|&)raw(?:&|$)/;
42
43
  const urlRE = /(\?|&)url(?:&|$)/;
@@ -91,7 +92,7 @@ function assetPlugin(config, options) {
91
92
  fs_extra_1.default.outputFileSync(path_1.default.resolve(process.env.UNI_OUTPUT_DIR, emittedFile.fileName), emittedFile.source);
92
93
  },
93
94
  }
94
- : this);
95
+ : this, false, (0, static_1.getIsStaticFile)());
95
96
  if (options?.isAndroidX) {
96
97
  this.emitFile({
97
98
  type: 'asset',
@@ -176,8 +177,8 @@ function checkPublicFile(url, { publicDir }) {
176
177
  }
177
178
  }
178
179
  exports.checkPublicFile = checkPublicFile;
179
- function fileToUrl(id, config, ctx, canInline = false) {
180
- return fileToBuiltUrl(id, config, ctx, false, canInline);
180
+ function fileToUrl(id, config, ctx, canInline = false, isStaticFile) {
181
+ return fileToBuiltUrl(id, config, ctx, false, canInline, isStaticFile);
181
182
  }
182
183
  exports.fileToUrl = fileToUrl;
183
184
  function getAssetFilename(hash, config) {
@@ -261,7 +262,7 @@ function sanitizeFileName(name) {
261
262
  * Register an asset to be emitted as part of the bundle (if necessary)
262
263
  * and returns the resolved public URL
263
264
  */
264
- function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, canInline = false) {
265
+ function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, canInline = false, isStaticFile) {
265
266
  if (!skipPublicCheck && checkPublicFile(id, config)) {
266
267
  return config.base + id.slice(1);
267
268
  }
@@ -294,14 +295,15 @@ function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, canI
294
295
  assetFileNames = output[0].assetFileNames ?? assetFileNames;
295
296
  }
296
297
  const inputDir = (0, utils_1.normalizePath)(process.env.UNI_INPUT_DIR);
297
- let fileName = file.startsWith(inputDir) && file.includes('/static/')
298
+ const isStatic = isStaticFile(file);
299
+ let fileName = file.startsWith(inputDir) && isStatic
298
300
  ? // 需要处理 HBuilderX 项目中的 node_modules 目录
299
301
  (0, utils_3.normalizeNodeModules)(path_1.default.posix.relative(inputDir, file))
300
302
  : assetFileNamesToFileName(assetFileNames, file, contentHash, content);
301
303
  if (!map.has(contentHash)) {
302
304
  map.set(contentHash, fileName);
303
305
  }
304
- if (!fileName.includes('/static/')) {
306
+ if (!isStatic) {
305
307
  const emittedSet = emittedHashMap.get(config);
306
308
  if (!emittedSet.has(contentHash)) {
307
309
  pluginContext.emitFile({
@@ -322,7 +324,7 @@ function getAssetHash(content) {
322
324
  return (0, crypto_1.createHash)('sha256').update(content).digest('hex').slice(0, 8);
323
325
  }
324
326
  exports.getAssetHash = getAssetHash;
325
- function urlToBuiltUrl(url, importer, config, pluginContext) {
327
+ function urlToBuiltUrl(url, importer, config, pluginContext, isStaticFile) {
326
328
  if (checkPublicFile(url, config)) {
327
329
  return config.base + url.slice(1);
328
330
  }
@@ -331,6 +333,6 @@ function urlToBuiltUrl(url, importer, config, pluginContext) {
331
333
  : path_1.default.join(path_1.default.dirname(importer), url);
332
334
  return fileToBuiltUrl(file, config, pluginContext,
333
335
  // skip public check since we just did it above
334
- true);
336
+ true, false, isStaticFile);
335
337
  }
336
338
  exports.urlToBuiltUrl = urlToBuiltUrl;
@@ -47,6 +47,7 @@ const utils_2 = require("../../../utils/utils");
47
47
  const compiler_core_1 = require("@vue/compiler-core");
48
48
  const utils_3 = require("../../../../utils");
49
49
  const utils_4 = require("../../../utils");
50
+ const static_1 = require("./static");
50
51
  const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
51
52
  exports.cssLangRE = new RegExp(cssLangs);
52
53
  const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
@@ -134,14 +135,14 @@ function cssPlugin(config, options = { isAndroidX: false }) {
134
135
  emitFile(emittedFile) {
135
136
  const fileName = path_1.default.resolve(process.env.UNI_OUTPUT_DIR, emittedFile.fileName);
136
137
  // 忽略static(可能有只读文件,写入覆盖只读会报错权限)
137
- if ((0, utils_1.normalizePath)(fileName).includes('/static/')) {
138
+ if ((0, static_1.getIsStaticFile)()((0, utils_1.normalizePath)(emittedFile.fileName))) {
138
139
  return;
139
140
  }
140
141
  // 直接写入目标目录
141
142
  fs_extra_1.default.outputFileSync(fileName, emittedFile.source);
142
143
  },
143
144
  }
144
- : this, true);
145
+ : this, true, (0, static_1.getIsStaticFile)());
145
146
  }
146
147
  return url;
147
148
  });
@@ -0,0 +1,2 @@
1
+ export declare function createIsStaticFile(): (relativeFile: string) => boolean;
2
+ export declare function getIsStaticFile(): (file: string) => boolean;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getIsStaticFile = exports.createIsStaticFile = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const utils_1 = require("../utils");
10
+ const json_1 = require("../../../../json/json");
11
+ const uniModulesStaticRe = /^uni_modules\/[^/]+\/static\//;
12
+ function createIsStaticFile() {
13
+ let subPackageStatics = [];
14
+ const pagesFilename = path_1.default.join(process.env.UNI_INPUT_DIR, 'pages.json');
15
+ if (fs_1.default.existsSync(pagesFilename)) {
16
+ const pagesJson = (0, json_1.parseJson)(fs_1.default.readFileSync(pagesFilename, 'utf8'), true);
17
+ subPackageStatics = (pagesJson.subPackages || pagesJson.subpackages || [])
18
+ .filter((subPackage) => subPackage.root)
19
+ .map((subPackage) => {
20
+ return (0, utils_1.normalizePath)(path_1.default.join(subPackage.root, 'static')) + '/';
21
+ });
22
+ }
23
+ return function isStaticFile(relativeFile) {
24
+ if (path_1.default.isAbsolute(relativeFile)) {
25
+ relativeFile = (0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, relativeFile));
26
+ }
27
+ return (relativeFile.startsWith('static/') ||
28
+ uniModulesStaticRe.test(relativeFile) ||
29
+ subPackageStatics.some((s) => relativeFile.startsWith(s)));
30
+ };
31
+ }
32
+ exports.createIsStaticFile = createIsStaticFile;
33
+ let isStaticFile;
34
+ function getIsStaticFile() {
35
+ if (!isStaticFile) {
36
+ isStaticFile = createIsStaticFile();
37
+ }
38
+ return isStaticFile;
39
+ }
40
+ exports.getIsStaticFile = getIsStaticFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-4010720240511002",
3
+ "version": "3.0.0-alpha-4010820240516001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,8 +26,8 @@
26
26
  "@babel/core": "^7.23.3",
27
27
  "@babel/parser": "^7.23.9",
28
28
  "@babel/types": "^7.20.7",
29
- "@dcloudio/uni-i18n": "3.0.0-alpha-4010720240511002",
30
- "@dcloudio/uni-shared": "3.0.0-alpha-4010720240511002",
29
+ "@dcloudio/uni-i18n": "3.0.0-alpha-4010820240516001",
30
+ "@dcloudio/uni-shared": "3.0.0-alpha-4010820240516001",
31
31
  "@intlify/core-base": "9.1.9",
32
32
  "@intlify/shared": "9.1.9",
33
33
  "@intlify/vue-devtools": "9.1.9",
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
73
73
  "devDependencies": {
74
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-4010720240511002",
74
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-4010820240516001",
75
75
  "@types/adm-zip": "^0.5.5",
76
76
  "@types/babel__code-frame": "^7.0.6",
77
77
  "@types/babel__core": "^7.1.19",