@dcloudio/uni-cli-shared 3.0.0-alpha-3061520221220001 → 3.0.0-alpha-3061620221230002

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/hbx/log.js CHANGED
@@ -107,7 +107,6 @@ exports.errorFormatter = {
107
107
  },
108
108
  };
109
109
  function buildErrorMessage(err, args = [], includeStack = true) {
110
- var _a, _b;
111
110
  if (err.plugin) {
112
111
  args.push(`${picocolors_1.default.magenta('[plugin:' + err.plugin + ']')} ${picocolors_1.default.red(err.message)}`);
113
112
  if (err.loc &&
@@ -132,7 +131,7 @@ function buildErrorMessage(err, args = [], includeStack = true) {
132
131
  args.push(picocolors_1.default.red(err.message));
133
132
  }
134
133
  if (err.id) {
135
- args.push(formatAtFilename(err.id, (_a = err.loc) === null || _a === void 0 ? void 0 : _a.line, (_b = err.loc) === null || _b === void 0 ? void 0 : _b.column));
134
+ args.push(formatAtFilename(err.id, err.loc?.line, err.loc?.column));
136
135
  }
137
136
  if (err.frame) {
138
137
  args.push(picocolors_1.default.yellow(pad(err.frame)));
@@ -9,7 +9,6 @@ function initArguments(manifestJson, pagesJson) {
9
9
  }
10
10
  exports.initArguments = initArguments;
11
11
  function parseArguments(pagesJson) {
12
- var _a;
13
12
  if (process.env.NODE_ENV !== 'development') {
14
13
  return;
15
14
  }
@@ -21,7 +20,7 @@ function parseArguments(pagesJson) {
21
20
  });
22
21
  }
23
22
  const condition = pagesJson.condition;
24
- if (condition && ((_a = condition.list) === null || _a === void 0 ? void 0 : _a.length)) {
23
+ if (condition && condition.list?.length) {
25
24
  const list = condition.list;
26
25
  let current = condition.current || 0;
27
26
  if (current < 0) {
@@ -23,10 +23,9 @@ function isConfusionFile(filename) {
23
23
  }
24
24
  exports.isConfusionFile = isConfusionFile;
25
25
  function hasConfusionFile(inputDir) {
26
- var _a, _b;
27
26
  if (inputDir) {
28
27
  const manifestJson = (0, manifest_1.parseManifestJsonOnce)(inputDir);
29
- const resources = (_b = (_a = manifestJson['app-plus']) === null || _a === void 0 ? void 0 : _a.confusion) === null || _b === void 0 ? void 0 : _b.resources;
28
+ const resources = manifestJson['app-plus']?.confusion?.resources;
30
29
  if (resources && parseConfusion(resources)[1].length) {
31
30
  return true;
32
31
  }
@@ -64,9 +63,8 @@ function parseConfusion(resources) {
64
63
  return [res, dynamicJsFiles];
65
64
  }
66
65
  function initConfusion(manifestJson) {
67
- var _a;
68
66
  dynamicConfusionJsFiles.length = 0;
69
- if (!((_a = manifestJson.plus.confusion) === null || _a === void 0 ? void 0 : _a.resources)) {
67
+ if (!manifestJson.plus.confusion?.resources) {
70
68
  return;
71
69
  }
72
70
  const resources = manifestJson.plus.confusion.resources;
@@ -10,15 +10,13 @@ function getAppRenderer(manifestJson) {
10
10
  }
11
11
  exports.getAppRenderer = getAppRenderer;
12
12
  function getAppCodeSpliting(manifestJson) {
13
- var _a, _b;
14
- if (((_b = (_a = manifestJson['app-plus']) === null || _a === void 0 ? void 0 : _a.optimization) === null || _b === void 0 ? void 0 : _b.codeSpliting) === true) {
13
+ if (manifestJson['app-plus']?.optimization?.codeSpliting === true) {
15
14
  return true;
16
15
  }
17
16
  return false;
18
17
  }
19
18
  exports.getAppCodeSpliting = getAppCodeSpliting;
20
19
  function getAppStyleIsolation(manifestJson) {
21
- var _a, _b, _c;
22
- return ((_c = (_b = (_a = manifestJson['app-plus']) === null || _a === void 0 ? void 0 : _a.optimization) === null || _b === void 0 ? void 0 : _b.styleIsolation) !== null && _c !== void 0 ? _c : 'apply-shared');
20
+ return (manifestJson['app-plus']?.optimization?.styleIsolation ?? 'apply-shared');
23
21
  }
24
22
  exports.getAppStyleIsolation = getAppStyleIsolation;
@@ -21,7 +21,7 @@ function initLaunchwebview(manifestJson, pagesJson) {
21
21
  });
22
22
  // 首页为nvue
23
23
  const entryPage = pagesJson.pages.find((p) => p.path === entryPagePath);
24
- if (entryPage === null || entryPage === void 0 ? void 0 : entryPage.style.isNVue) {
24
+ if (entryPage?.style.isNVue) {
25
25
  manifestJson.plus.launchwebview.uniNView = { path: entryPagePath + '.js' };
26
26
  }
27
27
  else {
@@ -30,9 +30,8 @@ function getNVueStyleCompiler(manifestJson) {
30
30
  exports.getNVueStyleCompiler = getNVueStyleCompiler;
31
31
  const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse'];
32
32
  function getNVueFlexDirection(manifestJson) {
33
- var _a, _b;
34
33
  let flexDir = 'column';
35
- if ((_b = (_a = manifestJson['app-plus']) === null || _a === void 0 ? void 0 : _a.nvue) === null || _b === void 0 ? void 0 : _b['flex-direction']) {
34
+ if (manifestJson['app-plus']?.nvue?.['flex-direction']) {
36
35
  flexDir = manifestJson['app-plus'].nvue['flex-direction'];
37
36
  if (flexDirs.indexOf(flexDir) === -1) {
38
37
  flexDir = 'column';
@@ -14,7 +14,6 @@ const wxPageOrientationMapping = {
14
14
  landscape: ['landscape-primary', 'landscape-secondary'],
15
15
  };
16
16
  function initPlus(manifestJson, pagesJson) {
17
- var _a;
18
17
  initUniStatistics(manifestJson);
19
18
  // 转换为老版本配置
20
19
  if (manifestJson.plus.modules) {
@@ -50,7 +49,7 @@ function initPlus(manifestJson, pagesJson) {
50
49
  manifestJson.screenOrientation = manifestJson.plus.screenOrientation;
51
50
  delete manifestJson.plus.screenOrientation;
52
51
  }
53
- else if ((_a = pagesJson.globalStyle) === null || _a === void 0 ? void 0 : _a.pageOrientation) {
52
+ else if (pagesJson.globalStyle?.pageOrientation) {
54
53
  // 兼容微信小程序
55
54
  const pageOrientationValue = wxPageOrientationMapping[pagesJson.globalStyle
56
55
  .pageOrientation];
@@ -93,7 +92,6 @@ function initPlus(manifestJson, pagesJson) {
93
92
  }
94
93
  exports.initPlus = initPlus;
95
94
  function initUniStatistics(manifestJson) {
96
- var _a;
97
95
  // 根节点配置了统计
98
96
  if (manifestJson.uniStatistics) {
99
97
  manifestJson.plus.uniStatistics = (0, merge_1.recursive)(true, manifestJson.uniStatistics, manifestJson.plus.uniStatistics);
@@ -114,7 +112,7 @@ function initUniStatistics(manifestJson) {
114
112
  if (!space) {
115
113
  return;
116
114
  }
117
- const uniStatistics = (_a = manifestJson.plus) === null || _a === void 0 ? void 0 : _a.uniStatistics;
115
+ const uniStatistics = manifestJson.plus?.uniStatistics;
118
116
  if (!uniStatistics) {
119
117
  return;
120
118
  }
@@ -2,8 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initSafearea = void 0;
4
4
  function initSafearea(manifestJson, pagesJson) {
5
- var _a, _b;
6
- if ((_b = (_a = pagesJson.tabBar) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.length) {
5
+ if (pagesJson.tabBar?.list?.length) {
7
6
  // 安全区配置 仅包含 tabBar 的时候才配置
8
7
  if (!manifestJson.plus.safearea) {
9
8
  manifestJson.plus.safearea = {
@@ -34,8 +34,7 @@ function initSplashscreen(manifestJson, userManifestJson) {
34
34
  }
35
35
  exports.initSplashscreen = initSplashscreen;
36
36
  function getSplashscreen(manifestJson) {
37
- var _a;
38
- const splashscreenOptions = ((_a = manifestJson['app-plus']) === null || _a === void 0 ? void 0 : _a.splashscreen) || {};
37
+ const splashscreenOptions = manifestJson['app-plus']?.splashscreen || {};
39
38
  return {
40
39
  autoclose: splashscreenOptions.autoclose !== false,
41
40
  alwaysShowBeforeRender: splashscreenOptions.alwaysShowBeforeRender !== false,
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initTabBar = void 0;
4
4
  const uni_shared_1 = require("@dcloudio/uni-shared");
5
5
  function initTabBar(entryPagePath, manifestJson, pagesJson) {
6
- var _a, _b;
7
- if (!((_b = (_a = pagesJson.tabBar) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.length)) {
6
+ if (!pagesJson.tabBar?.list?.length) {
8
7
  return;
9
8
  }
10
9
  const tabBar = JSON.parse(JSON.stringify(pagesJson.tabBar));
@@ -12,7 +12,6 @@ const arguments_1 = require("../manifest/arguments");
12
12
  const splashscreen_1 = require("../manifest/splashscreen");
13
13
  const theme_1 = require("../../theme");
14
14
  function normalizeAppUniConfig(pagesJson, manifestJson) {
15
- var _a;
16
15
  const { autoclose, alwaysShowBeforeRender } = (0, splashscreen_1.getSplashscreen)(manifestJson);
17
16
  const platformConfig = (0, manifest_1.getPlatformManifestJsonOnce)();
18
17
  const config = {
@@ -23,7 +22,7 @@ function normalizeAppUniConfig(pagesJson, manifestJson) {
23
22
  styleCompiler: (0, manifest_2.getNVueStyleCompiler)(manifestJson),
24
23
  'flex-direction': (0, manifest_2.getNVueFlexDirection)(manifestJson),
25
24
  },
26
- renderer: ((_a = manifestJson['app-plus']) === null || _a === void 0 ? void 0 : _a.renderer) === 'native' ? 'native' : 'auto',
25
+ renderer: manifestJson['app-plus']?.renderer === 'native' ? 'native' : 'auto',
27
26
  appname: manifestJson.name || '',
28
27
  splashscreen: {
29
28
  alwaysShowBeforeRender,
@@ -42,7 +41,6 @@ function normalizeAppUniConfig(pagesJson, manifestJson) {
42
41
  }
43
42
  exports.normalizeAppUniConfig = normalizeAppUniConfig;
44
43
  function parseEntryPagePath(pagesJson) {
45
- var _a;
46
44
  const res = {
47
45
  entryPagePath: '',
48
46
  entryPageQuery: '',
@@ -62,7 +60,7 @@ function parseEntryPagePath(pagesJson) {
62
60
  res.entryPagePath = entryPagePath;
63
61
  res.entryPageQuery = args.query ? '?' + args.query : '';
64
62
  // non tabBar page
65
- if (!(((_a = pagesJson.tabBar) === null || _a === void 0 ? void 0 : _a.list) || []).find((page) => page.pagePath === entryPagePath)) {
63
+ if (!(pagesJson.tabBar?.list || []).find((page) => page.pagePath === entryPagePath)) {
66
64
  res.realEntryPagePath = realEntryPagePath;
67
65
  }
68
66
  }
@@ -44,17 +44,19 @@ function normalizeNetworkTimeout(networkTimeout) {
44
44
  exports.normalizeNetworkTimeout = normalizeNetworkTimeout;
45
45
  function getUniStatistics(inputDir, platform) {
46
46
  const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
47
+ if (platform === 'app') {
48
+ platform = 'app-plus';
49
+ }
47
50
  return (0, shared_1.extend)({}, manifest.uniStatistics, manifest[platform] && manifest[platform].uniStatistics);
48
51
  }
49
52
  exports.getUniStatistics = getUniStatistics;
50
53
  function isEnableUniPushV1(inputDir, platform) {
51
- var _a, _b, _c;
52
54
  if (isEnableUniPushV2(inputDir, platform)) {
53
55
  return false;
54
56
  }
55
57
  const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
56
58
  if (platform === 'app') {
57
- const push = (_c = (_b = (_a = manifest['app-plus']) === null || _a === void 0 ? void 0 : _a.distribute) === null || _b === void 0 ? void 0 : _b.sdkConfigs) === null || _c === void 0 ? void 0 : _c.push;
59
+ const push = manifest['app-plus']?.distribute?.sdkConfigs?.push;
58
60
  if (push && (0, shared_1.hasOwn)(push, 'unipush')) {
59
61
  return true;
60
62
  }
@@ -63,44 +65,38 @@ function isEnableUniPushV1(inputDir, platform) {
63
65
  }
64
66
  exports.isEnableUniPushV1 = isEnableUniPushV1;
65
67
  function isEnableUniPushV2(inputDir, platform) {
66
- var _a, _b, _c, _d, _e, _f, _g;
67
68
  const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
68
69
  if (platform === 'app') {
69
- return (((_e = (_d = (_c = (_b = (_a = manifest['app-plus']) === null || _a === void 0 ? void 0 : _a.distribute) === null || _b === void 0 ? void 0 : _b.sdkConfigs) === null || _c === void 0 ? void 0 : _c.push) === null || _d === void 0 ? void 0 : _d.unipush) === null || _e === void 0 ? void 0 : _e.version) ==
70
+ return (manifest['app-plus']?.distribute?.sdkConfigs?.push?.unipush?.version ==
70
71
  '2');
71
72
  }
72
- return ((_g = (_f = manifest[platform]) === null || _f === void 0 ? void 0 : _f.unipush) === null || _g === void 0 ? void 0 : _g.enable) === true;
73
+ return manifest[platform]?.unipush?.enable === true;
73
74
  }
74
75
  exports.isEnableUniPushV2 = isEnableUniPushV2;
75
76
  function isEnableSecureNetwork(inputDir, platform) {
76
- var _a, _b, _c, _d;
77
77
  const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
78
78
  if (platform === 'app') {
79
- return !!((_b = (_a = manifest['app-plus']) === null || _a === void 0 ? void 0 : _a.modules) === null || _b === void 0 ? void 0 : _b.SecureNetwork);
79
+ return !!manifest['app-plus']?.modules?.SecureNetwork;
80
80
  }
81
- return ((_d = (_c = manifest[platform]) === null || _c === void 0 ? void 0 : _c.secureNetwork) === null || _d === void 0 ? void 0 : _d.enable) === true;
81
+ return manifest[platform]?.secureNetwork?.enable === true;
82
82
  }
83
83
  exports.isEnableSecureNetwork = isEnableSecureNetwork;
84
84
  function isUniPushOffline(inputDir) {
85
- var _a, _b, _c, _d, _e;
86
85
  const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
87
- return (((_e = (_d = (_c = (_b = (_a = manifest['app-plus']) === null || _a === void 0 ? void 0 : _a.distribute) === null || _b === void 0 ? void 0 : _b.sdkConfigs) === null || _c === void 0 ? void 0 : _c.push) === null || _d === void 0 ? void 0 : _d.unipush) === null || _e === void 0 ? void 0 : _e.offline) ===
86
+ return (manifest['app-plus']?.distribute?.sdkConfigs?.push?.unipush?.offline ===
88
87
  true);
89
88
  }
90
89
  exports.isUniPushOffline = isUniPushOffline;
91
90
  function getRouterOptions(manifestJson) {
92
- var _a;
93
- return (0, shared_1.extend)({}, (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.router);
91
+ return (0, shared_1.extend)({}, manifestJson.h5?.router);
94
92
  }
95
93
  exports.getRouterOptions = getRouterOptions;
96
94
  function isEnableTreeShaking(manifestJson) {
97
- var _a, _b, _c;
98
- return ((_c = (_b = (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.optimization) === null || _b === void 0 ? void 0 : _b.treeShaking) === null || _c === void 0 ? void 0 : _c.enable) !== false;
95
+ return manifestJson.h5?.optimization?.treeShaking?.enable !== false;
99
96
  }
100
97
  exports.isEnableTreeShaking = isEnableTreeShaking;
101
98
  function getDevServerOptions(manifestJson) {
102
- var _a;
103
- return (0, shared_1.extend)({}, (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.devServer);
99
+ return (0, shared_1.extend)({}, manifestJson.h5?.devServer);
104
100
  }
105
101
  exports.getDevServerOptions = getDevServerOptions;
106
102
  function getPlatformManifestJsonOnce() {
@@ -53,7 +53,6 @@ exports.normalizeJsonFilename = normalizeJsonFilename;
53
53
  function findChangedJsonFiles(supportGlobalUsingComponents = true) {
54
54
  const changedJsonFiles = new Map();
55
55
  function findChangedFile(filename, json) {
56
- var _a;
57
56
  const newJson = JSON.parse(JSON.stringify(json));
58
57
  if (!newJson.usingComponents) {
59
58
  newJson.usingComponents = {};
@@ -63,7 +62,7 @@ function findChangedJsonFiles(supportGlobalUsingComponents = true) {
63
62
  // app.json mp-baidu 在 win 不支持相对路径。所有平台改用绝对路径
64
63
  if (filename !== 'app') {
65
64
  let usingComponents = newJson.usingComponents;
66
- const globalUsingComponents = (_a = appJsonCache === null || appJsonCache === void 0 ? void 0 : appJsonCache.usingComponents) !== null && _a !== void 0 ? _a : {};
65
+ const globalUsingComponents = appJsonCache?.usingComponents ?? {};
67
66
  // 如果小程序不支持 global 的 usingComponents
68
67
  if (!supportGlobalUsingComponents) {
69
68
  // 从 appJsonCache 中读取全局的 usingComponents 并补充到子组件 usingComponents 中
@@ -26,6 +26,7 @@ const NON_APP_JSON_KEYS = [
26
26
  'scopedSlotsCompiler',
27
27
  'usingComponents',
28
28
  'uniStatistics',
29
+ 'mergeVirtualHostAttributes',
29
30
  ];
30
31
  function mergeMiniProgramAppJson(appJson, platformJson = {}) {
31
32
  Object.keys(platformJson).forEach((name) => {
@@ -408,8 +408,7 @@ function normalizePagesRoute(pagesJson) {
408
408
  }
409
409
  exports.normalizePagesRoute = normalizePagesRoute;
410
410
  function isEnablePullDownRefresh(pageStyle) {
411
- var _a;
412
- return pageStyle.enablePullDownRefresh || ((_a = pageStyle.pullToRefresh) === null || _a === void 0 ? void 0 : _a.support);
411
+ return pageStyle.enablePullDownRefresh || pageStyle.pullToRefresh?.support;
413
412
  }
414
413
  function normalizePullToRefresh(pageStyle) {
415
414
  return pageStyle.pullToRefresh;
@@ -65,7 +65,7 @@ function formatInfoMsg(msg, options) {
65
65
  if (formatter) {
66
66
  return formatter.format(msg, options);
67
67
  }
68
- if (options === null || options === void 0 ? void 0 : options.nvue) {
68
+ if (options?.nvue) {
69
69
  initNVueInfoFormattersOnce();
70
70
  const formatter = nvueInfoFormatters.find(({ test }) => test(msg, options));
71
71
  if (formatter) {
package/dist/mp/ast.d.ts CHANGED
@@ -1,4 +1,5 @@
1
+ import type { Program } from '@babel/types';
1
2
  import { ParserPlugin } from '@babel/parser';
2
3
  export declare function parseProgram(code: string, importer: string, { babelParserPlugins }: {
3
4
  babelParserPlugins?: ParserPlugin[];
4
- }): import("@babel/types").Program;
5
+ }): Program;
@@ -57,9 +57,8 @@ function walkDecls(rpx2unit) {
57
57
  };
58
58
  }
59
59
  function filterPrefersColorScheme(root) {
60
- var _a;
61
60
  if (process.env.VUE_APP_DARK_MODE !== 'true') {
62
- const filePath = (_a = root.source) === null || _a === void 0 ? void 0 : _a.input.file;
61
+ const filePath = root.source?.input.file;
63
62
  if (filePath && filePath.includes('@dcloudio')) {
64
63
  root.walkAtRules((rule) => {
65
64
  if (rule.params.includes('prefers-color-scheme')) {
package/dist/scripts.js CHANGED
@@ -7,17 +7,16 @@ exports.parseScripts = void 0;
7
7
  const shared_1 = require("@vue/shared");
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  function parseScripts(name, pkgPath) {
10
- var _a, _b;
11
10
  if (!fs_1.default.existsSync(pkgPath)) {
12
11
  return;
13
12
  }
14
13
  const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf8'));
15
- const scripts = ((_a = pkg['uni-app']) === null || _a === void 0 ? void 0 : _a.scripts) || {};
14
+ const scripts = pkg['uni-app']?.scripts || {};
16
15
  const options = scripts[name];
17
16
  if (!options) {
18
17
  return;
19
18
  }
20
- if (!((_b = options.env) === null || _b === void 0 ? void 0 : _b.UNI_PLATFORM)) {
19
+ if (!options.env?.UNI_PLATFORM) {
21
20
  console.error(`package.json->uni-app->scripts->${name}->env->UNI_PLATFORM is required`);
22
21
  process.exit(0);
23
22
  }
@@ -14,7 +14,6 @@ function parseUniExtApis(vite = true) {
14
14
  }
15
15
  const injects = {};
16
16
  fs_extra_1.default.readdirSync(uniModulesDir).forEach((uniModuleDir) => {
17
- var _a, _b;
18
17
  // 必须以 uni- 开头
19
18
  if (!uniModuleDir.startsWith('uni-')) {
20
19
  return;
@@ -24,7 +23,8 @@ function parseUniExtApis(vite = true) {
24
23
  return;
25
24
  }
26
25
  try {
27
- const exports = (_b = (_a = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))) === null || _a === void 0 ? void 0 : _a.uni_modules) === null || _b === void 0 ? void 0 : _b['uni-ext-api'];
26
+ const exports = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))
27
+ ?.uni_modules?.['uni-ext-api'];
28
28
  if (exports) {
29
29
  Object.assign(injects, parseInjects(vite, process.env.UNI_PLATFORM === 'h5'
30
30
  ? 'web'
package/dist/utils.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare function normalizePagePath(pagePath: string, platform: UniApp.PLA
11
11
  export declare function removeExt(str: string): string;
12
12
  export declare function normalizeNodeModules(str: string): string;
13
13
  export declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string;
14
- export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): ParserPlugin[];
14
+ export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): (import("@babel/parser").ParserPluginWithOptions | ("asyncDoExpressions" | "asyncGenerators" | "bigInt" | "classPrivateMethods" | "classPrivateProperties" | "classProperties" | "classStaticBlock" | "decimal" | "decorators-legacy" | "decoratorAutoAccessors" | "destructuringPrivate" | "doExpressions" | "dynamicImport" | "explicitResourceManagement" | "exportDefaultFrom" | "exportNamespaceFrom" | "flow" | "flowComments" | "functionBind" | "functionSent" | "importMeta" | "jsx" | "logicalAssignment" | "importAssertions" | "importReflection" | "moduleBlocks" | "moduleStringNames" | "nullishCoalescingOperator" | "numericSeparator" | "objectRestSpread" | "optionalCatchBinding" | "optionalChaining" | "partialApplication" | "placeholders" | "privateIn" | "regexpUnicodeSets" | "throwExpressions" | "topLevelAwait" | "v8intrinsic" | "decorators" | "estree" | "moduleAttributes" | "pipelineOperator" | "recordAndTuple" | "typescript"))[];
15
15
  export declare function pathToGlob(pathString: string, glob: string, options?: {
16
16
  windows?: boolean;
17
17
  escape?: boolean;
package/dist/utils.js CHANGED
@@ -17,7 +17,7 @@ exports.version = require('../package.json').version;
17
17
  try {
18
18
  exports.isRunningWithYarnPnp = Boolean(require('pnpapi'));
19
19
  }
20
- catch (_a) { }
20
+ catch { }
21
21
  exports.isWindows = os_1.default.platform() === 'win32';
22
22
  function normalizePath(id) {
23
23
  return exports.isWindows ? id.replace(/\\/g, '/') : id;
@@ -145,8 +145,7 @@ function fileToUrl(id, config, ctx, canInline = false) {
145
145
  }
146
146
  exports.fileToUrl = fileToUrl;
147
147
  function getAssetFilename(hash, config) {
148
- var _a;
149
- return (_a = assetHashToFilenameMap.get(config)) === null || _a === void 0 ? void 0 : _a.get(hash);
148
+ return assetHashToFilenameMap.get(config)?.get(hash);
150
149
  }
151
150
  exports.getAssetFilename = getAssetFilename;
152
151
  /**
@@ -227,7 +226,6 @@ function sanitizeFileName(name) {
227
226
  * and returns the resolved public URL
228
227
  */
229
228
  function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, canInline = false) {
230
- var _a, _b, _c, _d;
231
229
  if (!skipPublicCheck && checkPublicFile(id, config)) {
232
230
  return config.base + id.slice(1);
233
231
  }
@@ -248,15 +246,16 @@ function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, canI
248
246
  const contentHash = getAssetHash(content);
249
247
  const { search, hash } = (0, url_1.parse)(id);
250
248
  const postfix = (search || '') + (hash || '');
251
- const output = (_b = (_a = config.build) === null || _a === void 0 ? void 0 : _a.rollupOptions) === null || _b === void 0 ? void 0 : _b.output;
249
+ const output = config.build?.rollupOptions?.output;
252
250
  const defaultAssetFileNames = path_1.default.posix.join(config.build.assetsDir, '[name].[hash][extname]');
253
251
  // Steps to determine which assetFileNames will be actually used.
254
252
  // First, if output is an object or string, use assetFileNames in it.
255
253
  // And a default assetFileNames as fallback.
256
- let assetFileNames = (_c = (output && !Array.isArray(output) ? output.assetFileNames : undefined)) !== null && _c !== void 0 ? _c : defaultAssetFileNames;
254
+ let assetFileNames = (output && !Array.isArray(output) ? output.assetFileNames : undefined) ??
255
+ defaultAssetFileNames;
257
256
  if (output && Array.isArray(output)) {
258
257
  // Second, if output is an array, adopt assetFileNames in the first object.
259
- assetFileNames = (_d = output[0].assetFileNames) !== null && _d !== void 0 ? _d : assetFileNames;
258
+ assetFileNames = output[0].assetFileNames ?? assetFileNames;
260
259
  }
261
260
  const inputDir = (0, utils_1.normalizePath)(process.env.UNI_INPUT_DIR);
262
261
  let fileName = file.startsWith(inputDir) && file.includes('/static/')
@@ -37,7 +37,6 @@ const utils_1 = require("../utils");
37
37
  const asset_1 = require("./asset");
38
38
  const magic_string_1 = __importDefault(require("magic-string"));
39
39
  const preprocess_1 = require("../../../../preprocess");
40
- const constants_1 = require("../../../../constants");
41
40
  const cleanString_1 = require("../cleanString");
42
41
  const shared_1 = require("@vue/shared");
43
42
  const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
@@ -108,34 +107,6 @@ function cssPlugin(config) {
108
107
  };
109
108
  }
110
109
  exports.cssPlugin = cssPlugin;
111
- function findCssModuleIds(moduleId, cssModuleIds, seen) {
112
- if (!cssModuleIds) {
113
- cssModuleIds = new Set();
114
- }
115
- if (!seen) {
116
- seen = new Set();
117
- }
118
- if (seen.has(moduleId)) {
119
- return cssModuleIds;
120
- }
121
- seen.add(moduleId);
122
- const moduleInfo = this.getModuleInfo(moduleId);
123
- if (moduleInfo) {
124
- moduleInfo.importedIds.forEach((id) => {
125
- if (id.includes(constants_1.PAGES_JSON_JS)) {
126
- // 查询main.js时,需要忽略pages.json.js,否则会把所有页面样式加进来
127
- return;
128
- }
129
- if (exports.cssLangRE.test(id) && !exports.commonjsProxyRE.test(id)) {
130
- cssModuleIds.add(id);
131
- }
132
- else {
133
- findCssModuleIds.call(this, id, cssModuleIds, seen);
134
- }
135
- });
136
- }
137
- return cssModuleIds;
138
- }
139
110
  /**
140
111
  * Plugin applied after user plugins
141
112
  */
@@ -164,14 +135,18 @@ function cssPostPlugin(config, { chunkCssFilename, chunkCssCode, }) {
164
135
  moduleSideEffects: 'no-treeshake',
165
136
  };
166
137
  },
167
- async generateBundle() {
168
- const moduleIds = Array.from(this.getModuleIds());
169
- moduleIds.forEach((id) => {
138
+ async renderChunk(_code, chunk, _opts) {
139
+ const id = chunk.facadeModuleId;
140
+ if (id) {
170
141
  const filename = chunkCssFilename(id);
171
142
  if (filename) {
172
- cssChunks.set(filename, findCssModuleIds.call(this, id));
143
+ const ids = Object.keys(chunk.modules).filter((id) => styles.has(id));
144
+ cssChunks.set(filename, ids);
173
145
  }
174
- });
146
+ }
147
+ return null;
148
+ },
149
+ async generateBundle() {
175
150
  if (!cssChunks.size) {
176
151
  return;
177
152
  }
@@ -254,7 +229,6 @@ function getCssResolversKeys(resolvers) {
254
229
  return Object.keys(resolvers);
255
230
  }
256
231
  async function compileCSS(id, code, config, urlReplacer, atImportResolvers, server) {
257
- var _a;
258
232
  const { modules: modulesOptions, preprocessorOptions, devSourcemap, } = config.css || {};
259
233
  const isModule = modulesOptions !== false && cssModuleRE.test(id);
260
234
  // although at serve time it can work without processing, we do need to
@@ -262,7 +236,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
262
236
  const needInlineImport = code.includes('@import');
263
237
  const hasUrl = exports.cssUrlRE.test(code) || cssImageSetRE.test(code);
264
238
  const postcssConfig = await resolvePostcssConfig(config);
265
- const lang = (_a = id.match(exports.cssLangRE)) === null || _a === void 0 ? void 0 : _a[1];
239
+ const lang = id.match(exports.cssLangRE)?.[1];
266
240
  // 1. plain css that needs no processing
267
241
  if (lang === 'css' &&
268
242
  !postcssConfig &&
@@ -299,7 +273,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
299
273
  }
300
274
  // important: set this for relative import resolving
301
275
  opts.filename = (0, utils_1.cleanUrl)(id);
302
- opts.enableSourcemap = devSourcemap !== null && devSourcemap !== void 0 ? devSourcemap : false;
276
+ opts.enableSourcemap = devSourcemap ?? false;
303
277
  const preprocessResult = await preProcessor(code, config.root, opts, atImportResolvers, !!config.nvue);
304
278
  if (preprocessResult.errors.length) {
305
279
  throw preprocessResult.errors[0];
@@ -494,13 +468,12 @@ function combineSourcemapsIfExists(filename, map1, map2) {
494
468
  : map1;
495
469
  }
496
470
  async function resolvePostcssConfig(config) {
497
- var _a;
498
471
  let result = postcssConfigCache.get(config);
499
472
  if (result !== undefined) {
500
473
  return result;
501
474
  }
502
475
  // inline postcss config via vite config
503
- const inlineOptions = (_a = config.css) === null || _a === void 0 ? void 0 : _a.postcss;
476
+ const inlineOptions = config.css?.postcss;
504
477
  if ((0, utils_1.isObject)(inlineOptions)) {
505
478
  const options = { ...inlineOptions };
506
479
  delete options.plugins;
@@ -552,8 +525,7 @@ const UrlRewritePostcssPlugin = (opts) => {
552
525
  const isCssImageSet = cssImageSetRE.test(declaration.value);
553
526
  if (isCssUrl || isCssImageSet) {
554
527
  const replacerForDeclaration = (rawUrl) => {
555
- var _a;
556
- const importer = (_a = declaration.source) === null || _a === void 0 ? void 0 : _a.input.file;
528
+ const importer = declaration.source?.input.file;
557
529
  return opts.replacer(rawUrl, importer);
558
530
  };
559
531
  const rewriterToUse = isCssImageSet
@@ -700,14 +672,13 @@ async function hoistAtRules(css) {
700
672
  exports.hoistAtRules = hoistAtRules;
701
673
  const loadedPreprocessors = {};
702
674
  function loadPreprocessor(lang, root) {
703
- var _a, _b;
704
675
  if (lang in loadedPreprocessors) {
705
676
  return loadedPreprocessors[lang];
706
677
  }
707
678
  try {
708
679
  // Search for the preprocessor in the root directory first, and fall back
709
680
  // to the default require paths.
710
- const fallbackPaths = ((_b = (_a = require.resolve).paths) === null || _b === void 0 ? void 0 : _b.call(_a, lang)) || [];
681
+ const fallbackPaths = require.resolve.paths?.(lang) || [];
711
682
  const resolved = require.resolve(lang, { paths: [root, ...fallbackPaths] });
712
683
  return (loadedPreprocessors[lang] = require(resolved));
713
684
  }
@@ -722,11 +693,11 @@ const scss = async (source, root, options, resolvers, isNVue) => {
722
693
  resolvers.sass(url, importer).then((resolved) => {
723
694
  if (resolved) {
724
695
  rebaseUrls(resolved, options.filename, options.alias, isNVue)
725
- .then((data) => done === null || done === void 0 ? void 0 : done(data))
726
- .catch((data) => done === null || done === void 0 ? void 0 : done(data));
696
+ .then((data) => done?.(data))
697
+ .catch((data) => done?.(data));
727
698
  }
728
699
  else {
729
- done === null || done === void 0 ? void 0 : done(null);
700
+ done?.(null);
730
701
  }
731
702
  });
732
703
  };
@@ -937,14 +908,13 @@ function createViteLessPlugin(less, rootFile, alias, resolvers, isNVue) {
937
908
  }
938
909
  // .styl
939
910
  const styl = async (source, root, options) => {
940
- var _a;
941
911
  const nodeStylus = loadPreprocessor("stylus" /* PreprocessLang.stylus */, root);
942
912
  // Get source with preprocessor options.additionalData. Make sure a new line separator
943
913
  // is added to avoid any render error, as added stylus content may not have semi-colon separators
944
914
  const { content, map: additionalMap } = await getSource(source, options.filename, options.additionalData, options.enableSourcemap, '\n');
945
915
  // Get preprocessor options.imports dependencies as stylus
946
916
  // does not return them with its builtin `.deps()` method
947
- const importsDeps = ((_a = options.imports) !== null && _a !== void 0 ? _a : []).map((dep) => path_1.default.resolve(dep));
917
+ const importsDeps = (options.imports ?? []).map((dep) => path_1.default.resolve(dep));
948
918
  try {
949
919
  const ref = nodeStylus(content, options);
950
920
  if (options.enableSourcemap) {
@@ -113,7 +113,7 @@ async function processSrcSet(srcs, replacer) {
113
113
  const [url] = imageSetUrlRE.exec(src) || [];
114
114
  return {
115
115
  url: url,
116
- descriptor: src === null || src === void 0 ? void 0 : src.slice(url.length).trim(),
116
+ descriptor: src?.slice(url.length).trim(),
117
117
  };
118
118
  })
119
119
  .filter(({ url }) => !!url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3061520221220001",
3
+ "version": "3.0.0-alpha-3061620221230002",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@ampproject/remapping": "^2.1.2",
25
- "@babel/core": "^7.19.6",
26
- "@babel/parser": "^7.19.6",
27
- "@babel/types": "^7.20.0",
28
- "@dcloudio/uni-i18n": "3.0.0-alpha-3061520221220001",
29
- "@dcloudio/uni-shared": "3.0.0-alpha-3061520221220001",
25
+ "@babel/core": "^7.20.5",
26
+ "@babel/parser": "^7.20.5",
27
+ "@babel/types": "^7.20.7",
28
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3061620221230002",
29
+ "@dcloudio/uni-shared": "3.0.0-alpha-3061620221230002",
30
30
  "@intlify/core-base": "9.1.9",
31
31
  "@intlify/shared": "9.1.9",
32
32
  "@intlify/vue-devtools": "9.1.9",
@@ -42,13 +42,13 @@
42
42
  "compare-versions": "^3.6.0",
43
43
  "debug": "^4.3.3",
44
44
  "es-module-lexer": "^0.9.3",
45
- "esbuild": "^0.15.9",
45
+ "esbuild": "^0.16.3",
46
46
  "estree-walker": "^2.0.2",
47
47
  "fast-glob": "^3.2.11",
48
48
  "fs-extra": "^10.0.0",
49
49
  "hash-sum": "^2.0.0",
50
50
  "jsonc-parser": "^3.0.0",
51
- "magic-string": "^0.26.7",
51
+ "magic-string": "^0.27.0",
52
52
  "merge": "^2.1.1",
53
53
  "mime": "^3.0.0",
54
54
  "module-alias": "^2.2.2",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
66
66
  "devDependencies": {
67
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-3061520221220001",
67
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-3061620221230002",
68
68
  "@types/babel__core": "^7.1.19",
69
69
  "@types/debug": "^4.1.7",
70
70
  "@types/estree": "^0.0.51",