@umijs/server 4.0.0-beta.9 → 4.0.0-rc.1

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/scripts.js CHANGED
@@ -13,7 +13,7 @@ const RE_URL = /^(http:|https:)?\/\//;
13
13
  function normalizeScript(script) {
14
14
  if (typeof script === 'string') {
15
15
  const isUrl = RE_URL.test(script) ||
16
- script.startsWith('/') ||
16
+ (script.startsWith('/') && !script.startsWith('/*')) ||
17
17
  script.startsWith('./') ||
18
18
  script.startsWith('../');
19
19
  return isUrl
package/dist/server.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { RequestHandler } from 'express';
2
- interface IOpts {
2
+ export interface IOpts {
3
+ base: string;
3
4
  routes: Record<string, {
4
5
  path: string;
5
6
  file: string;
@@ -12,6 +13,7 @@ interface IOpts {
12
13
  favicon?: string;
13
14
  headScripts?: (Record<string, string> | string)[];
14
15
  scripts?: (Record<string, string> | string)[];
16
+ mountElementId?: string;
15
17
  esmScript?: boolean;
16
18
  modifyHTML?: (html: string, args: {
17
19
  path?: string;
@@ -21,4 +23,3 @@ export declare function getMarkup(opts: Omit<IOpts, 'routes'> & {
21
23
  path?: string;
22
24
  }): Promise<string>;
23
25
  export declare function createRequestHandler(opts: IOpts): RequestHandler;
24
- export {};
package/dist/server.js CHANGED
@@ -22,7 +22,7 @@ const styles_1 = require("./styles");
22
22
  function getMarkup(opts) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
24
  // TODO: use real component
25
- let markup = server_1.default.renderToString(react_1.default.createElement('div', { id: 'root' }));
25
+ let markup = server_1.default.renderToString(react_1.default.createElement('div', { id: opts.mountElementId || 'root' }));
26
26
  function propsToString(opts) {
27
27
  return Object.keys(opts.props)
28
28
  .filter((key) => !(opts.filters || []).includes(key))
@@ -44,7 +44,7 @@ function getMarkup(opts) {
44
44
  filters: ['src', 'content'],
45
45
  });
46
46
  return style.src
47
- ? `<link rel="stylesheet" ${attrs} src="${style.src}" />`
47
+ ? `<link rel="stylesheet" ${attrs} href="${style.src}" />`
48
48
  : `<style ${attrs}>${style.content}</style>`;
49
49
  }
50
50
  function getTagContent(opts) {
@@ -99,7 +99,7 @@ function createRequestHandler(opts) {
99
99
  const routes = (0, routes_1.createServerRoutes)({
100
100
  routesById: opts.routes,
101
101
  });
102
- const matches = (0, react_router_dom_1.matchRoutes)(routes, req.path);
102
+ const matches = (0, react_router_dom_1.matchRoutes)(routes, req.path, opts.base);
103
103
  if (matches) {
104
104
  res.set('Content-Type', 'text/html');
105
105
  const markup = yield getMarkup(Object.assign(Object.assign({}, opts), { path: req.path }));
package/dist/styles.js CHANGED
@@ -13,7 +13,7 @@ const RE_URL = /^(http:|https:)?\/\//;
13
13
  function normalizeStyle(style) {
14
14
  if (typeof style === 'string') {
15
15
  const isUrl = RE_URL.test(style) ||
16
- style.startsWith('/') ||
16
+ (style.startsWith('/') && !style.startsWith('/*')) ||
17
17
  style.startsWith('./') ||
18
18
  style.startsWith('../');
19
19
  return isUrl
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/server",
3
- "version": "4.0.0-beta.9",
3
+ "version": "4.0.0-rc.1",
4
4
  "description": "@umijs/server",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/server#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -20,10 +20,10 @@
20
20
  "dev": "pnpm build -- --watch"
21
21
  },
22
22
  "dependencies": {
23
- "history": "5.0.1",
24
- "react": "18.0.0-alpha-4298ddbc5-20211023",
25
- "react-dom": "18.0.0-alpha-4298ddbc5-20211023",
26
- "react-router-dom": "6.0.0-beta.8"
23
+ "history": "5.1.0",
24
+ "react": "18.0.0-rc.0",
25
+ "react-dom": "18.0.0-rc.0",
26
+ "react-router-dom": "6.1.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/express": "4.17.13"