@tarojs/helper 2.2.17 → 2.2.19
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/utils.js +8 -4
- package/package.json +3 -3
- package/src/utils.ts +8 -4
- package/types/index.d.ts +2 -2
- package/types/utils.d.ts +2 -2
package/dist/utils.js
CHANGED
|
@@ -46,14 +46,14 @@ function isAliasPath(name, pathAlias = {}) {
|
|
|
46
46
|
return prefixs.includes(name) || (new RegExp(`^(${prefixs.join('|')})/`).test(name));
|
|
47
47
|
}
|
|
48
48
|
exports.isAliasPath = isAliasPath;
|
|
49
|
-
function replaceAliasPath(filePath, name, pathAlias = {}) {
|
|
49
|
+
function replaceAliasPath(filePath, name, pathAlias = {}, env) {
|
|
50
50
|
// 后续的 path.join 在遇到符号链接时将会解析为真实路径,如果
|
|
51
51
|
// 这里的 filePath 没有做同样的处理,可能会导致 import 指向
|
|
52
52
|
// 源代码文件,导致文件被意外修改
|
|
53
53
|
filePath = fs.realpathSync(filePath);
|
|
54
54
|
const prefixs = Object.keys(pathAlias);
|
|
55
55
|
if (prefixs.includes(name)) {
|
|
56
|
-
return promoteRelativePath(path.relative(filePath, fs.realpathSync(resolveScriptPath(pathAlias[name]))));
|
|
56
|
+
return promoteRelativePath(path.relative(filePath, fs.realpathSync(resolveScriptPath(pathAlias[name], env))));
|
|
57
57
|
}
|
|
58
58
|
const reg = new RegExp(`^(${prefixs.join('|')})/(.*)`);
|
|
59
59
|
name = name.replace(reg, function (m, $1, $2) {
|
|
@@ -207,9 +207,13 @@ function isEmptyObject(obj) {
|
|
|
207
207
|
return true;
|
|
208
208
|
}
|
|
209
209
|
exports.isEmptyObject = isEmptyObject;
|
|
210
|
-
function resolveScriptPath(p) {
|
|
210
|
+
function resolveScriptPath(p, env) {
|
|
211
211
|
const realPath = p;
|
|
212
|
-
|
|
212
|
+
let taroEnv = env || process.env.TARO_ENV || '';
|
|
213
|
+
// Note: H5 在拷贝文件时做了处理,不需要额外的转换
|
|
214
|
+
if (['h5'].includes(taroEnv)) {
|
|
215
|
+
taroEnv = '';
|
|
216
|
+
}
|
|
213
217
|
const SCRIPT_EXT = constants_1.JS_EXT.concat(constants_1.TS_EXT);
|
|
214
218
|
for (let i = 0; i < SCRIPT_EXT.length; i++) {
|
|
215
219
|
const item = SCRIPT_EXT[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/helper",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.19",
|
|
4
4
|
"description": "Taro Helper",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@babel/preset-typescript": "7.9.0",
|
|
45
45
|
"@babel/register": "7.9.0",
|
|
46
46
|
"@babel/runtime": "7.9.2",
|
|
47
|
-
"@tarojs/taro": "2.2.
|
|
47
|
+
"@tarojs/taro": "2.2.19",
|
|
48
48
|
"babel-plugin-transform-react-jsx": "^6.24.1",
|
|
49
49
|
"chalk": "3.0.0",
|
|
50
50
|
"chokidar": "3.3.1",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"ts-jest": "25.2.1",
|
|
65
65
|
"typescript": "^3.4.5"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "64d57843cb01f25d9dc738ad26765e7c52cae8e6"
|
|
68
68
|
}
|
package/src/utils.ts
CHANGED
|
@@ -49,7 +49,7 @@ export function isAliasPath (name: string, pathAlias: object = {}): boolean {
|
|
|
49
49
|
return prefixs.includes(name) || (new RegExp(`^(${prefixs.join('|')})/`).test(name))
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export function replaceAliasPath (filePath: string, name: string, pathAlias: object = {}) {
|
|
52
|
+
export function replaceAliasPath (filePath: string, name: string, pathAlias: object = {}, env?: string) {
|
|
53
53
|
// 后续的 path.join 在遇到符号链接时将会解析为真实路径,如果
|
|
54
54
|
// 这里的 filePath 没有做同样的处理,可能会导致 import 指向
|
|
55
55
|
// 源代码文件,导致文件被意外修改
|
|
@@ -57,7 +57,7 @@ export function replaceAliasPath (filePath: string, name: string, pathAlias: obj
|
|
|
57
57
|
|
|
58
58
|
const prefixs = Object.keys(pathAlias)
|
|
59
59
|
if (prefixs.includes(name)) {
|
|
60
|
-
return promoteRelativePath(path.relative(filePath, fs.realpathSync(resolveScriptPath(pathAlias[name]))))
|
|
60
|
+
return promoteRelativePath(path.relative(filePath, fs.realpathSync(resolveScriptPath(pathAlias[name], env))))
|
|
61
61
|
}
|
|
62
62
|
const reg = new RegExp(`^(${prefixs.join('|')})/(.*)`)
|
|
63
63
|
name = name.replace(reg, function (m, $1, $2) {
|
|
@@ -212,9 +212,13 @@ export function isEmptyObject (obj: any): boolean {
|
|
|
212
212
|
return true
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
export function resolveScriptPath (p: string): string {
|
|
215
|
+
export function resolveScriptPath (p: string, env?: string): string {
|
|
216
216
|
const realPath = p
|
|
217
|
-
|
|
217
|
+
let taroEnv = env || process.env.TARO_ENV || ''
|
|
218
|
+
// Note: H5 在拷贝文件时做了处理,不需要额外的转换
|
|
219
|
+
if (['h5'].includes(taroEnv)) {
|
|
220
|
+
taroEnv = ''
|
|
221
|
+
}
|
|
218
222
|
const SCRIPT_EXT = JS_EXT.concat(TS_EXT)
|
|
219
223
|
for (let i = 0; i < SCRIPT_EXT.length; i++) {
|
|
220
224
|
const item = SCRIPT_EXT[i]
|
package/types/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ declare interface helper {
|
|
|
29
29
|
isNpmPkg(name: string): boolean;
|
|
30
30
|
isQuickAppPkg(name: string): boolean;
|
|
31
31
|
isAliasPath(name: string, pathAlias?: object): boolean;
|
|
32
|
-
replaceAliasPath(filePath: string, name: string, pathAlias?: object): string;
|
|
32
|
+
replaceAliasPath(filePath: string, name: string, pathAlias?: object, env?: string): string;
|
|
33
33
|
promoteRelativePath(fPath: string): string;
|
|
34
34
|
resolveStylePath(p: string): string;
|
|
35
35
|
printLog(type: processTypeEnum, tag: string, filePath?: string | undefined): void;
|
|
@@ -41,7 +41,7 @@ declare interface helper {
|
|
|
41
41
|
shouldUseYarn(): boolean;
|
|
42
42
|
shouldUseCnpm(): boolean;
|
|
43
43
|
isEmptyObject(obj: any): boolean;
|
|
44
|
-
resolveScriptPath(p: string): string;
|
|
44
|
+
resolveScriptPath(p: string, env?: string): string;
|
|
45
45
|
generateEnvList(env: object): object;
|
|
46
46
|
generateConstantsList(constants: object): object;
|
|
47
47
|
cssImports(content: string): string[];
|
package/types/utils.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const isNodeModule: (filename: string) => boolean;
|
|
|
4
4
|
export declare function isNpmPkg(name: string): boolean;
|
|
5
5
|
export declare function isQuickAppPkg(name: string): boolean;
|
|
6
6
|
export declare function isAliasPath(name: string, pathAlias?: object): boolean;
|
|
7
|
-
export declare function replaceAliasPath(filePath: string, name: string, pathAlias?: object): string;
|
|
7
|
+
export declare function replaceAliasPath(filePath: string, name: string, pathAlias?: object, env?: string): string;
|
|
8
8
|
export declare function promoteRelativePath(fPath: string): string;
|
|
9
9
|
export declare function resolveStylePath(p: string): string;
|
|
10
10
|
export declare function printLog(type: processTypeEnum, tag: string, filePath?: string): void;
|
|
@@ -16,7 +16,7 @@ export declare function getSystemUsername(): string;
|
|
|
16
16
|
export declare function shouldUseYarn(): boolean;
|
|
17
17
|
export declare function shouldUseCnpm(): boolean;
|
|
18
18
|
export declare function isEmptyObject(obj: any): boolean;
|
|
19
|
-
export declare function resolveScriptPath(p: string): string;
|
|
19
|
+
export declare function resolveScriptPath(p: string, env?: string): string;
|
|
20
20
|
export declare function generateEnvList(env: object): object;
|
|
21
21
|
export declare function generateConstantsList(constants: object): object;
|
|
22
22
|
export declare function cssImports(content: string): string[];
|