@tarojs/helper 3.4.6 → 3.5.0-alpha.1
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 +3 -3
- package/dist/index.js +2 -0
- package/dist/swcRegister.js +38 -0
- package/dist/utils.js +4 -3
- package/package.json +5 -3
- package/types/constants.d.ts +3 -3
- package/types/index.d.ts +5 -3
- package/types/swcRegister.d.ts +3 -0
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.
|
|
172
|
-
exports.DEFAULT_TEMPLATE_SRC_GITEE = 'direct:https://gitee.com/o2team/taro-project-templates.git#v3.
|
|
173
|
-
exports.TARO_CONFIG_FLODER = '.taro3.
|
|
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
|
|
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, '/');
|
|
@@ -615,11 +615,12 @@ 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
|
-
|
|
618
|
+
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];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/helper",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0-alpha.1",
|
|
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
|
-
"@
|
|
43
|
+
"@swc/core": "^1.2.147",
|
|
44
|
+
"@swc/register": "^0.1.10",
|
|
45
|
+
"@tarojs/taro": "3.5.0-alpha.1",
|
|
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": "
|
|
56
|
+
"gitHead": "3bd136d26d77b847a1a18e028d5b0d048c89f288"
|
|
55
57
|
}
|
package/types/constants.d.ts
CHANGED
|
@@ -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.
|
|
77
|
-
export declare const DEFAULT_TEMPLATE_SRC_GITEE = "direct:https://gitee.com/o2team/taro-project-templates.git#v3.
|
|
78
|
-
export declare const TARO_CONFIG_FLODER = ".taro3.
|
|
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.
|
|
137
|
-
DEFAULT_TEMPLATE_SRC_GITEE: "direct:https://gitee.com/o2team/taro-project-templates.git#v3.
|
|
138
|
-
TARO_CONFIG_FLODER: ".taro3.
|
|
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";
|