@umijs/renderer-react
Advanced tools
Comparing version 4.3.34 to 4.3.35
@@ -149,34 +149,11 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
var _opts$routes$id, _opts$routes$id2; | ||
// preload | ||
// @ts-ignore | ||
var manifest = window.__umi_manifest__; | ||
if (manifest) { | ||
var routeIdReplaced = id.replace(/[\/\-]/g, '_'); | ||
var preloadId = "preload-".concat(routeIdReplaced, ".js"); | ||
if (!document.getElementById(preloadId)) { | ||
var keys = Object.keys(manifest).filter(function (k) { | ||
return k.startsWith(routeIdReplaced + '.'); | ||
}); | ||
keys.forEach(function (key) { | ||
if (!/\.(js|css)$/.test(key)) { | ||
throw Error("preload not support ".concat(key, " file")); | ||
} | ||
var file = manifest[key]; | ||
var link = document.createElement('link'); | ||
link.rel = 'preload'; | ||
link.as = 'style'; | ||
if (key.endsWith('.js')) { | ||
link.as = 'script'; | ||
link.id = preloadId; | ||
} | ||
// publicPath already in the manifest, | ||
// but if runtimePublicPath is true, we need to replace it | ||
if (opts.runtimePublicPath) { | ||
file = file.replace(new RegExp("^".concat(opts.publicPath)), | ||
// @ts-ignore | ||
window.publicPath); | ||
} | ||
link.href = file; | ||
document.head.appendChild(link); | ||
}); | ||
// preload lazy component | ||
// window.__umi_manifest__ is available when routePrefetch and manifest config is enabled | ||
// __umi_manifest__ is not needed for preload, keep this is for compatibility and minimal change | ||
if (window.__umi_manifest__) { | ||
var _opts$routeComponents; | ||
// ref: https://github.com/facebook/react/blob/0940414/packages/react/src/ReactLazy.js#L135 | ||
var lazyCtor = (_opts$routeComponents = opts.routeComponents[id]) === null || _opts$routeComponents === void 0 || (_opts$routeComponents = _opts$routeComponents._payload) === null || _opts$routeComponents === void 0 ? void 0 : _opts$routeComponents._result; | ||
if (typeof lazyCtor == 'function') { | ||
lazyCtor(); | ||
} | ||
@@ -183,0 +160,0 @@ } |
@@ -104,4 +104,3 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; | ||
}, | ||
key: key, | ||
crossOrigin: "anonymous" | ||
key: key | ||
}, rest)); | ||
@@ -164,4 +163,3 @@ })); | ||
}, | ||
key: key, | ||
crossOrigin: "anonymous" | ||
key: key | ||
}, rest)); | ||
@@ -168,0 +166,0 @@ }))) |
@@ -5,2 +5,2 @@ import React, { PropsWithChildren } from 'react'; | ||
prefetch?: boolean; | ||
} & LinkProps & React.RefAttributes<HTMLAnchorElement>>): React.JSX.Element | null; | ||
} & LinkProps & React.RefAttributes<HTMLAnchorElement>>): JSX.Element | null; |
@@ -17,2 +17,2 @@ import React from 'react'; | ||
} | ||
export declare function withRouter<P extends RouteComponentProps<P>>(Component: React.ComponentType<P>): (props: P) => React.JSX.Element; | ||
export declare function withRouter<P extends RouteComponentProps<P>>(Component: React.ComponentType<P>): (props: P) => JSX.Element; |
{ | ||
"name": "@umijs/renderer-react", | ||
"version": "4.3.34", | ||
"version": "4.3.35", | ||
"description": "@umijs/renderer-react", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/umijs/umi/tree/master/packages/renderer-react#readme", |
46221
1087