@modern-js/runtime 2.49.2 → 2.49.3

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.
@@ -55,7 +55,16 @@ function modifyRoutes(modifyFunction) {
55
55
  console.error("It is not allowed to modify routes config after create router.");
56
56
  }
57
57
  }
58
- const routerPlugin = ({ serverBase = [], supportHtml5History = true, basename = "", routesConfig, createRoutes }) => {
58
+ const routerPlugin = ({
59
+ serverBase = [],
60
+ supportHtml5History = true,
61
+ basename = "",
62
+ // when the current child app has multiple entries, there is a problem,
63
+ // so we have added a new parameter, the parameter will replace basename and baseUrl after the major version.
64
+ originalBaseUrl = "",
65
+ routesConfig,
66
+ createRoutes
67
+ }) => {
59
68
  const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
60
69
  let routes = [];
61
70
  finalRouteConfig = routesConfig;
@@ -91,7 +100,7 @@ const routerPlugin = ({ serverBase = [], supportHtml5History = true, basename =
91
100
  const getRouteApp = () => {
92
101
  const useCreateRouter = (props) => {
93
102
  var _window__SERVER_DATA;
94
- const baseUrl = ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname);
103
+ const baseUrl = originalBaseUrl || ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname);
95
104
  const _basename = baseUrl === "/" ? (0, import_utils.urlJoin)(baseUrl, basename) : baseUrl;
96
105
  let hydrationData = window._ROUTER_DATA;
97
106
  const runtimeContext = (0, import_react.useContext)(import_core.RuntimeReactContext);
@@ -71,7 +71,7 @@ function createFetchHeaders(requestHeaders) {
71
71
  }
72
72
  return headers;
73
73
  }
74
- const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
74
+ const routerPlugin = ({ basename = "", originalBaseUrl = "", routesConfig, createRoutes }) => {
75
75
  return {
76
76
  name: "@modern-js/plugin-router",
77
77
  registerHook: {
@@ -86,7 +86,7 @@ const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
86
86
  });
87
87
  }
88
88
  const { request, mode: ssrMode, nonce } = context.ssrContext;
89
- const baseUrl = request.baseUrl;
89
+ const baseUrl = originalBaseUrl || request.baseUrl;
90
90
  const _basename = baseUrl === "/" ? (0, import_utils.urlJoin)(baseUrl, basename) : baseUrl;
91
91
  const { reporter, serverTiming } = context.ssrContext;
92
92
  const requestContext = (0, import_node.createRequestContext)();
@@ -54,23 +54,19 @@ const checkIsInline = (chunk, enableInline) => {
54
54
  return false;
55
55
  }
56
56
  };
57
- function getHeadTemplate(beforeEntryTemplate, context, pluginConfig) {
57
+ async function buildShellBeforeTemplate(beforeAppTemplate, context, pluginConfig) {
58
58
  const helmetData = import_react_helmet.default.renderStatic();
59
59
  const callbacks = [
60
- (headTemplate2) => {
61
- return helmetData ? (0, import_helmet.default)(headTemplate2, helmetData) : headTemplate2;
60
+ (headTemplate) => {
61
+ return helmetData ? (0, import_helmet.default)(headTemplate, helmetData) : headTemplate;
62
62
  },
63
63
  // @TODO: prefetch scripts of lazy component
64
64
  injectCss
65
65
  ];
66
- const [headTemplate = ""] = beforeEntryTemplate.match(import_buildTemplate.HEAD_REG_EXP) || [];
67
- if (!headTemplate.length) {
68
- return "";
69
- }
70
- return (0, import_buildTemplate.buildTemplate)(headTemplate, callbacks);
71
- async function injectCss(headTemplate2) {
66
+ return (0, import_buildTemplate.buildTemplate)(beforeAppTemplate, callbacks);
67
+ async function injectCss(template) {
72
68
  const css = await getCssChunks();
73
- return (0, import_utils.safeReplace)(headTemplate2, import_constants.CHUNK_CSS_PLACEHOLDER, css);
69
+ return (0, import_utils.safeReplace)(template, import_constants.CHUNK_CSS_PLACEHOLDER, css);
74
70
  async function getCssChunks() {
75
71
  const { routeManifest, routerContext, routes } = context;
76
72
  if (!routeManifest || !routerContext || !routes) {
@@ -88,7 +84,7 @@ function getHeadTemplate(beforeEntryTemplate, context, pluginConfig) {
88
84
  const routeManifest2 = routeAssets[routeId];
89
85
  if (routeManifest2) {
90
86
  const { referenceCssAssets = [] } = routeManifest2;
91
- const _cssChunks = referenceCssAssets.filter((asset) => (asset === null || asset === void 0 ? void 0 : asset.endsWith(".css")) && !headTemplate2.includes(asset));
87
+ const _cssChunks = referenceCssAssets.filter((asset) => (asset === null || asset === void 0 ? void 0 : asset.endsWith(".css")) && !template.includes(asset));
92
88
  cssChunks.push(..._cssChunks);
93
89
  }
94
90
  }
@@ -108,10 +104,6 @@ function getHeadTemplate(beforeEntryTemplate, context, pluginConfig) {
108
104
  }
109
105
  }
110
106
  }
111
- async function buildShellBeforeTemplate(beforeAppTemplate, context, pluginConfig) {
112
- const headTemplate = await getHeadTemplate(beforeAppTemplate, context, pluginConfig);
113
- return beforeAppTemplate.replace(import_buildTemplate.HEAD_REG_EXP, headTemplate);
114
- }
115
107
  // Annotate the CommonJS export names for ESM import in node:
116
108
  0 && (module.exports = {
117
109
  buildShellBeforeTemplate
@@ -23,7 +23,7 @@ function modifyRoutes(modifyFunction) {
23
23
  }
24
24
  }
25
25
  var routerPlugin = function(param) {
26
- var _param_serverBase = param.serverBase, serverBase = _param_serverBase === void 0 ? [] : _param_serverBase, _param_supportHtml5History = param.supportHtml5History, supportHtml5History = _param_supportHtml5History === void 0 ? true : _param_supportHtml5History, _param_basename = param.basename, basename = _param_basename === void 0 ? "" : _param_basename, routesConfig = param.routesConfig, createRoutes = param.createRoutes;
26
+ var _param_serverBase = param.serverBase, serverBase = _param_serverBase === void 0 ? [] : _param_serverBase, _param_supportHtml5History = param.supportHtml5History, supportHtml5History = _param_supportHtml5History === void 0 ? true : _param_supportHtml5History, _param_basename = param.basename, basename = _param_basename === void 0 ? "" : _param_basename, _param_originalBaseUrl = param.originalBaseUrl, originalBaseUrl = _param_originalBaseUrl === void 0 ? "" : _param_originalBaseUrl, routesConfig = param.routesConfig, createRoutes = param.createRoutes;
27
27
  var select = function(pathname) {
28
28
  return serverBase.find(function(baseUrl) {
29
29
  return pathname.search(baseUrl) === 0;
@@ -65,7 +65,7 @@ var routerPlugin = function(param) {
65
65
  var getRouteApp = function() {
66
66
  var useCreateRouter = function(props) {
67
67
  var _window__SERVER_DATA;
68
- var baseUrl = ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname);
68
+ var baseUrl = originalBaseUrl || ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname);
69
69
  var _basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
70
70
  var hydrationData = window._ROUTER_DATA;
71
71
  var runtimeContext = useContext(RuntimeReactContext);
@@ -77,7 +77,7 @@ function createFetchHeaders(requestHeaders) {
77
77
  return headers;
78
78
  }
79
79
  var routerPlugin = function(param) {
80
- var _param_basename = param.basename, basename = _param_basename === void 0 ? "" : _param_basename, routesConfig = param.routesConfig, createRoutes = param.createRoutes;
80
+ var _param_basename = param.basename, basename = _param_basename === void 0 ? "" : _param_basename, _param_originalBaseUrl = param.originalBaseUrl, originalBaseUrl = _param_originalBaseUrl === void 0 ? "" : _param_originalBaseUrl, routesConfig = param.routesConfig, createRoutes = param.createRoutes;
81
81
  return {
82
82
  name: "@modern-js/plugin-router",
83
83
  registerHook: {
@@ -101,7 +101,7 @@ var routerPlugin = function(param) {
101
101
  ];
102
102
  }
103
103
  _context_ssrContext = context.ssrContext, request = _context_ssrContext.request, ssrMode = _context_ssrContext.mode, nonce = _context_ssrContext.nonce;
104
- baseUrl = request.baseUrl;
104
+ baseUrl = originalBaseUrl || request.baseUrl;
105
105
  _basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
106
106
  _context_ssrContext1 = context.ssrContext, reporter = _context_ssrContext1.reporter, serverTiming = _context_ssrContext1.serverTiming;
107
107
  requestContext = createRequestContext();
@@ -1,6 +1,5 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
3
- import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
3
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
4
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
6
5
  import ReactHelmet from "react-helmet";
@@ -8,7 +7,7 @@ import { matchRoutes } from "@modern-js/runtime-utils/router";
8
7
  import helmetReplace from "../helmet";
9
8
  import { CHUNK_CSS_PLACEHOLDER } from "../constants";
10
9
  import { checkIsNode, safeReplace } from "../utils";
11
- import { HEAD_REG_EXP, buildTemplate } from "./buildTemplate.share";
10
+ import { buildTemplate } from "./buildTemplate.share";
12
11
  var readAsset = function() {
13
12
  var _ref = _async_to_generator(function(chunk) {
14
13
  var fs, path, filepath;
@@ -50,145 +49,129 @@ var checkIsInline = function(chunk, enableInline) {
50
49
  return false;
51
50
  }
52
51
  };
53
- function getHeadTemplate(beforeEntryTemplate, context, pluginConfig) {
54
- var helmetData = ReactHelmet.renderStatic();
55
- var callbacks = [
56
- function(headTemplate2) {
57
- return helmetData ? helmetReplace(headTemplate2, helmetData) : headTemplate2;
58
- },
59
- // @TODO: prefetch scripts of lazy component
60
- injectCss
61
- ];
62
- var _ref = _sliced_to_array(beforeEntryTemplate.match(HEAD_REG_EXP) || [], 1), tmp = _ref[0], headTemplate = tmp === void 0 ? "" : tmp;
63
- if (!headTemplate.length) {
64
- return "";
65
- }
66
- return buildTemplate(headTemplate, callbacks);
67
- function injectCss(headTemplate2) {
68
- return _injectCss.apply(this, arguments);
69
- }
70
- function _injectCss() {
71
- _injectCss = _async_to_generator(function(headTemplate2) {
72
- var css;
73
- function getCssChunks() {
74
- return _getCssChunks.apply(this, arguments);
75
- }
76
- function _getCssChunks() {
77
- _getCssChunks = _async_to_generator(function() {
78
- var routeManifest, routerContext, routes, routeAssets, cssChunks, matches, enableInlineStyles, styles;
79
- return _ts_generator(this, function(_state) {
80
- switch (_state.label) {
81
- case 0:
82
- routeManifest = context.routeManifest, routerContext = context.routerContext, routes = context.routes;
83
- if (!routeManifest || !routerContext || !routes) {
84
- return [
85
- 2,
86
- ""
87
- ];
88
- }
89
- routeAssets = routeManifest.routeAssets;
90
- cssChunks = [];
91
- matches = matchRoutes(routes, routerContext.location, routerContext.basename);
92
- matches === null || matches === void 0 ? void 0 : matches.forEach(function(match, index) {
93
- if (!index) {
94
- return;
52
+ function buildShellBeforeTemplate(beforeAppTemplate, context, pluginConfig) {
53
+ return _buildShellBeforeTemplate.apply(this, arguments);
54
+ }
55
+ function _buildShellBeforeTemplate() {
56
+ _buildShellBeforeTemplate = _async_to_generator(function(beforeAppTemplate, context, pluginConfig) {
57
+ var helmetData, callbacks;
58
+ function injectCss(template) {
59
+ return _injectCss.apply(this, arguments);
60
+ }
61
+ function _injectCss() {
62
+ _injectCss = _async_to_generator(function(template) {
63
+ var css;
64
+ function getCssChunks() {
65
+ return _getCssChunks.apply(this, arguments);
66
+ }
67
+ function _getCssChunks() {
68
+ _getCssChunks = _async_to_generator(function() {
69
+ var routeManifest, routerContext, routes, routeAssets, cssChunks, matches, enableInlineStyles, styles;
70
+ return _ts_generator(this, function(_state) {
71
+ switch (_state.label) {
72
+ case 0:
73
+ routeManifest = context.routeManifest, routerContext = context.routerContext, routes = context.routes;
74
+ if (!routeManifest || !routerContext || !routes) {
75
+ return [
76
+ 2,
77
+ ""
78
+ ];
95
79
  }
96
- var routeId = match.route.id;
97
- if (routeId) {
98
- var routeManifest2 = routeAssets[routeId];
99
- if (routeManifest2) {
100
- var _cssChunks;
101
- var _routeManifest_referenceCssAssets = routeManifest2.referenceCssAssets, referenceCssAssets = _routeManifest_referenceCssAssets === void 0 ? [] : _routeManifest_referenceCssAssets;
102
- var _cssChunks1 = referenceCssAssets.filter(function(asset) {
103
- return (asset === null || asset === void 0 ? void 0 : asset.endsWith(".css")) && !headTemplate2.includes(asset);
104
- });
105
- (_cssChunks = cssChunks).push.apply(_cssChunks, _to_consumable_array(_cssChunks1));
80
+ routeAssets = routeManifest.routeAssets;
81
+ cssChunks = [];
82
+ matches = matchRoutes(routes, routerContext.location, routerContext.basename);
83
+ matches === null || matches === void 0 ? void 0 : matches.forEach(function(match, index) {
84
+ if (!index) {
85
+ return;
106
86
  }
107
- }
108
- });
109
- enableInlineStyles = pluginConfig.enableInlineStyles;
110
- return [
111
- 4,
112
- Promise.all(cssChunks.map(function() {
113
- var _ref2 = _async_to_generator(function(chunk) {
114
- var link;
115
- return _ts_generator(this, function(_state2) {
116
- link = '<link href="'.concat(chunk, '" rel="stylesheet" />');
117
- if (checkIsNode() && checkIsInline(chunk, enableInlineStyles)) {
118
- return [
119
- 2,
120
- readAsset(chunk).then(function(content) {
121
- return "<style>".concat(content, "</style>");
122
- }).catch(function(_) {
123
- return link;
124
- })
125
- ];
126
- } else {
87
+ var routeId = match.route.id;
88
+ if (routeId) {
89
+ var routeManifest2 = routeAssets[routeId];
90
+ if (routeManifest2) {
91
+ var _cssChunks;
92
+ var _routeManifest_referenceCssAssets = routeManifest2.referenceCssAssets, referenceCssAssets = _routeManifest_referenceCssAssets === void 0 ? [] : _routeManifest_referenceCssAssets;
93
+ var _cssChunks1 = referenceCssAssets.filter(function(asset) {
94
+ return (asset === null || asset === void 0 ? void 0 : asset.endsWith(".css")) && !template.includes(asset);
95
+ });
96
+ (_cssChunks = cssChunks).push.apply(_cssChunks, _to_consumable_array(_cssChunks1));
97
+ }
98
+ }
99
+ });
100
+ enableInlineStyles = pluginConfig.enableInlineStyles;
101
+ return [
102
+ 4,
103
+ Promise.all(cssChunks.map(function() {
104
+ var _ref = _async_to_generator(function(chunk) {
105
+ var link;
106
+ return _ts_generator(this, function(_state2) {
107
+ link = '<link href="'.concat(chunk, '" rel="stylesheet" />');
108
+ if (checkIsNode() && checkIsInline(chunk, enableInlineStyles)) {
109
+ return [
110
+ 2,
111
+ readAsset(chunk).then(function(content) {
112
+ return "<style>".concat(content, "</style>");
113
+ }).catch(function(_) {
114
+ return link;
115
+ })
116
+ ];
117
+ } else {
118
+ return [
119
+ 2,
120
+ link
121
+ ];
122
+ }
127
123
  return [
128
- 2,
129
- link
124
+ 2
130
125
  ];
131
- }
132
- return [
133
- 2
134
- ];
126
+ });
135
127
  });
136
- });
137
- return function(chunk) {
138
- return _ref2.apply(this, arguments);
139
- };
140
- }()))
141
- ];
142
- case 1:
143
- styles = _state.sent();
144
- return [
145
- 2,
146
- "".concat(styles.join(""))
147
- ];
148
- }
128
+ return function(chunk) {
129
+ return _ref.apply(this, arguments);
130
+ };
131
+ }()))
132
+ ];
133
+ case 1:
134
+ styles = _state.sent();
135
+ return [
136
+ 2,
137
+ "".concat(styles.join(""))
138
+ ];
139
+ }
140
+ });
149
141
  });
150
- });
151
- return _getCssChunks.apply(this, arguments);
152
- }
153
- return _ts_generator(this, function(_state) {
154
- switch (_state.label) {
155
- case 0:
156
- return [
157
- 4,
158
- getCssChunks()
159
- ];
160
- case 1:
161
- css = _state.sent();
162
- return [
163
- 2,
164
- safeReplace(headTemplate2, CHUNK_CSS_PLACEHOLDER, css)
165
- ];
142
+ return _getCssChunks.apply(this, arguments);
166
143
  }
144
+ return _ts_generator(this, function(_state) {
145
+ switch (_state.label) {
146
+ case 0:
147
+ return [
148
+ 4,
149
+ getCssChunks()
150
+ ];
151
+ case 1:
152
+ css = _state.sent();
153
+ return [
154
+ 2,
155
+ safeReplace(template, CHUNK_CSS_PLACEHOLDER, css)
156
+ ];
157
+ }
158
+ });
167
159
  });
168
- });
169
- return _injectCss.apply(this, arguments);
170
- }
171
- }
172
- function buildShellBeforeTemplate(beforeAppTemplate, context, pluginConfig) {
173
- return _buildShellBeforeTemplate.apply(this, arguments);
174
- }
175
- function _buildShellBeforeTemplate() {
176
- _buildShellBeforeTemplate = _async_to_generator(function(beforeAppTemplate, context, pluginConfig) {
177
- var headTemplate;
160
+ return _injectCss.apply(this, arguments);
161
+ }
178
162
  return _ts_generator(this, function(_state) {
179
- switch (_state.label) {
180
- case 0:
181
- return [
182
- 4,
183
- getHeadTemplate(beforeAppTemplate, context, pluginConfig)
184
- ];
185
- case 1:
186
- headTemplate = _state.sent();
187
- return [
188
- 2,
189
- beforeAppTemplate.replace(HEAD_REG_EXP, headTemplate)
190
- ];
191
- }
163
+ helmetData = ReactHelmet.renderStatic();
164
+ callbacks = [
165
+ function(headTemplate) {
166
+ return helmetData ? helmetReplace(headTemplate, helmetData) : headTemplate;
167
+ },
168
+ // @TODO: prefetch scripts of lazy component
169
+ injectCss
170
+ ];
171
+ return [
172
+ 2,
173
+ buildTemplate(beforeAppTemplate, callbacks)
174
+ ];
192
175
  });
193
176
  });
194
177
  return _buildShellBeforeTemplate.apply(this, arguments);
@@ -19,7 +19,16 @@ function modifyRoutes(modifyFunction) {
19
19
  console.error("It is not allowed to modify routes config after create router.");
20
20
  }
21
21
  }
22
- const routerPlugin = ({ serverBase = [], supportHtml5History = true, basename = "", routesConfig, createRoutes }) => {
22
+ const routerPlugin = ({
23
+ serverBase = [],
24
+ supportHtml5History = true,
25
+ basename = "",
26
+ // when the current child app has multiple entries, there is a problem,
27
+ // so we have added a new parameter, the parameter will replace basename and baseUrl after the major version.
28
+ originalBaseUrl = "",
29
+ routesConfig,
30
+ createRoutes
31
+ }) => {
23
32
  const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
24
33
  let routes = [];
25
34
  finalRouteConfig = routesConfig;
@@ -55,7 +64,7 @@ const routerPlugin = ({ serverBase = [], supportHtml5History = true, basename =
55
64
  const getRouteApp = () => {
56
65
  const useCreateRouter = (props) => {
57
66
  var _window__SERVER_DATA;
58
- const baseUrl = ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname);
67
+ const baseUrl = originalBaseUrl || ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname);
59
68
  const _basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
60
69
  let hydrationData = window._ROUTER_DATA;
61
70
  const runtimeContext = useContext(RuntimeReactContext);
@@ -36,7 +36,7 @@ function createFetchHeaders(requestHeaders) {
36
36
  }
37
37
  return headers;
38
38
  }
39
- const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
39
+ const routerPlugin = ({ basename = "", originalBaseUrl = "", routesConfig, createRoutes }) => {
40
40
  return {
41
41
  name: "@modern-js/plugin-router",
42
42
  registerHook: {
@@ -51,7 +51,7 @@ const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
51
51
  });
52
52
  }
53
53
  const { request, mode: ssrMode, nonce } = context.ssrContext;
54
- const baseUrl = request.baseUrl;
54
+ const baseUrl = originalBaseUrl || request.baseUrl;
55
55
  const _basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
56
56
  const { reporter, serverTiming } = context.ssrContext;
57
57
  const requestContext = createRequestContext();
@@ -3,7 +3,7 @@ import { matchRoutes } from "@modern-js/runtime-utils/router";
3
3
  import helmetReplace from "../helmet";
4
4
  import { CHUNK_CSS_PLACEHOLDER } from "../constants";
5
5
  import { checkIsNode, safeReplace } from "../utils";
6
- import { HEAD_REG_EXP, buildTemplate } from "./buildTemplate.share";
6
+ import { buildTemplate } from "./buildTemplate.share";
7
7
  const readAsset = async (chunk) => {
8
8
  const fs = await import("fs/promises");
9
9
  const path = await import("path");
@@ -21,23 +21,19 @@ const checkIsInline = (chunk, enableInline) => {
21
21
  return false;
22
22
  }
23
23
  };
24
- function getHeadTemplate(beforeEntryTemplate, context, pluginConfig) {
24
+ async function buildShellBeforeTemplate(beforeAppTemplate, context, pluginConfig) {
25
25
  const helmetData = ReactHelmet.renderStatic();
26
26
  const callbacks = [
27
- (headTemplate2) => {
28
- return helmetData ? helmetReplace(headTemplate2, helmetData) : headTemplate2;
27
+ (headTemplate) => {
28
+ return helmetData ? helmetReplace(headTemplate, helmetData) : headTemplate;
29
29
  },
30
30
  // @TODO: prefetch scripts of lazy component
31
31
  injectCss
32
32
  ];
33
- const [headTemplate = ""] = beforeEntryTemplate.match(HEAD_REG_EXP) || [];
34
- if (!headTemplate.length) {
35
- return "";
36
- }
37
- return buildTemplate(headTemplate, callbacks);
38
- async function injectCss(headTemplate2) {
33
+ return buildTemplate(beforeAppTemplate, callbacks);
34
+ async function injectCss(template) {
39
35
  const css = await getCssChunks();
40
- return safeReplace(headTemplate2, CHUNK_CSS_PLACEHOLDER, css);
36
+ return safeReplace(template, CHUNK_CSS_PLACEHOLDER, css);
41
37
  async function getCssChunks() {
42
38
  const { routeManifest, routerContext, routes } = context;
43
39
  if (!routeManifest || !routerContext || !routes) {
@@ -55,7 +51,7 @@ function getHeadTemplate(beforeEntryTemplate, context, pluginConfig) {
55
51
  const routeManifest2 = routeAssets[routeId];
56
52
  if (routeManifest2) {
57
53
  const { referenceCssAssets = [] } = routeManifest2;
58
- const _cssChunks = referenceCssAssets.filter((asset) => (asset === null || asset === void 0 ? void 0 : asset.endsWith(".css")) && !headTemplate2.includes(asset));
54
+ const _cssChunks = referenceCssAssets.filter((asset) => (asset === null || asset === void 0 ? void 0 : asset.endsWith(".css")) && !template.includes(asset));
59
55
  cssChunks.push(..._cssChunks);
60
56
  }
61
57
  }
@@ -75,10 +71,6 @@ function getHeadTemplate(beforeEntryTemplate, context, pluginConfig) {
75
71
  }
76
72
  }
77
73
  }
78
- async function buildShellBeforeTemplate(beforeAppTemplate, context, pluginConfig) {
79
- const headTemplate = await getHeadTemplate(beforeAppTemplate, context, pluginConfig);
80
- return beforeAppTemplate.replace(HEAD_REG_EXP, headTemplate);
81
- }
82
74
  export {
83
75
  buildShellBeforeTemplate
84
76
  };
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  export declare function Html(props: {
3
3
  children: any[];
4
- }): JSX.Element;
4
+ } & React.HtmlHTMLAttributes<HTMLHtmlElement>): JSX.Element;
@@ -3,4 +3,4 @@ import type { RouterConfig, Routes } from './types';
3
3
  export declare let finalRouteConfig: RouterConfig['routesConfig'];
4
4
  export declare let beforeCreateRouter: boolean;
5
5
  export declare function modifyRoutes(modifyFunction: (routes: Routes) => Routes): void;
6
- export declare const routerPlugin: ({ serverBase, supportHtml5History, basename, routesConfig, createRoutes, }: RouterConfig) => Plugin;
6
+ export declare const routerPlugin: ({ serverBase, supportHtml5History, basename, originalBaseUrl, routesConfig, createRoutes, }: RouterConfig) => Plugin;
@@ -2,5 +2,5 @@ import type { Plugin } from '../../core';
2
2
  import { SSRServerContext } from '../../ssr/serverRender/types';
3
3
  import type { RouterConfig } from './types';
4
4
  export declare function createFetchHeaders(requestHeaders: SSRServerContext['request']['headers']): Headers;
5
- export declare const routerPlugin: ({ basename, routesConfig, createRoutes, }: RouterConfig) => Plugin;
5
+ export declare const routerPlugin: ({ basename, originalBaseUrl, routesConfig, createRoutes, }: RouterConfig) => Plugin;
6
6
  export declare const modifyRoutes: () => void;
@@ -37,6 +37,7 @@ export type RouterConfig = {
37
37
  oldVersion?: boolean;
38
38
  serverBase?: string[];
39
39
  supportHtml5History?: boolean;
40
+ originalBaseUrl?: string;
40
41
  basename?: string;
41
42
  createRoutes?: () => RouteObject[];
42
43
  };
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.49.2",
18
+ "version": "2.49.3",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -170,10 +170,10 @@
170
170
  "react-side-effect": "^2.1.1",
171
171
  "styled-components": "^5.3.1",
172
172
  "@swc/helpers": "0.5.3",
173
- "@modern-js/plugin": "2.49.2",
174
- "@modern-js/types": "2.49.2",
175
- "@modern-js/utils": "2.49.2",
176
- "@modern-js/runtime-utils": "2.49.2"
173
+ "@modern-js/plugin": "2.49.3",
174
+ "@modern-js/utils": "2.49.3",
175
+ "@modern-js/types": "2.49.3",
176
+ "@modern-js/runtime-utils": "2.49.3"
177
177
  },
178
178
  "peerDependencies": {
179
179
  "react": ">=17",
@@ -194,11 +194,11 @@
194
194
  "ts-jest": "^29.1.0",
195
195
  "typescript": "^5",
196
196
  "webpack": "^5.91.0",
197
- "@modern-js/core": "2.49.2",
198
- "@modern-js/app-tools": "2.49.2",
199
- "@scripts/build": "2.49.2",
200
- "@modern-js/server-core": "2.49.2",
201
- "@scripts/jest-config": "2.49.2"
197
+ "@modern-js/app-tools": "2.49.3",
198
+ "@modern-js/core": "2.49.3",
199
+ "@scripts/build": "2.49.3",
200
+ "@modern-js/server-core": "2.49.3",
201
+ "@scripts/jest-config": "2.49.3"
202
202
  },
203
203
  "sideEffects": false,
204
204
  "publishConfig": {