@tarojs/helper 3.4.8 → 3.5.0-alpha.10

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
@@ -168,9 +168,9 @@ exports.taroJsMobx = '@tarojs/mobx';
168
168
  exports.taroJsMobxCommon = '@tarojs/mobx-common';
169
169
  exports.DEVICE_RATIO_NAME = 'deviceRatio';
170
170
  exports.isWindows = os.platform() === 'win32';
171
- exports.DEFAULT_TEMPLATE_SRC = 'github:NervJS/taro-project-templates#v3.4';
172
- exports.DEFAULT_TEMPLATE_SRC_GITEE = 'direct:https://gitee.com/o2team/taro-project-templates.git#v3.4';
173
- exports.TARO_CONFIG_FLODER = '.taro3.4';
171
+ exports.DEFAULT_TEMPLATE_SRC = 'github:NervJS/taro-project-templates#v3.5';
172
+ exports.DEFAULT_TEMPLATE_SRC_GITEE = 'direct:https://gitee.com/o2team/taro-project-templates.git#v3.5';
173
+ exports.TARO_CONFIG_FLODER = '.taro3.5';
174
174
  exports.TARO_BASE_CONFIG = 'index.json';
175
175
  exports.OUTPUT_DIR = 'dist';
176
176
  exports.SOURCE_DIR = 'src';
package/dist/index.js CHANGED
@@ -8,9 +8,11 @@ const constants = require("./constants");
8
8
  const utils = require("./utils");
9
9
  const npm = require("./npm");
10
10
  const babelRegister_1 = require("./babelRegister");
11
+ const swcRegister_1 = require("./swcRegister");
11
12
  exports.helper = Object.assign(Object.assign(Object.assign({}, constants), utils), { npm,
12
13
  createBabelRegister: babelRegister_1.default,
13
14
  injectDefineConfigHeader: babelRegister_1.injectDefineConfigHeader,
15
+ createSwcRegister: swcRegister_1.default,
14
16
  fs,
15
17
  chalk,
16
18
  chokidar, createDebug: id => require('debug')(id) });
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InjectDefinConfigHeader = void 0;
4
+ const Visitor_js_1 = require("@swc/core/Visitor.js");
5
+ class InjectDefinConfigHeader extends Visitor_js_1.Visitor {
6
+ visitTsType(expression) {
7
+ return expression;
8
+ }
9
+ visitCallExpression(expression) {
10
+ const callee = expression.callee;
11
+ if (callee.type === 'Identifier' && (callee.value === 'definePageConfig' || callee.value === 'defineAppConfig')) {
12
+ return expression.arguments[0].expression;
13
+ }
14
+ return expression;
15
+ }
16
+ }
17
+ exports.InjectDefinConfigHeader = InjectDefinConfigHeader;
18
+ function createSwcRegister({ only, plugin }) {
19
+ const config = {
20
+ only: Array.from(new Set([...only])),
21
+ jsc: {
22
+ parser: {
23
+ syntax: 'typescript',
24
+ decorators: true
25
+ },
26
+ transform: {
27
+ legacyDecorator: true
28
+ }
29
+ },
30
+ module: {
31
+ type: 'commonjs'
32
+ }
33
+ };
34
+ if (plugin)
35
+ config.plugin = plugin;
36
+ require('@swc/register')(config);
37
+ }
38
+ exports.default = createSwcRegister;
package/dist/utils.js CHANGED
@@ -17,7 +17,7 @@ const child_process = require("child_process");
17
17
  const chalk = require("chalk");
18
18
  const lodash_1 = require("lodash");
19
19
  const constants_1 = require("./constants");
20
- const babelRegister_1 = require("./babelRegister");
20
+ const swcRegister_1 = require("./swcRegister");
21
21
  const execSync = child_process.execSync;
22
22
  function normalizePath(path) {
23
23
  return path.replace(/\\/g, '/').replace(/\/{2,}/g, '/');
@@ -255,7 +255,7 @@ function generateConstantsList(constants) {
255
255
  const res = {};
256
256
  if (constants && !isEmptyObject(constants)) {
257
257
  for (const key in constants) {
258
- if (lodash_1.isPlainObject(constants[key])) {
258
+ if ((0, lodash_1.isPlainObject)(constants[key])) {
259
259
  res[key] = generateConstantsList(constants[key]);
260
260
  }
261
261
  else {
@@ -315,7 +315,7 @@ function emptyDirectory(dirPath, opts = { excludes: [] }) {
315
315
  }
316
316
  exports.emptyDirectory = emptyDirectory;
317
317
  /* eslint-enable */
318
- const pascalCase = (str) => str.charAt(0).toUpperCase() + lodash_1.camelCase(str.substr(1));
318
+ const pascalCase = (str) => str.charAt(0).toUpperCase() + (0, lodash_1.camelCase)(str.substr(1));
319
319
  exports.pascalCase = pascalCase;
320
320
  function getInstalledNpmPkgPath(pkgName, basedir) {
321
321
  const resolvePath = require('resolve');
@@ -336,7 +336,7 @@ function getInstalledNpmPkgVersion(pkgName, basedir) {
336
336
  }
337
337
  exports.getInstalledNpmPkgVersion = getInstalledNpmPkgVersion;
338
338
  const recursiveMerge = (src, ...args) => {
339
- return lodash_1.mergeWith(src, ...args, (value, srcValue) => {
339
+ return (0, lodash_1.mergeWith)(src, ...args, (value, srcValue) => {
340
340
  const typeValue = typeof value;
341
341
  const typeSrcValue = typeof srcValue;
342
342
  if (typeValue !== typeSrcValue)
@@ -345,20 +345,20 @@ const recursiveMerge = (src, ...args) => {
345
345
  return value.concat(srcValue);
346
346
  }
347
347
  if (typeValue === 'object') {
348
- return exports.recursiveMerge(value, srcValue);
348
+ return (0, exports.recursiveMerge)(value, srcValue);
349
349
  }
350
350
  });
351
351
  };
352
352
  exports.recursiveMerge = recursiveMerge;
353
353
  const mergeVisitors = (src, ...args) => {
354
354
  const validFuncs = ['exit', 'enter'];
355
- return lodash_1.mergeWith(src, ...args, (value, srcValue, key, object, srcObject) => {
355
+ return (0, lodash_1.mergeWith)(src, ...args, (value, srcValue, key, object, srcObject) => {
356
356
  if (!object.hasOwnProperty(key) || !srcObject.hasOwnProperty(key)) {
357
357
  return undefined;
358
358
  }
359
359
  const shouldMergeToArray = validFuncs.indexOf(key) > -1;
360
360
  if (shouldMergeToArray) {
361
- return lodash_1.flatMap([value, srcValue]);
361
+ return (0, lodash_1.flatMap)([value, srcValue]);
362
362
  }
363
363
  const [newValue, newSrcValue] = [value, srcValue].map(v => {
364
364
  if (typeof v === 'function') {
@@ -370,7 +370,7 @@ const mergeVisitors = (src, ...args) => {
370
370
  return v;
371
371
  }
372
372
  });
373
- return exports.mergeVisitors(newValue, newSrcValue);
373
+ return (0, exports.mergeVisitors)(newValue, newSrcValue);
374
374
  });
375
375
  };
376
376
  exports.mergeVisitors = mergeVisitors;
@@ -386,7 +386,7 @@ const applyArrayedVisitors = obj => {
386
386
  };
387
387
  }
388
388
  else if (typeof funcs === 'object') {
389
- exports.applyArrayedVisitors(funcs);
389
+ (0, exports.applyArrayedVisitors)(funcs);
390
390
  }
391
391
  }
392
392
  return obj;
@@ -448,7 +448,7 @@ const getAllFilesInFloder = (floder, filter = []) => __awaiter(void 0, void 0, v
448
448
  yield Promise.all(list.map((item) => __awaiter(void 0, void 0, void 0, function* () {
449
449
  const itemPath = path.join(floder, item.name);
450
450
  if (item.isDirectory) {
451
- const _files = yield exports.getAllFilesInFloder(itemPath, filter);
451
+ const _files = yield (0, exports.getAllFilesInFloder)(itemPath, filter);
452
452
  files = [...files, ..._files];
453
453
  }
454
454
  else if (item.isFile) {
@@ -615,16 +615,17 @@ function readConfig(configPath) {
615
615
  let result = {};
616
616
  if (fs.existsSync(configPath)) {
617
617
  const importPaths = constants_1.REG_SCRIPTS.test(configPath) ? analyzeImport(configPath) : [];
618
- babelRegister_1.default({
618
+ (0, swcRegister_1.default)({
619
619
  only: [
620
620
  configPath,
621
621
  filepath => importPaths.includes(filepath)
622
- ]
622
+ ],
623
+ plugin: m => new swcRegister_1.InjectDefinConfigHeader().visitProgram(m)
623
624
  });
624
625
  importPaths.concat([configPath]).forEach(item => {
625
626
  delete require.cache[item];
626
627
  });
627
- result = exports.getModuleDefaultExport(require(configPath));
628
+ result = (0, exports.getModuleDefaultExport)(require(configPath));
628
629
  }
629
630
  else {
630
631
  result = readPageConfig(configPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/helper",
3
- "version": "3.4.8",
3
+ "version": "3.5.0-alpha.10",
4
4
  "description": "Taro Helper",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -40,7 +40,9 @@
40
40
  "@babel/preset-typescript": "^7.14.5",
41
41
  "@babel/register": "^7.14.5",
42
42
  "@babel/runtime": "^7.14.5",
43
- "@tarojs/taro": "3.4.8",
43
+ "@swc/core": "^1.2.147",
44
+ "@swc/register": "^0.1.10",
45
+ "@tarojs/taro": "3.5.0-alpha.10",
44
46
  "chalk": "3.0.0",
45
47
  "chokidar": "^3.3.1",
46
48
  "cross-spawn": "^7.0.3",
@@ -51,5 +53,5 @@
51
53
  "resolve": "^1.6.0",
52
54
  "yauzl": "2.10.0"
53
55
  },
54
- "gitHead": "a025bcbb226ed3d01ed218c269a05d2e98109a46"
56
+ "gitHead": "8569f73a71cd11c697e66662d584c17175c7343b"
55
57
  }
@@ -73,9 +73,9 @@ export declare const taroJsMobx = "@tarojs/mobx";
73
73
  export declare const taroJsMobxCommon = "@tarojs/mobx-common";
74
74
  export declare const DEVICE_RATIO_NAME = "deviceRatio";
75
75
  export declare const isWindows: boolean;
76
- export declare const DEFAULT_TEMPLATE_SRC = "github:NervJS/taro-project-templates#v3.4";
77
- export declare const DEFAULT_TEMPLATE_SRC_GITEE = "direct:https://gitee.com/o2team/taro-project-templates.git#v3.4";
78
- export declare const TARO_CONFIG_FLODER = ".taro3.4";
76
+ export declare const DEFAULT_TEMPLATE_SRC = "github:NervJS/taro-project-templates#v3.5";
77
+ export declare const DEFAULT_TEMPLATE_SRC_GITEE = "direct:https://gitee.com/o2team/taro-project-templates.git#v3.5";
78
+ export declare const TARO_CONFIG_FLODER = ".taro3.5";
79
79
  export declare const TARO_BASE_CONFIG = "index.json";
80
80
  export declare const OUTPUT_DIR = "dist";
81
81
  export declare const SOURCE_DIR = "src";
package/types/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { processTypeEnum, IProcessTypeMap } from './constants';
6
6
  import * as utils from './utils';
7
7
  import * as npm from './npm';
8
8
  import createBabelRegister, { injectDefineConfigHeader } from './babelRegister';
9
+ import createSwcRegister from './swcRegister';
9
10
 
10
11
  export declare enum META_TYPE {
11
12
  ENTRY = 'ENTRY',
@@ -26,6 +27,7 @@ export declare enum FRAMEWORK_MAP {
26
27
 
27
28
  declare interface helper {
28
29
  npm: typeof npm;
30
+ createSwcRegister: typeof createSwcRegister;
29
31
  createBabelRegister: typeof createBabelRegister;
30
32
  injectDefineConfigHeader: typeof injectDefineConfigHeader;
31
33
  fs: typeof fs;
@@ -133,9 +135,9 @@ declare interface helper {
133
135
  taroJsMobxCommon: "@tarojs/mobx-common";
134
136
  DEVICE_RATIO_NAME: "deviceRatio";
135
137
  isWindows: boolean;
136
- DEFAULT_TEMPLATE_SRC: "github:NervJS/taro-project-templates#v3.1";
137
- DEFAULT_TEMPLATE_SRC_GITEE: "direct:https://gitee.com/o2team/taro-project-templates.git#v3.1";
138
- TARO_CONFIG_FLODER: ".taro3.1";
138
+ DEFAULT_TEMPLATE_SRC: "github:NervJS/taro-project-templates#v3.5";
139
+ DEFAULT_TEMPLATE_SRC_GITEE: "direct:https://gitee.com/o2team/taro-project-templates.git#v3.5";
140
+ TARO_CONFIG_FLODER: ".taro3.5";
139
141
  TARO_BASE_CONFIG: "index.json";
140
142
  OUTPUT_DIR: "dist";
141
143
  SOURCE_DIR: "src";
@@ -0,0 +1,3 @@
1
+ export default function createSwcRegister({ only }: {
2
+ only: any;
3
+ }): void;