@umijs/server 4.3.18 → 4.3.19

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/ssr.d.ts CHANGED
@@ -32,6 +32,7 @@ interface CreateRequestHandlerOptions extends CreateRequestServerlessOptions {
32
32
  pureHtml: boolean;
33
33
  };
34
34
  mountElementId: string;
35
+ basename?: string;
35
36
  }
36
37
  export declare function createMarkupGenerator(opts: CreateRequestHandlerOptions): (url: string) => Promise<unknown>;
37
38
  declare type IExpressRequestHandlerArgs = Parameters<RequestHandler>;
package/dist/ssr.js CHANGED
@@ -72,7 +72,8 @@ function createJSXGenerator(opts) {
72
72
  pluginManager,
73
73
  getRoutes,
74
74
  createHistory,
75
- sourceDir
75
+ sourceDir,
76
+ basename
76
77
  } = opts;
77
78
  createHistory({ type: "memory", initialEntries: [url], initialIndex: 1 });
78
79
  const { routes, routeComponents } = await getRoutes(pluginManager);
@@ -84,7 +85,7 @@ function createJSXGenerator(opts) {
84
85
  routeComponents
85
86
  }
86
87
  });
87
- const matches = matchRoutesForSSR(url, routes);
88
+ const matches = matchRoutesForSSR(url, routes, basename);
88
89
  if (matches.length === 0) {
89
90
  return;
90
91
  }
@@ -126,7 +127,8 @@ function createJSXGenerator(opts) {
126
127
  loaderData,
127
128
  htmlPageOpts: opts.htmlPageOpts,
128
129
  __INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: opts.__INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
129
- mountElementId: opts.mountElementId
130
+ mountElementId: opts.mountElementId,
131
+ basename
130
132
  };
131
133
  const element = await opts.getClientRootComponent(
132
134
  context
@@ -453,9 +455,10 @@ function createAppRootElement(opts) {
453
455
  return () => jsx == null ? void 0 : jsx.element;
454
456
  };
455
457
  }
456
- function matchRoutesForSSR(reqUrl, routesById) {
458
+ function matchRoutesForSSR(reqUrl, routesById, basename) {
457
459
  var _a;
458
- return ((_a = (0, import_react_router_dom.matchRoutes)(createClientRoutes({ routesById }), reqUrl)) == null ? void 0 : _a.map(
460
+ const _basename = (basename == null ? void 0 : basename.endsWith("/")) ? basename.slice(0, -1) : basename;
461
+ return ((_a = (0, import_react_router_dom.matchRoutes)(createClientRoutes({ routesById }), reqUrl, _basename)) == null ? void 0 : _a.map(
459
462
  (route) => route.route.id
460
463
  )) || [];
461
464
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/server",
3
- "version": "4.3.18",
3
+ "version": "4.3.19",
4
4
  "description": "@umijs/server",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/server#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -19,7 +19,7 @@
19
19
  "react": "18.3.1",
20
20
  "react-dom": "18.3.1",
21
21
  "react-router-dom": "6.3.0",
22
- "@umijs/bundler-utils": "4.3.18"
22
+ "@umijs/bundler-utils": "4.3.19"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"