umi 4.0.0-canary.20220628.2 → 4.0.0-canary.20220707.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/test.d.ts +1 -0
- package/dist/test.js +18 -6
- package/package.json +10 -10
package/dist/test.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Config } from '@umijs/test';
|
|
2
2
|
export * from '@umijs/test';
|
|
3
|
+
export declare function getAliasPathWithKey(alias: Record<string, string>, key: string): string;
|
|
3
4
|
export declare function getUmiAlias(): Promise<any>;
|
|
4
5
|
export declare function configUmiAlias(config: Config.InitialOptions): Promise<Partial<{
|
|
5
6
|
automock: boolean;
|
package/dist/test.js
CHANGED
|
@@ -14,17 +14,26 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.configUmiAlias = exports.getUmiAlias = void 0;
|
|
17
|
+
exports.configUmiAlias = exports.getUmiAlias = exports.getAliasPathWithKey = void 0;
|
|
18
18
|
const fs_1 = require("fs");
|
|
19
19
|
const service_1 = require("./service/service");
|
|
20
20
|
__exportStar(require("@umijs/test"), exports);
|
|
21
21
|
function getAliasPathWithKey(alias, key) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
if (alias[key]) {
|
|
23
|
+
return getAliasPathWithKey(alias, alias[key]);
|
|
24
|
+
}
|
|
25
|
+
const aliasKeys = Object.keys(alias);
|
|
26
|
+
const keyStartedWith = aliasKeys.find((k) => !k.endsWith('$') && key.startsWith(`${k}/`));
|
|
27
|
+
if (keyStartedWith) {
|
|
28
|
+
const realPath = alias[keyStartedWith];
|
|
29
|
+
const newKey = realPath + key.slice(keyStartedWith.length);
|
|
30
|
+
return getAliasPathWithKey(alias, newKey);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return key;
|
|
25
34
|
}
|
|
26
|
-
return thePath;
|
|
27
35
|
}
|
|
36
|
+
exports.getAliasPathWithKey = getAliasPathWithKey;
|
|
28
37
|
let service;
|
|
29
38
|
async function getUmiAlias() {
|
|
30
39
|
if (!service) {
|
|
@@ -42,7 +51,10 @@ async function configUmiAlias(config) {
|
|
|
42
51
|
const alias = await getUmiAlias();
|
|
43
52
|
for (const key of Object.keys(alias)) {
|
|
44
53
|
const aliasPath = getAliasPathWithKey(alias, key);
|
|
45
|
-
if (
|
|
54
|
+
if (key.endsWith('$')) {
|
|
55
|
+
config.moduleNameMapper[`^${key}`] = aliasPath;
|
|
56
|
+
}
|
|
57
|
+
else if ((0, fs_1.existsSync)(aliasPath) && (0, fs_1.statSync)(aliasPath).isDirectory()) {
|
|
46
58
|
config.moduleNameMapper[`^${key}/(.*)$`] = `${aliasPath}/$1`;
|
|
47
59
|
config.moduleNameMapper[`^${key}$`] = aliasPath;
|
|
48
60
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "umi",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20220707.1",
|
|
4
4
|
"description": "umi",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/umi#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -38,15 +38,15 @@
|
|
|
38
38
|
"test": "umi-scripts jest-turbo"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
42
|
-
"@umijs/bundler-webpack": "4.0.0-canary.
|
|
43
|
-
"@umijs/core": "4.0.0-canary.
|
|
44
|
-
"@umijs/lint": "4.0.0-canary.
|
|
45
|
-
"@umijs/preset-umi": "4.0.0-canary.
|
|
46
|
-
"@umijs/renderer-react": "4.0.0-canary.
|
|
47
|
-
"@umijs/server": "4.0.0-canary.
|
|
48
|
-
"@umijs/test": "4.0.0-canary.
|
|
49
|
-
"@umijs/utils": "4.0.0-canary.
|
|
41
|
+
"@umijs/bundler-utils": "4.0.0-canary.20220707.1",
|
|
42
|
+
"@umijs/bundler-webpack": "4.0.0-canary.20220707.1",
|
|
43
|
+
"@umijs/core": "4.0.0-canary.20220707.1",
|
|
44
|
+
"@umijs/lint": "4.0.0-canary.20220707.1",
|
|
45
|
+
"@umijs/preset-umi": "4.0.0-canary.20220707.1",
|
|
46
|
+
"@umijs/renderer-react": "4.0.0-canary.20220707.1",
|
|
47
|
+
"@umijs/server": "4.0.0-canary.20220707.1",
|
|
48
|
+
"@umijs/test": "4.0.0-canary.20220707.1",
|
|
49
|
+
"@umijs/utils": "4.0.0-canary.20220707.1",
|
|
50
50
|
"prettier-plugin-organize-imports": "^2.3.4",
|
|
51
51
|
"prettier-plugin-packagejson": "^2.2.17"
|
|
52
52
|
},
|