@umijs/renderer-react 4.3.34 → 4.3.36

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/browser.js CHANGED
@@ -146,38 +146,14 @@ var getBrowser = function getBrowser(opts, routesElement) {
146
146
  })) || []).filter(Boolean);
147
147
  matchedRouteIds.forEach(function (id) {
148
148
  var _opts$routes$id, _opts$routes$id2;
149
- // preload
150
- // @ts-ignore
151
- var manifest = window.__umi_manifest__;
152
- if (manifest) {
153
- var routeIdReplaced = id.replace(/[\/\-]/g, '_');
154
- var preloadId = "preload-".concat(routeIdReplaced, ".js");
155
- if (!document.getElementById(preloadId)) {
156
- var keys = Object.keys(manifest).filter(function (k) {
157
- return k.startsWith(routeIdReplaced + '.');
158
- });
159
- keys.forEach(function (key) {
160
- if (!/\.(js|css)$/.test(key)) {
161
- throw Error("preload not support ".concat(key, " file"));
162
- }
163
- var file = manifest[key];
164
- var link = document.createElement('link');
165
- link.rel = 'preload';
166
- link.as = 'style';
167
- if (key.endsWith('.js')) {
168
- link.as = 'script';
169
- link.id = preloadId;
170
- }
171
- // publicPath already in the manifest,
172
- // but if runtimePublicPath is true, we need to replace it
173
- if (opts.runtimePublicPath) {
174
- file = file.replace(new RegExp("^".concat(opts.publicPath)),
175
- // @ts-ignore
176
- window.publicPath);
177
- }
178
- link.href = file;
179
- document.head.appendChild(link);
180
- });
149
+ // preload lazy component
150
+ // window.__umi_route_prefetch__ is available when routePrefetch and manifest config is enabled
151
+ if (window.__umi_route_prefetch__) {
152
+ var _opts$routeComponents;
153
+ // ref: https://github.com/facebook/react/blob/0940414/packages/react/src/ReactLazy.js#L135
154
+ 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;
155
+ if (typeof lazyCtor == 'function') {
156
+ lazyCtor();
181
157
  }
182
158
  }
183
159
  var clientLoader = (_opts$routes$id = opts.routes[id]) === null || _opts$routes$id === void 0 ? void 0 : _opts$routes$id.clientLoader;
package/dist/html.js CHANGED
@@ -101,8 +101,7 @@ var HydrateMetadata = function HydrateMetadata(props) {
101
101
  dangerouslySetInnerHTML: {
102
102
  __html: content
103
103
  },
104
- key: key,
105
- crossOrigin: "anonymous"
104
+ key: key
106
105
  }, rest));
107
106
  }));
108
107
  };
@@ -160,8 +159,7 @@ export function Html(_ref) {
160
159
  dangerouslySetInnerHTML: {
161
160
  __html: content
162
161
  },
163
- key: key,
164
- crossOrigin: "anonymous"
162
+ key: key
165
163
  }, rest));
166
164
  })))
167
165
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/renderer-react",
3
- "version": "4.3.34",
3
+ "version": "4.3.36",
4
4
  "description": "@umijs/renderer-react",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/renderer-react#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",