@dcloudio/uni-cli-shared 3.0.0-alpha-4000020240126001 → 3.0.0-alpha-4000120240201001

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/constants.js CHANGED
@@ -9,7 +9,7 @@ exports.EXTNAME_VUE = ['.vue', '.nvue', '.uvue'];
9
9
  exports.X_EXTNAME_VUE = ['.uvue', '.vue'];
10
10
  exports.EXTNAME_VUE_TEMPLATE = ['.vue', '.nvue', '.uvue', '.jsx', '.tsx'];
11
11
  exports.EXTNAME_VUE_RE = /\.(vue|nvue|uvue)$/;
12
- exports.EXTNAME_JS_RE = /\.(js|jsx|ts|tsx|mjs)$/;
12
+ exports.EXTNAME_JS_RE = /\.(js|jsx|ts|uts|tsx|mjs)$/;
13
13
  exports.EXTNAME_TS_RE = /\.tsx?$/;
14
14
  const COMMON_EXTENSIONS = [
15
15
  '.uts',
package/dist/easycom.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  interface EasycomOption {
2
+ isX?: boolean;
2
3
  dirs?: string[];
3
4
  rootDir: string;
4
5
  extensions: string[];
@@ -28,4 +29,8 @@ export declare function matchEasycom(tag: string): string | false | undefined;
28
29
  export declare function addImportDeclaration(importDeclarations: string[], local: string, source: string, imported?: string): string;
29
30
  export declare function genResolveEasycomCode(importDeclarations: string[], code: string, name: string): string;
30
31
  export declare const UNI_EASYCOM_EXCLUDE: RegExp[];
32
+ export declare function getUTSEasyComAutoImports(): Record<string, [[string, string]]>;
33
+ export declare function addUTSEasyComAutoImports(source: string, imports: [string, string]): void;
34
+ export declare function genUTSComponentPublicInstanceIdent(tagName: string): string;
35
+ export declare function genUTSComponentPublicInstanceImported(root: string, fileName: string): string;
31
36
  export {};
package/dist/easycom.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.UNI_EASYCOM_EXCLUDE = exports.genResolveEasycomCode = exports.addImportDeclaration = exports.matchEasycom = exports.initEasycomsOnce = exports.initEasycoms = void 0;
6
+ exports.genUTSComponentPublicInstanceImported = exports.genUTSComponentPublicInstanceIdent = exports.addUTSEasyComAutoImports = exports.getUTSEasyComAutoImports = exports.UNI_EASYCOM_EXCLUDE = exports.genResolveEasycomCode = exports.addImportDeclaration = exports.matchEasycom = exports.initEasycomsOnce = exports.initEasycoms = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const debug_1 = __importDefault(require("debug"));
@@ -31,6 +31,7 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
31
31
  // 初始化时,从once中读取缓存,refresh时,实时读取
32
32
  const { easycom } = pagesJson || (0, pages_1.parsePagesJson)(inputDir, platform, false);
33
33
  const easycomOptions = {
34
+ isX,
34
35
  dirs: easycom && easycom.autoscan === false
35
36
  ? [...dirs] // 禁止自动扫描
36
37
  : [
@@ -100,11 +101,25 @@ function initUniModulesEasycomDirs(uniModulesDir) {
100
101
  })
101
102
  .filter(Boolean);
102
103
  }
103
- function initEasycom({ dirs, rootDir, custom, extensions }) {
104
+ function initEasycom({ isX, dirs, rootDir, custom, extensions, }) {
104
105
  clearEasycom();
105
106
  const easycomsObj = Object.create(null);
106
107
  if (dirs && dirs.length && rootDir) {
107
- (0, shared_1.extend)(easycomsObj, initAutoScanEasycoms(dirs, rootDir, extensions));
108
+ const autoEasyComObj = initAutoScanEasycoms(dirs, rootDir, extensions);
109
+ if (isX) {
110
+ Object.keys(autoEasyComObj).forEach((tagName) => {
111
+ let source = autoEasyComObj[tagName];
112
+ tagName = tagName.slice(1, -1);
113
+ if (path_1.default.isAbsolute(source) && source.startsWith(rootDir)) {
114
+ source = '@/' + (0, utils_1.normalizePath)(path_1.default.relative(rootDir, source));
115
+ }
116
+ addUTSEasyComAutoImports(source, [
117
+ genUTSComponentPublicInstanceImported(rootDir, source),
118
+ genUTSComponentPublicInstanceIdent(tagName),
119
+ ]);
120
+ });
121
+ }
122
+ (0, shared_1.extend)(easycomsObj, autoEasyComObj);
108
123
  }
109
124
  if (custom) {
110
125
  Object.keys(custom).forEach((name) => {
@@ -223,3 +238,33 @@ function genResolveEasycomCode(importDeclarations, code, name) {
223
238
  }
224
239
  exports.genResolveEasycomCode = genResolveEasycomCode;
225
240
  exports.UNI_EASYCOM_EXCLUDE = [/App.vue$/, /@dcloudio\/uni-h5/];
241
+ const utsEasyComAutoImports = {};
242
+ function getUTSEasyComAutoImports() {
243
+ return utsEasyComAutoImports;
244
+ }
245
+ exports.getUTSEasyComAutoImports = getUTSEasyComAutoImports;
246
+ function addUTSEasyComAutoImports(source, imports) {
247
+ if (!utsEasyComAutoImports[source]) {
248
+ utsEasyComAutoImports[source] = [imports];
249
+ }
250
+ else {
251
+ if (!utsEasyComAutoImports[source].find((item) => item[0] === imports[0])) {
252
+ utsEasyComAutoImports[source].push(imports);
253
+ }
254
+ }
255
+ }
256
+ exports.addUTSEasyComAutoImports = addUTSEasyComAutoImports;
257
+ function genUTSComponentPublicInstanceIdent(tagName) {
258
+ return (0, shared_1.capitalize)((0, shared_1.camelize)(tagName)) + 'ComponentPublicInstance';
259
+ }
260
+ exports.genUTSComponentPublicInstanceIdent = genUTSComponentPublicInstanceIdent;
261
+ function genUTSComponentPublicInstanceImported(root, fileName) {
262
+ if (path_1.default.isAbsolute(fileName) && fileName.startsWith(root)) {
263
+ fileName = (0, utils_1.normalizePath)(path_1.default.relative(root, fileName));
264
+ }
265
+ if (fileName.startsWith('@/')) {
266
+ return ((0, uts_1.genUTSClassName)(fileName.replace('@/', '')) + 'ComponentPublicInstance');
267
+ }
268
+ return (0, uts_1.genUTSClassName)(fileName) + 'ComponentPublicInstance';
269
+ }
270
+ exports.genUTSComponentPublicInstanceImported = genUTSComponentPublicInstanceImported;
@@ -124,16 +124,19 @@ exports.normalizePagesJson = normalizePagesJson;
124
124
  function validatePages(pagesJson, jsonStr) {
125
125
  if (!(0, shared_1.isArray)(pagesJson.pages)) {
126
126
  pagesJson.pages = [];
127
- throw new Error(`[uni-app] Error: pages.json->pages parse failed.`);
127
+ console.error(`[uni-app] Error: pages.json->pages parse failed.`);
128
+ process.exit(0);
128
129
  }
129
130
  else if (!pagesJson.pages.length) {
130
- throw new Error(`[uni-app] Error: pages.json->pages must contain at least 1 page.`);
131
+ console.error(`[uni-app] Error: pages.json->pages must contain at least 1 page.`);
132
+ process.exit(0);
131
133
  }
132
134
  else {
133
135
  const pages = [];
134
136
  pagesJson.pages.forEach((page) => {
135
137
  if (pages.indexOf(page.path) !== -1) {
136
- throw new Error(`[uni-app] Error: pages.json->${page.path} duplication.`);
138
+ console.error(`[uni-app] Error: pages.json->${page.path} duplication.`);
139
+ process.exit(0);
137
140
  }
138
141
  pages.push(page.path);
139
142
  });
@@ -16,7 +16,7 @@ export interface Exports {
16
16
  [name: string]: Define | Defines | false;
17
17
  }
18
18
  export declare function parseUniExtApis(vite: boolean | undefined, platform: typeof process.env.UNI_UTS_PLATFORM, language?: UTSTargetLanguage): Injects;
19
- type Injects = {
19
+ export type Injects = {
20
20
  [name: string]: string | [string, string] | [string, string, DefineOptions['app']] | false;
21
21
  };
22
22
  /**
@@ -41,4 +41,3 @@ type Injects = {
41
41
  * @returns
42
42
  */
43
43
  export declare function parseInjects(vite: boolean | undefined, platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage, source: string, uniModuleRootDir: string, exports?: Exports): Injects;
44
- export {};
package/dist/uts.d.ts CHANGED
@@ -24,3 +24,4 @@ export type UTSTargetLanguage = typeof process.env.UNI_UTS_TARGET_LANGUAGE;
24
24
  export declare const parseUniExtApiNamespacesOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
25
25
  export declare const parseUniExtApiNamespacesJsOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
26
26
  export declare function matchUTSComponent(tag: string): boolean;
27
+ export declare function genUTSClassName(fileName: string, prefix?: string): string;
package/dist/uts.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.matchUTSComponent = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.isUTSComponent = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
6
+ exports.genUTSClassName = exports.matchUTSComponent = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.isUTSComponent = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fast_glob_1 = __importDefault(require("fast-glob"));
@@ -259,3 +259,37 @@ function matchUTSComponent(tag) {
259
259
  return !!(source && source.includes('uts-proxy'));
260
260
  }
261
261
  exports.matchUTSComponent = matchUTSComponent;
262
+ function genUTSClassName(fileName, prefix = 'Gen') {
263
+ return (prefix +
264
+ (0, utils_1.capitalize)((0, utils_1.camelize)(verifySymbol((0, utils_1.removeExt)((0, utils_1.normalizeNodeModules)(fileName)
265
+ .replace(/[\/|_]/g, '-')
266
+ .replace(/-+/g, '-'))))));
267
+ }
268
+ exports.genUTSClassName = genUTSClassName;
269
+ function isValidStart(c) {
270
+ return !!c.match(/^[A-Za-z_-]$/);
271
+ }
272
+ function isValidContinue(c) {
273
+ return !!c.match(/^[A-Za-z0-9_-]$/);
274
+ }
275
+ function verifySymbol(s) {
276
+ const chars = Array.from(s);
277
+ if (isValidStart(chars[0]) && chars.slice(1).every(isValidContinue)) {
278
+ return s;
279
+ }
280
+ const buf = [];
281
+ let hasStart = false;
282
+ for (const c of chars) {
283
+ if (!hasStart && isValidStart(c)) {
284
+ hasStart = true;
285
+ buf.push(c);
286
+ }
287
+ else if (isValidContinue(c)) {
288
+ buf.push(c);
289
+ }
290
+ }
291
+ if (buf.length === 0) {
292
+ buf.push('_');
293
+ }
294
+ return buf.join('');
295
+ }
@@ -19,6 +19,8 @@ const uniPreset = {
19
19
  'onLastPageBackPress',
20
20
  'onExit',
21
21
  // Page
22
+ 'onPageShow',
23
+ 'onPageHide',
22
24
  'onLoad',
23
25
  'onReady',
24
26
  'onUnload',
@@ -28,11 +30,10 @@ const uniPreset = {
28
30
  'onTabItemTap',
29
31
  'onReachBottom',
30
32
  'onPullDownRefresh',
33
+ // 辅助
34
+ 'renderComponentSlot',
31
35
  ],
32
36
  };
33
- if (process.env.UNI_UTS_PLATFORM === 'web') {
34
- uniPreset.imports.push('onPageShow', 'onPageHide');
35
- }
36
37
  const uniH5Preset = {
37
38
  from: '@dcloudio/uni-h5',
38
39
  imports: ['UniElement', 'UniElementImpl'],
@@ -106,7 +107,7 @@ function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
106
107
  }
107
108
  return {
108
109
  ...userOptions,
109
- include: [/\.[u]?ts$/, /\.[u]?vue$/, /\.[u]?vue\?vue/],
110
+ include: [/\.[u]?ts$/, /\.[u]?vue/],
110
111
  exclude: [/[\\/]\.git[\\/]/],
111
112
  imports: imports.concat(
112
113
  // app-android 平台暂不注入其他
@@ -10,5 +10,5 @@ export * from './uts/uvue';
10
10
  export * from './uts/ext-api';
11
11
  export * from './easycom';
12
12
  export { assetPlugin, parseAssets, getAssetHash } from './vitejs/plugins/asset';
13
- export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, } from './vitejs/plugins/css';
13
+ export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, rewriteScssReadFileSync, } from './vitejs/plugins/css';
14
14
  export { generateCodeFrame, locToStartAndEnd, offsetToStartAndEnd, } from './vitejs/utils';
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.offsetToStartAndEnd = exports.locToStartAndEnd = exports.generateCodeFrame = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.parseAssets = exports.assetPlugin = void 0;
17
+ exports.offsetToStartAndEnd = exports.locToStartAndEnd = exports.generateCodeFrame = exports.rewriteScssReadFileSync = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.parseAssets = exports.assetPlugin = void 0;
18
18
  __exportStar(require("./cssScoped"), exports);
19
19
  __exportStar(require("./copy"), exports);
20
20
  __exportStar(require("./inject"), exports);
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "cssPostPlugin", { enumerable: true, get: functio
37
37
  Object.defineProperty(exports, "minifyCSS", { enumerable: true, get: function () { return css_1.minifyCSS; } });
38
38
  Object.defineProperty(exports, "cssLangRE", { enumerable: true, get: function () { return css_1.cssLangRE; } });
39
39
  Object.defineProperty(exports, "commonjsProxyRE", { enumerable: true, get: function () { return css_1.commonjsProxyRE; } });
40
+ Object.defineProperty(exports, "rewriteScssReadFileSync", { enumerable: true, get: function () { return css_1.rewriteScssReadFileSync; } });
40
41
  var utils_1 = require("./vitejs/utils");
41
42
  Object.defineProperty(exports, "generateCodeFrame", { enumerable: true, get: function () { return utils_1.generateCodeFrame; } });
42
43
  Object.defineProperty(exports, "locToStartAndEnd", { enumerable: true, get: function () { return utils_1.locToStartAndEnd; } });
@@ -1,2 +1,12 @@
1
1
  import type { Plugin } from 'vite';
2
- export declare function uniUTSExtApi(): Plugin;
2
+ import { Injects } from '../../../uni_modules';
3
+ export declare function uniUTSExtApiReplace(): Plugin;
4
+ /**
5
+ * { 'uni.getBatteryInfo': ['@/uni_modules/uni-getbatteryinfo/utssdk/web/index.uts','getBatteryInfo'] }
6
+ * { '@/uni_modules/uni-getbatteryinfo/utssdk/web/index.ts': [['getBatteryInfo', 'uni_getBatteryInfo']] }
7
+ * @param injects
8
+ */
9
+ export declare function injectsToAutoImports(injects: Injects): {
10
+ from: string;
11
+ imports: [string, string][];
12
+ }[];
@@ -1,22 +1,81 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uniUTSExtApi = void 0;
6
+ exports.injectsToAutoImports = exports.uniUTSExtApiReplace = void 0;
7
+ const shared_1 = require("@vue/shared");
8
+ const uni_shared_1 = require("@dcloudio/uni-shared");
9
+ const vite_1 = __importDefault(require("unplugin-auto-import/vite"));
4
10
  const uni_modules_1 = require("../../../uni_modules");
5
- const inject_1 = require("../inject");
6
- function uniUTSExtApi() {
11
+ const url_1 = require("../../utils/url");
12
+ const escape = (str) => str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
13
+ const parseUniExtApisOnce = (0, uni_shared_1.once)(uni_modules_1.parseUniExtApis);
14
+ function uniUTSExtApiReplace() {
15
+ const injects = parseUniExtApisOnce(true, process.env.UNI_UTS_PLATFORM, 'javascript');
16
+ const injectApis = Object.keys(injects);
17
+ const firstPass = new RegExp(`(?:${injectApis.map(escape).join('|')})`, 'g');
7
18
  return {
8
- name: 'uni:uts-ext-api',
19
+ name: 'uni:uts-ext-api-replace',
9
20
  configResolved(config) {
10
- // 在 uts 之前插入 ext-api-inject
11
21
  const index = config.plugins.findIndex((p) => p.name === 'uts');
12
22
  if (index > -1) {
13
- const injects = (0, uni_modules_1.parseUniExtApis)(true, process.env.UNI_UTS_PLATFORM, 'javascript');
23
+ const injects = parseUniExtApisOnce(true, process.env.UNI_UTS_PLATFORM, 'javascript');
14
24
  if (Object.keys(injects).length) {
15
25
  // @ts-expect-error
16
- config.plugins.splice(index, 0, (0, inject_1.uniViteInjectPlugin)('uni:ext-api-inject', injects));
26
+ config.plugins.splice(index, 0, (0, vite_1.default)({
27
+ include: [/\.[u]?ts$/, /\.[u]?vue/],
28
+ exclude: [/[\\/]\.git[\\/]/],
29
+ imports: injectsToAutoImports(parseUniExtApisOnce(true, process.env.UNI_UTS_PLATFORM, 'javascript')),
30
+ dts: false,
31
+ }));
17
32
  }
18
33
  }
19
34
  },
35
+ transform(code, id) {
36
+ if (!injectApis.length) {
37
+ return;
38
+ }
39
+ if (!(0, url_1.isJsFile)(id)) {
40
+ return;
41
+ }
42
+ if (code.search(firstPass) === -1) {
43
+ return;
44
+ }
45
+ injectApis.forEach((api) => {
46
+ code = code.replaceAll(api, api.replace('.', '_'));
47
+ });
48
+ return {
49
+ code,
50
+ map: { mappings: '' },
51
+ };
52
+ },
20
53
  };
21
54
  }
22
- exports.uniUTSExtApi = uniUTSExtApi;
55
+ exports.uniUTSExtApiReplace = uniUTSExtApiReplace;
56
+ /**
57
+ * { 'uni.getBatteryInfo': ['@/uni_modules/uni-getbatteryinfo/utssdk/web/index.uts','getBatteryInfo'] }
58
+ * { '@/uni_modules/uni-getbatteryinfo/utssdk/web/index.ts': [['getBatteryInfo', 'uni_getBatteryInfo']] }
59
+ * @param injects
60
+ */
61
+ function injectsToAutoImports(injects) {
62
+ const autoImports = {};
63
+ Object.keys(injects).forEach((api) => {
64
+ const options = injects[api];
65
+ if ((0, shared_1.isArray)(options) && options.length >= 2) {
66
+ const source = options[0];
67
+ const name = options[1];
68
+ if (!autoImports[source]) {
69
+ autoImports[source] = [];
70
+ }
71
+ autoImports[source].push([name, api.replace('.', '_')]);
72
+ }
73
+ });
74
+ return Object.keys(autoImports).map((source) => {
75
+ return {
76
+ from: source,
77
+ imports: autoImports[source],
78
+ };
79
+ });
80
+ }
81
+ exports.injectsToAutoImports = injectsToAutoImports;
@@ -58,3 +58,8 @@ export interface StylePreprocessorResults {
58
58
  errors: RollupError[];
59
59
  deps: string[];
60
60
  }
61
+ /**
62
+ * 重写 readFileSync
63
+ * 目前主要解决 scss 文件被 @import 的条件编译
64
+ */
65
+ export declare function rewriteScssReadFileSync(): void;
@@ -26,7 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.hoistAtRules = exports.minifyCSS = exports.importCssRE = exports.cssDataUriRE = exports.cssUrlRE = exports.formatPostcssSourceMap = exports.cssPostPlugin = exports.cssPlugin = exports.isDirectCSSRequest = exports.isCSSRequest = exports.commonjsProxyRE = exports.cssLangRE = void 0;
29
+ exports.rewriteScssReadFileSync = exports.hoistAtRules = exports.minifyCSS = exports.importCssRE = exports.cssDataUriRE = exports.cssUrlRE = exports.formatPostcssSourceMap = exports.cssPostPlugin = exports.cssPlugin = exports.isDirectCSSRequest = exports.isCSSRequest = exports.commonjsProxyRE = exports.cssLangRE = void 0;
30
+ const fs_1 = __importDefault(require("fs"));
30
31
  const fs_extra_1 = __importDefault(require("fs-extra"));
31
32
  const path_1 = __importDefault(require("path"));
32
33
  const fast_glob_1 = __importDefault(require("fast-glob"));
@@ -810,6 +811,8 @@ function loadPreprocessor(lang, root) {
810
811
  // .scss/.sass processor
811
812
  const scss = async (source, root, options, resolvers, isNVue) => {
812
813
  const render = loadPreprocessor("sass" /* PreprocessLang.sass */, root).render;
814
+ // NOTE: `sass` always runs it's own importer first, and only falls back to
815
+ // the `importer` option when it can't resolve a path
813
816
  const internalImporter = (url, importer, done) => {
814
817
  resolvers.sass(url, importer).then((resolved) => {
815
818
  if (resolved) {
@@ -1107,3 +1110,21 @@ const preProcessors = Object.freeze({
1107
1110
  function isPreProcessor(lang) {
1108
1111
  return lang && lang in preProcessors;
1109
1112
  }
1113
+ /**
1114
+ * 重写 readFileSync
1115
+ * 目前主要解决 scss 文件被 @import 的条件编译
1116
+ */
1117
+ function rewriteScssReadFileSync() {
1118
+ const { readFileSync } = fs_1.default;
1119
+ fs_1.default.readFileSync = ((filepath, options) => {
1120
+ const content = readFileSync(filepath, options);
1121
+ if ((0, shared_1.isString)(filepath) &&
1122
+ path_1.default.extname(filepath) === '.scss' &&
1123
+ (0, shared_1.isString)(content) &&
1124
+ content.includes('#endif')) {
1125
+ return (0, preprocess_1.preCss)(content);
1126
+ }
1127
+ return content;
1128
+ });
1129
+ }
1130
+ exports.rewriteScssReadFileSync = rewriteScssReadFileSync;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-4000020240126001",
3
+ "version": "3.0.0-alpha-4000120240201001",
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.21.3",
27
27
  "@babel/parser": "^7.23.5",
28
28
  "@babel/types": "^7.20.7",
29
- "@dcloudio/uni-i18n": "3.0.0-alpha-4000020240126001",
30
- "@dcloudio/uni-shared": "3.0.0-alpha-4000020240126001",
29
+ "@dcloudio/uni-i18n": "3.0.0-alpha-4000120240201001",
30
+ "@dcloudio/uni-shared": "3.0.0-alpha-4000120240201001",
31
31
  "@intlify/core-base": "9.1.9",
32
32
  "@intlify/shared": "9.1.9",
33
33
  "@intlify/vue-devtools": "9.1.9",
@@ -62,11 +62,12 @@
62
62
  "postcss-selector-parser": "^6.0.6",
63
63
  "resolve": "^1.22.1",
64
64
  "tapable": "^2.2.0",
65
+ "unplugin-auto-import": "^0.16.7",
65
66
  "xregexp": "3.1.0"
66
67
  },
67
68
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
68
69
  "devDependencies": {
69
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-4000020240126001",
70
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-4000120240201001",
70
71
  "@types/babel__code-frame": "^7.0.6",
71
72
  "@types/babel__core": "^7.1.19",
72
73
  "@types/debug": "^4.1.7",