@umijs/preset-umi 4.0.39 → 4.0.41
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.
|
@@ -54,7 +54,8 @@ var jest_default = (api) => {
|
|
|
54
54
|
jest: "^27",
|
|
55
55
|
"@types/jest": "^27",
|
|
56
56
|
typescript: "^4",
|
|
57
|
-
"ts-node": "^10"
|
|
57
|
+
"ts-node": "^10",
|
|
58
|
+
"cross-env": "^7"
|
|
58
59
|
};
|
|
59
60
|
const packageToInstall = res.willUseTLR ? {
|
|
60
61
|
...basicDeps,
|
|
@@ -63,7 +64,7 @@ var jest_default = (api) => {
|
|
|
63
64
|
"@types/testing-library__jest-dom": "^5.14.5"
|
|
64
65
|
} : basicDeps;
|
|
65
66
|
h.addDevDeps(packageToInstall);
|
|
66
|
-
h.addScript("test", "TS_NODE_TRANSPILE_ONLY=yes jest --passWithNoTests");
|
|
67
|
+
h.addScript("test", "cross-env TS_NODE_TRANSPILE_ONLY=yes jest --passWithNoTests");
|
|
67
68
|
const setupImports = res.willUseTLR ? [
|
|
68
69
|
`import '@testing-library/jest-dom';`,
|
|
69
70
|
`import '${api.appData.umi.importSource}/test-setup'`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.41",
|
|
4
4
|
"description": "@umijs/preset-umi",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/preset-umi#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"test": "umi-scripts jest-turbo"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@umijs/ast": "4.0.
|
|
29
|
-
"@umijs/babel-preset-umi": "4.0.
|
|
30
|
-
"@umijs/bundler-utils": "4.0.
|
|
31
|
-
"@umijs/bundler-vite": "4.0.
|
|
32
|
-
"@umijs/bundler-webpack": "4.0.
|
|
33
|
-
"@umijs/core": "4.0.
|
|
28
|
+
"@umijs/ast": "4.0.41",
|
|
29
|
+
"@umijs/babel-preset-umi": "4.0.41",
|
|
30
|
+
"@umijs/bundler-utils": "4.0.41",
|
|
31
|
+
"@umijs/bundler-vite": "4.0.41",
|
|
32
|
+
"@umijs/bundler-webpack": "4.0.41",
|
|
33
|
+
"@umijs/core": "4.0.41",
|
|
34
34
|
"@umijs/did-you-know": "^1.0.0",
|
|
35
35
|
"@umijs/history": "5.3.1",
|
|
36
|
-
"@umijs/mfsu": "4.0.
|
|
37
|
-
"@umijs/plugin-run": "4.0.
|
|
38
|
-
"@umijs/renderer-react": "4.0.
|
|
39
|
-
"@umijs/server": "4.0.
|
|
40
|
-
"@umijs/utils": "4.0.
|
|
36
|
+
"@umijs/mfsu": "4.0.41",
|
|
37
|
+
"@umijs/plugin-run": "4.0.41",
|
|
38
|
+
"@umijs/renderer-react": "4.0.41",
|
|
39
|
+
"@umijs/server": "4.0.41",
|
|
40
|
+
"@umijs/utils": "4.0.41",
|
|
41
41
|
"babel-plugin-dynamic-import-node": "2.3.3",
|
|
42
42
|
"click-to-react-component": "^1.0.8",
|
|
43
43
|
"core-js": "3.22.4",
|
package/templates/history.tpl
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
1
|
import { createHashHistory, createMemoryHistory, createBrowserHistory, History } from '{{{ historyPath }}}';
|
|
3
2
|
|
|
4
3
|
let history: History;
|
|
@@ -19,10 +18,10 @@ export function createHistory(opts: any) {
|
|
|
19
18
|
history = {
|
|
20
19
|
...h,
|
|
21
20
|
push(to, state) {
|
|
22
|
-
h.push(patchTo(to, h
|
|
21
|
+
h.push(patchTo(to, h), state);
|
|
23
22
|
},
|
|
24
23
|
replace(to, state) {
|
|
25
|
-
h.replace(patchTo(to, h
|
|
24
|
+
h.replace(patchTo(to, h), state);
|
|
26
25
|
},
|
|
27
26
|
get location() {
|
|
28
27
|
return h.location;
|
|
@@ -39,20 +38,16 @@ export function createHistory(opts: any) {
|
|
|
39
38
|
// Refs:
|
|
40
39
|
// https://github.com/remix-run/history/blob/3e9dab4/packages/history/index.ts#L484
|
|
41
40
|
// https://github.com/remix-run/history/blob/dev/docs/api-reference.md#to
|
|
42
|
-
function patchTo(to: any, h: History
|
|
41
|
+
function patchTo(to: any, h: History) {
|
|
43
42
|
if (typeof to === 'string') {
|
|
44
|
-
|
|
45
|
-
return `${stripLastSlash(basename)}${to}`;
|
|
46
|
-
} else {
|
|
47
|
-
return `${stripLastSlash(basename)}${resolvePath(to, h, basename)}`;
|
|
48
|
-
}
|
|
43
|
+
return `${stripLastSlash(basename)}${to}`;
|
|
49
44
|
} else if (typeof to === 'object') {
|
|
50
45
|
|
|
51
46
|
const currentPathname = h.location.pathname;
|
|
52
47
|
|
|
53
48
|
return {
|
|
54
49
|
...to,
|
|
55
|
-
pathname: to.pathname
|
|
50
|
+
pathname: to.pathname? `${stripLastSlash(basename)}${to.pathname}` : currentPathname,
|
|
56
51
|
};
|
|
57
52
|
} else {
|
|
58
53
|
throw new Error(`Unexpected to: ${to}`);
|
|
@@ -62,87 +57,5 @@ function patchTo(to: any, h: History, basename: string) {
|
|
|
62
57
|
function stripLastSlash(path) {
|
|
63
58
|
return path.slice(-1) === '/' ? path.slice(0, -1) : path;
|
|
64
59
|
}
|
|
65
|
-
function resolvePath(pathname: string, h: History, basename:string ){
|
|
66
|
-
let fromPath= h.location.pathname
|
|
67
|
-
|
|
68
|
-
if(basename ==='/' || basename ===''){
|
|
69
|
-
}else{
|
|
70
|
-
fromPath = fromPath.replace(new RegExp(`^${stripLastSlash(basename)}`), '') || '/'
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return resolvePathname(pathname, fromPath)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function isAbsolute(pathname:string): boolean {
|
|
77
|
-
return pathname.charAt(0) === '/';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// About 1.5x faster than the two-arg version of Array#splice()
|
|
81
|
-
function spliceOne(list: any[], index:number) {
|
|
82
|
-
for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
|
|
83
|
-
list[i] = list[k];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
list.pop();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function resolvePathname(to: string, from :string = ''): string {
|
|
90
|
-
|
|
91
|
-
const toParts = (to && to.split('/')) || [];
|
|
92
|
-
let fromParts = (from && from.split('/')) || [];
|
|
93
|
-
|
|
94
|
-
const isToAbs = to && isAbsolute(to);
|
|
95
|
-
const isFromAbs = from && isAbsolute(from);
|
|
96
|
-
const mustEndAbs = isToAbs || isFromAbs;
|
|
97
|
-
|
|
98
|
-
if (to && isAbsolute(to)) {
|
|
99
|
-
// to is absolute
|
|
100
|
-
fromParts = toParts;
|
|
101
|
-
} else if (toParts.length) {
|
|
102
|
-
// to is relative, drop the filename
|
|
103
|
-
fromParts.pop();
|
|
104
|
-
fromParts = fromParts.concat(toParts);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (!fromParts.length) return '/';
|
|
108
|
-
|
|
109
|
-
let hasTrailingSlash;
|
|
110
|
-
if (fromParts.length) {
|
|
111
|
-
const last = fromParts[fromParts.length - 1];
|
|
112
|
-
hasTrailingSlash = last === '.' || last === '..' || last === '';
|
|
113
|
-
} else {
|
|
114
|
-
hasTrailingSlash = false;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
let up = 0;
|
|
118
|
-
for (let i = fromParts.length; i >= 0; i--) {
|
|
119
|
-
const part = fromParts[i];
|
|
120
|
-
|
|
121
|
-
if (part === '.') {
|
|
122
|
-
spliceOne(fromParts, i);
|
|
123
|
-
} else if (part === '..') {
|
|
124
|
-
spliceOne(fromParts, i);
|
|
125
|
-
up++;
|
|
126
|
-
} else if (up) {
|
|
127
|
-
spliceOne(fromParts, i);
|
|
128
|
-
up--;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (!mustEndAbs) for (; up--; up) fromParts.unshift('..');
|
|
133
|
-
|
|
134
|
-
if (
|
|
135
|
-
mustEndAbs &&
|
|
136
|
-
fromParts[0] !== '' &&
|
|
137
|
-
(!fromParts[0] || !isAbsolute(fromParts[0]))
|
|
138
|
-
)
|
|
139
|
-
fromParts.unshift('');
|
|
140
|
-
|
|
141
|
-
let result = fromParts.join('/');
|
|
142
|
-
|
|
143
|
-
if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
|
|
144
|
-
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
60
|
|
|
148
61
|
export { history };
|