From 7e464a310e784941f570161f1307c6f116885096 Mon Sep 17 00:00:00 2001 From: ycjcl868 <45808948@qq.com> Date: Thu, 5 Nov 2020 23:33:22 +0800 Subject: [PATCH] feat: upgrade history v5 --- packages/preset-built-in/package.json | 2 +- .../src/plugins/features/alias.ts | 2 +- packages/renderer-react/src/index.ts | 2 +- packages/runtime/package.json | 2 +- packages/runtime/src/index.ts | 4 +-- packages/types/index.d.ts | 2 +- yarn.lock | 34 +++++++++++-------- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/packages/preset-built-in/package.json b/packages/preset-built-in/package.json index cd97cdfb5f6b..55188456d4e5 100644 --- a/packages/preset-built-in/package.json +++ b/packages/preset-built-in/package.json @@ -40,7 +40,7 @@ "cliui": "6.0.0", "es5-imcompatible-versions": "^0.1.62", "fork-ts-checker-webpack-plugin": "5.0.12", - "history-with-query": "4.10.3", + "@umijs/history": "5.0.0-beta.1", "joi2types": "~1.0.7", "merge-stream": "2.0.0", "multer": "1.4.2", diff --git a/packages/preset-built-in/src/plugins/features/alias.ts b/packages/preset-built-in/src/plugins/features/alias.ts index ee483d2f8e7b..f9380c743c0a 100644 --- a/packages/preset-built-in/src/plugins/features/alias.ts +++ b/packages/preset-built-in/src/plugins/features/alias.ts @@ -18,7 +18,7 @@ export default (api: IApi) => { ), // 替换成带 query 的 history // 由于用了 query-string,会额外引入 7.6K(压缩后,gzip 前),考虑换轻量的实现 - history: dirname(require.resolve('history-with-query/package.json')), + history: dirname(require.resolve('@umijs/history/package.json')), }, }, }); diff --git a/packages/renderer-react/src/index.ts b/packages/renderer-react/src/index.ts index 14bd4eb3029a..d2e4ac1ac5d3 100644 --- a/packages/renderer-react/src/index.ts +++ b/packages/renderer-react/src/index.ts @@ -1,5 +1,5 @@ import { FunctionComponent } from 'react'; -import { History, Location } from 'history-with-query'; +import { History, Location } from '@umijs/history'; import { match } from 'react-router-dom'; export interface IComponent extends FunctionComponent { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 41b387ed87c5..b2e29d8b17d7 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -27,7 +27,7 @@ "dependencies": { "@types/react-router": "5.1.8", "@types/react-router-dom": "5.1.5", - "history-with-query": "4.10.3", + "@umijs/history": "5.0.0-beta.1", "react-router": "5.2.0", "react-router-dom": "5.2.0", "use-subscription": "1.4.1" diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.ts index 2963bb96bc02..3306c9f8bbe3 100644 --- a/packages/runtime/src/index.ts +++ b/packages/runtime/src/index.ts @@ -21,8 +21,8 @@ export { createBrowserHistory, createHashHistory, createMemoryHistory, -} from 'history-with-query'; -export type { MemoryHistory } from 'history-with-query'; +} from '@umijs/history'; +export type { MemoryHistory } from '@umijs/history'; export { default as Plugin, ApplyPluginsType } from './Plugin/Plugin'; export { default as dynamic } from './dynamic/dynamic'; diff --git a/packages/types/index.d.ts b/packages/types/index.d.ts index a6d1373776f0..02d436795d57 100644 --- a/packages/types/index.d.ts +++ b/packages/types/index.d.ts @@ -21,7 +21,7 @@ import webpack from 'webpack'; import WebpackChain from 'webpack-chain'; import { Express, NextFunction, RequestHandler } from 'express'; import { Request, Response } from 'express-serve-static-core'; -import { History, Location } from 'history-with-query'; +import { History, Location } from '@umijs/history'; export enum BundlerConfigType { csr = 'csr', diff --git a/yarn.lock b/yarn.lock index 43335739c0fa..aab374851e32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1830,6 +1830,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.7.6": + version "7.12.5" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e" + integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg== + dependencies: + regenerator-runtime "^0.13.4" + "@babel/template@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.10.4.tgz#3251996c4200ebc71d1a8fc405fba940f36ba278" @@ -3826,6 +3833,14 @@ stylelint-declaration-block-no-ignored-properties "^2.1.0" stylelint-order "^3.0.0" +"@umijs/history@5.0.0-beta.1": + version "5.0.0-beta.1" + resolved "https://registry.yarnpkg.com/@umijs/history/-/history-5.0.0-beta.1.tgz#82820802f558e56d7468ec7e4a3edcd4e332aee9" + integrity sha512-kNLvy+LJB7/AWAKMV5bACsRpIlPdpOckXlyWSPrTI07ytdIG+kbW/J25OgtFlgjvZunFOVXtkxYLYNoAsxyQ4g== + dependencies: + "@babel/runtime" "^7.7.6" + query-string "^6.13.6" + "@umijs/plugin-analytics@^0.2.2": version "0.2.2" resolved "https://registry.yarnpkg.com/@umijs/plugin-analytics/-/plugin-analytics-0.2.2.tgz#575fd231d4327ea13413217aa1b5fc6bdd89465e" @@ -8198,18 +8213,6 @@ hex-color-regex@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e" -history-with-query@4.10.3: - version "4.10.3" - resolved "https://registry.yarnpkg.com/history-with-query/-/history-with-query-4.10.3.tgz#9430a6f59a223796a68a436c0c4c7590233805a6" - dependencies: - "@babel/runtime" "^7.1.2" - loose-envify "^1.2.0" - query-string "^6.11.0" - resolve-pathname "^3.0.0" - tiny-invariant "^1.0.2" - tiny-warning "^1.0.0" - value-equal "^1.0.1" - history@^4.9.0: version "4.10.1" resolved "https://registry.yarnpkg.com/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3" @@ -12678,9 +12681,10 @@ query-string@^4.1.0: object-assign "^4.1.0" strict-uri-encode "^1.0.0" -query-string@^6.11.0: - version "6.12.0" - resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.12.0.tgz#fa0fe5b3ddf4d040d1236b80672949ab33d5cf80" +query-string@^6.13.6: + version "6.13.6" + resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.6.tgz#e5ac7c74f2a5da43fbca0b883b4f0bafba439966" + integrity sha512-/WWZ7d9na6s2wMEGdVCVgKWE9Rt7nYyNIf7k8xmHXcesPMlEzicWo3lbYwHyA4wBktI2KrXxxZeACLbE84hvSQ== dependencies: decode-uri-component "^0.2.0" split-on-first "^1.0.0"