@shuvi/platform-web 1.0.38 → 1.0.39

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.
@@ -37,6 +37,7 @@ function prefetchViaDom(href, id, as) {
37
37
  return new Promise((res, rej) => {
38
38
  const selector = `
39
39
  link[rel="prefetch"][href^="${href}"],
40
+ link[rel="preload"][href^="${href}"],
40
41
  script[src^="${href}"]`;
41
42
  if (document.querySelector(selector)) {
42
43
  return res();
@@ -10,9 +10,13 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  }
11
11
  return t;
12
12
  };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
13
16
  Object.defineProperty(exports, "__esModule", { value: true });
14
17
  exports.generateRoutesContent = exports.normalizeRoutes = exports.serializeRoutes = void 0;
15
18
  const crypto_1 = require("crypto");
19
+ const path_1 = __importDefault(require("path"));
16
20
  const constants_1 = require("@shuvi/shared/constants");
17
21
  const file_1 = require("@shuvi/utils/file");
18
22
  const paths_1 = require("../../../paths");
@@ -43,9 +47,11 @@ function serializeRoutes(routes, { includeMeta, useEmptyComponent }) {
43
47
  if (useEmptyComponent) {
44
48
  componentRequest = EmptyComponnetPath;
45
49
  }
50
+ const fileExtension = path_1.default.extname(component);
51
+ const fileName = path_1.default.basename(component, fileExtension);
46
52
  strRoute += `
47
53
  __import__: () => import(
48
- /* webpackChunkName: "page-${id}" */
54
+ /* webpackChunkName: "${fileName}-${id}" */
49
55
  /* webpackExports: "default" */
50
56
  "${componentRequest}"),
51
57
  __resolveWeak__: () => [require.resolveWeak("${componentRequest}")]`.trim();
@@ -2,12 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  function generateFilesByRoutId(assetMap, routes) {
4
4
  let filesByRoutId = {};
5
- const loadable = assetMap.loadble;
6
- routes.forEach(({ id, __componentRawRequest__ }) => {
7
- if (__componentRawRequest__ && loadable[__componentRawRequest__]) {
8
- filesByRoutId[id] = loadable[__componentRawRequest__].files;
5
+ const processRoute = (route) => {
6
+ const { id, __componentRawRequest__, children } = route;
7
+ // Process the current route
8
+ if (__componentRawRequest__ && assetMap.loadble[__componentRawRequest__]) {
9
+ filesByRoutId[id] = assetMap.loadble[__componentRawRequest__].files;
9
10
  }
10
- });
11
+ // Recursively process children
12
+ if (children) {
13
+ children.forEach(processRoute);
14
+ }
15
+ };
16
+ routes.forEach(processRoute);
11
17
  return filesByRoutId;
12
18
  }
13
19
  exports.default = generateFilesByRoutId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/platform-web",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -72,15 +72,15 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@next/react-refresh-utils": "12.1.6",
75
- "@shuvi/error-overlay": "1.0.38",
76
- "@shuvi/hook": "1.0.38",
77
- "@shuvi/platform-shared": "1.0.38",
78
- "@shuvi/router": "1.0.38",
79
- "@shuvi/router-react": "1.0.38",
80
- "@shuvi/runtime": "1.0.38",
81
- "@shuvi/shared": "1.0.38",
82
- "@shuvi/toolpack": "1.0.38",
83
- "@shuvi/utils": "1.0.38",
75
+ "@shuvi/error-overlay": "1.0.39",
76
+ "@shuvi/hook": "1.0.39",
77
+ "@shuvi/platform-shared": "1.0.39",
78
+ "@shuvi/router": "1.0.39",
79
+ "@shuvi/router-react": "1.0.39",
80
+ "@shuvi/runtime": "1.0.39",
81
+ "@shuvi/shared": "1.0.39",
82
+ "@shuvi/toolpack": "1.0.39",
83
+ "@shuvi/utils": "1.0.39",
84
84
  "content-type": "1.0.4",
85
85
  "core-js": "3.6.5",
86
86
  "doura": "0.0.13",
@@ -98,7 +98,7 @@
98
98
  "whatwg-fetch": "3.0.0"
99
99
  },
100
100
  "peerDependencies": {
101
- "@shuvi/service": "1.0.38"
101
+ "@shuvi/service": "1.0.39"
102
102
  },
103
103
  "devDependencies": {
104
104
  "@shuvi/service": "workspace:*",