@dcloudio/uni-cli-shared 3.0.0-alpha-3030020211125001 → 3.0.0-alpha-3030020211126001

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.
@@ -1,8 +1,10 @@
1
1
  export declare const PUBLIC_DIR = "static";
2
2
  export declare const EXTNAME_JS: string[];
3
+ export declare const EXTNAME_TS: string[];
3
4
  export declare const EXTNAME_VUE: string[];
4
5
  export declare const EXTNAME_VUE_RE: RegExp;
5
6
  export declare const EXTNAME_JS_RE: RegExp;
7
+ export declare const EXTNAME_TS_RE: RegExp;
6
8
  export declare const ASSETS_INLINE_LIMIT: number;
7
9
  export declare const APP_SERVICE_FILENAME = "app-service.js";
8
10
  export declare const BINDING_COMPONENTS = "__BINDING_COMPONENTS__";
package/dist/constants.js CHANGED
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
3
+ exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
4
4
  exports.PUBLIC_DIR = 'static';
5
5
  exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
6
+ exports.EXTNAME_TS = ['.ts', '.tsx'];
6
7
  exports.EXTNAME_VUE = ['.vue', '.nvue'];
7
8
  exports.EXTNAME_VUE_RE = /\.(vue|nvue)$/;
8
9
  exports.EXTNAME_JS_RE = /\.[jt]sx?$/;
10
+ exports.EXTNAME_TS_RE = /\.tsx?$/;
9
11
  exports.ASSETS_INLINE_LIMIT = 40 * 1024;
10
12
  exports.APP_SERVICE_FILENAME = 'app-service.js';
11
13
  exports.BINDING_COMPONENTS = '__BINDING_COMPONENTS__';
@@ -17,7 +17,7 @@ function normalizeAppConfigService(pagesJson, manifestJson) {
17
17
  const __uniRoutes = ${(0, uniRoutes_1.normalizeAppUniRoutes)(pagesJson)}.map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
18
18
  __uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
19
19
  __uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
20
- service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:Math.round(f/20)})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,${code_1.globalCode}}}}});
20
+ service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:16})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,${code_1.globalCode}}}}});
21
21
  })();
22
22
  `;
23
23
  }
@@ -1,5 +1,12 @@
1
1
  import { PluginContext } from 'rollup';
2
2
  import { ImportSpecifier } from 'es-module-lexer';
3
+ /**
4
+ * 暂时没用
5
+ * @param source
6
+ * @param importer
7
+ * @param resolve
8
+ * @returns
9
+ */
3
10
  export declare function findVueComponentImports(source: string, importer: string, resolve: PluginContext['resolve']): Promise<(ImportSpecifier & {
4
11
  i: string;
5
12
  })[]>;
@@ -10,6 +10,14 @@ const shared_1 = require("@vue/shared");
10
10
  const types_1 = require("@babel/types");
11
11
  const parser_1 = require("@babel/parser");
12
12
  const constants_1 = require("../constants");
13
+ const utils_1 = require("../utils");
14
+ /**
15
+ * 暂时没用
16
+ * @param source
17
+ * @param importer
18
+ * @param resolve
19
+ * @returns
20
+ */
13
21
  async function findVueComponentImports(source, importer, resolve) {
14
22
  await es_module_lexer_1.init;
15
23
  let imports = [];
@@ -44,6 +52,7 @@ async function findVueComponentImports(source, importer, resolve) {
44
52
  }
45
53
  if (constants_1.EXTNAME_VUE_RE.test(res.id)) {
46
54
  const expr = (0, parser_1.parse)(source.slice(importSpecifier.ss, importSpecifier.se), {
55
+ plugins: (0, utils_1.normalizeParsePlugins)(res.id),
47
56
  sourceType: 'module',
48
57
  }).program.body[0];
49
58
  if ((0, types_1.isImportDeclaration)(expr) && expr.specifiers.length === 1) {
@@ -19,7 +19,7 @@ async function transformVueComponentImports(code, importer, { root, resolve, glo
19
19
  }
20
20
  const s = new magic_string_1.default(code);
21
21
  const scriptAst = (0, parser_1.parse)(code, {
22
- plugins: [...(babelParserPlugins || [])],
22
+ plugins: (0, utils_1.normalizeParsePlugins)(importer, babelParserPlugins),
23
23
  sourceType: 'module',
24
24
  }).program;
25
25
  const imports = findVueComponentImports(scriptAst.body, global
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as hash } from 'hash-sum';
2
2
  import { ElementNode, RootNode, TemplateChildNode } from '@vue/compiler-core';
3
+ import { ParserPlugin } from '@babel/parser';
3
4
  export declare let isRunningWithYarnPnp: boolean;
4
5
  export declare const isWindows: boolean;
5
6
  export declare function normalizePath(id: string): string;
@@ -9,3 +10,4 @@ export declare function normalizePagePath(pagePath: string, platform: UniApp.PLA
9
10
  export declare function removeExt(str: string): string;
10
11
  export declare function normalizeNodeModules(str: string): string;
11
12
  export declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string;
13
+ export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): ParserPlugin[];
package/dist/utils.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.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.hash = void 0;
6
+ exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.hash = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -65,3 +65,16 @@ function normalizeMiniProgramFilename(filename, inputDir) {
65
65
  return normalizeNodeModules(path_1.default.relative(inputDir, filename));
66
66
  }
67
67
  exports.normalizeMiniProgramFilename = normalizeMiniProgramFilename;
68
+ function normalizeParsePlugins(importer, babelParserPlugins) {
69
+ const isTS = constants_1.EXTNAME_TS_RE.test(importer.split('?')[0]);
70
+ const plugins = [];
71
+ if (isTS) {
72
+ plugins.push('jsx');
73
+ }
74
+ if (babelParserPlugins)
75
+ plugins.push(...babelParserPlugins);
76
+ if (isTS)
77
+ plugins.push('typescript', 'decorators-legacy');
78
+ return plugins;
79
+ }
80
+ exports.normalizeParsePlugins = normalizeParsePlugins;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3030020211125001",
3
+ "version": "3.0.0-alpha-3030020211126001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,13 +20,13 @@
20
20
  "dependencies": {
21
21
  "@babel/parser": "^7.15.0",
22
22
  "@babel/types": "^7.15.0",
23
- "@dcloudio/uni-i18n": "3.0.0-alpha-3030020211125001",
24
- "@dcloudio/uni-shared": "3.0.0-alpha-3030020211125001",
23
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3030020211126001",
24
+ "@dcloudio/uni-shared": "3.0.0-alpha-3030020211126001",
25
25
  "@rollup/pluginutils": "^4.1.1",
26
- "@vue/compiler-core": "3.2.22",
27
- "@vue/compiler-dom": "3.2.22",
28
- "@vue/compiler-sfc": "3.2.22",
29
- "@vue/shared": "3.2.22",
26
+ "@vue/compiler-core": "3.2.23",
27
+ "@vue/compiler-dom": "3.2.23",
28
+ "@vue/compiler-sfc": "3.2.23",
29
+ "@vue/shared": "3.2.23",
30
30
  "chalk": "^4.1.1",
31
31
  "chokidar": "^3.5.2",
32
32
  "compare-versions": "^3.6.0",