@bleedingdev/modern-js-runtime 3.2.0-ultramodern.9 → 3.2.0-ultramodern.90
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/cjs/boundary-debugger/index.js +299 -0
- package/dist/cjs/cli/ssr/index.js +5 -15
- package/dist/cjs/cli/template.server.js +1 -0
- package/dist/cjs/core/react/wrapper.js +9 -3
- package/dist/cjs/core/server/federatedCss.js +47 -0
- package/dist/cjs/core/server/helmet.js +8 -2
- package/dist/cjs/core/server/stream/afterTemplate.js +9 -6
- package/dist/cjs/core/server/stream/beforeTemplate.js +13 -20
- package/dist/cjs/core/server/stream/beforeTemplate.worker.js +98 -0
- package/dist/cjs/core/server/stream/createReadableStream.js +7 -2
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +4 -2
- package/dist/cjs/core/server/stream/shared.js +3 -1
- package/dist/cjs/core/server/string/index.js +6 -6
- package/dist/cjs/core/server/string/loadable.js +33 -7
- package/dist/cjs/exports/head.js +196 -5
- package/dist/cjs/router/cli/code/tanstackTypes.js +116 -51
- package/dist/cjs/router/cli/code/templates.js +1 -8
- package/dist/cjs/router/runtime/tanstack/plugin.js +4 -5
- package/dist/cjs/router/runtime/tanstack/plugin.node.js +2 -13
- package/dist/cjs/router/runtime/tanstack/routeTree.js +47 -4
- package/dist/cjs/rsc/server.worker.js +58 -0
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +9 -8
- package/dist/esm/boundary-debugger/index.mjs +263 -0
- package/dist/esm/cli/ssr/index.mjs +5 -15
- package/dist/esm/cli/template.server.mjs +1 -0
- package/dist/esm/core/react/wrapper.mjs +9 -3
- package/dist/esm/core/server/federatedCss.mjs +13 -0
- package/dist/esm/core/server/helmet.mjs +5 -2
- package/dist/esm/core/server/stream/afterTemplate.mjs +10 -7
- package/dist/esm/core/server/stream/beforeTemplate.mjs +14 -11
- package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +64 -0
- package/dist/esm/core/server/stream/createReadableStream.mjs +7 -2
- package/dist/esm/core/server/stream/createReadableStream.worker.mjs +4 -2
- package/dist/esm/core/server/stream/shared.mjs +3 -1
- package/dist/esm/core/server/string/index.mjs +7 -6
- package/dist/esm/core/server/string/loadable.mjs +33 -7
- package/dist/esm/exports/head.mjs +189 -4
- package/dist/esm/router/cli/code/tanstackTypes.mjs +116 -51
- package/dist/esm/router/cli/code/templates.mjs +1 -8
- package/dist/esm/router/runtime/tanstack/plugin.mjs +8 -9
- package/dist/esm/router/runtime/tanstack/plugin.node.mjs +3 -14
- package/dist/esm/router/runtime/tanstack/routeTree.mjs +47 -4
- package/dist/esm/rsc/server.worker.mjs +1 -0
- package/dist/esm/ssr/serverRender/renderToString/entry.mjs +9 -6
- package/dist/esm-node/boundary-debugger/index.mjs +264 -0
- package/dist/esm-node/cli/ssr/index.mjs +5 -15
- package/dist/esm-node/cli/template.server.mjs +1 -0
- package/dist/esm-node/core/react/wrapper.mjs +9 -3
- package/dist/esm-node/core/server/federatedCss.mjs +14 -0
- package/dist/esm-node/core/server/helmet.mjs +5 -2
- package/dist/esm-node/core/server/stream/afterTemplate.mjs +10 -7
- package/dist/esm-node/core/server/stream/beforeTemplate.mjs +14 -11
- package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +65 -0
- package/dist/esm-node/core/server/stream/createReadableStream.mjs +7 -2
- package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +4 -2
- package/dist/esm-node/core/server/stream/shared.mjs +3 -1
- package/dist/esm-node/core/server/string/index.mjs +7 -6
- package/dist/esm-node/core/server/string/loadable.mjs +33 -7
- package/dist/esm-node/exports/head.mjs +189 -4
- package/dist/esm-node/router/cli/code/tanstackTypes.mjs +116 -51
- package/dist/esm-node/router/cli/code/templates.mjs +1 -8
- package/dist/esm-node/router/runtime/tanstack/plugin.mjs +8 -9
- package/dist/esm-node/router/runtime/tanstack/plugin.node.mjs +3 -14
- package/dist/esm-node/router/runtime/tanstack/routeTree.mjs +47 -4
- package/dist/esm-node/rsc/server.worker.mjs +2 -0
- package/dist/esm-node/ssr/serverRender/renderToString/entry.mjs +9 -6
- package/dist/types/boundary-debugger/index.d.ts +28 -0
- package/dist/types/core/context/runtime.d.ts +4 -0
- package/dist/types/core/server/federatedCss.d.ts +5 -0
- package/dist/types/core/server/helmet.d.ts +5 -3
- package/dist/types/core/server/stream/beforeTemplate.d.ts +1 -0
- package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +10 -0
- package/dist/types/core/server/stream/shared.d.ts +8 -0
- package/dist/types/core/server/string/loadable.d.ts +4 -0
- package/dist/types/exports/head.d.ts +10 -3
- package/dist/types/rsc/server.worker.d.ts +1 -0
- package/package.json +25 -19
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
default: ()=>boundary_debugger,
|
|
28
|
+
ultramodernBoundaryDebuggerPlugin: ()=>ultramodernBoundaryDebuggerPlugin
|
|
29
|
+
});
|
|
30
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
+
const external_react_namespaceObject = require("react");
|
|
32
|
+
const defaultStorageKey = 'modernjs:boundary-debugger:enabled';
|
|
33
|
+
const queryParamName = 'modern-boundaries';
|
|
34
|
+
const boundarySelector = '[data-modern-boundary-id]';
|
|
35
|
+
const defaultLabels = {
|
|
36
|
+
cs: {
|
|
37
|
+
toggle: 'zobrazit hranice týmů'
|
|
38
|
+
},
|
|
39
|
+
en: {
|
|
40
|
+
toggle: 'show team boundaries'
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const palette = [
|
|
44
|
+
'#ff5a5f',
|
|
45
|
+
'#30e27a',
|
|
46
|
+
'#f6cf45',
|
|
47
|
+
'#7c8cff',
|
|
48
|
+
'#29b6f6'
|
|
49
|
+
];
|
|
50
|
+
const readStoredEnabled = (storageKey, fallback)=>{
|
|
51
|
+
if ("u" < typeof window) return fallback;
|
|
52
|
+
try {
|
|
53
|
+
const stored = window.localStorage.getItem(storageKey);
|
|
54
|
+
return null === stored ? fallback : 'true' === stored;
|
|
55
|
+
} catch {
|
|
56
|
+
return fallback;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const writeStoredEnabled = (storageKey, enabled)=>{
|
|
60
|
+
if ("u" < typeof window) return;
|
|
61
|
+
try {
|
|
62
|
+
window.localStorage.setItem(storageKey, String(enabled));
|
|
63
|
+
} catch {}
|
|
64
|
+
};
|
|
65
|
+
const parseEnabledOverride = (value)=>{
|
|
66
|
+
if (null === value) return;
|
|
67
|
+
const normalized = value.toLowerCase();
|
|
68
|
+
if ('1' === normalized || 'true' === normalized) return true;
|
|
69
|
+
if ('0' === normalized || 'false' === normalized) return false;
|
|
70
|
+
};
|
|
71
|
+
const readQueryEnabledOverride = ()=>{
|
|
72
|
+
if ("u" < typeof window) return;
|
|
73
|
+
try {
|
|
74
|
+
return parseEnabledOverride(new URLSearchParams(window.location.search).get(queryParamName));
|
|
75
|
+
} catch {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const detectLanguage = ()=>{
|
|
80
|
+
if ("u" < typeof document) return 'en';
|
|
81
|
+
const htmlLanguage = document.documentElement.lang;
|
|
82
|
+
if (htmlLanguage) return htmlLanguage.split('-')[0] || 'en';
|
|
83
|
+
if ("u" < typeof window) return 'en';
|
|
84
|
+
return window.location.pathname.split('/').filter(Boolean)[0] || 'en';
|
|
85
|
+
};
|
|
86
|
+
const hashBoundaryId = (id)=>{
|
|
87
|
+
let hash = 0;
|
|
88
|
+
for(let index = 0; index < id.length; index++)hash = 31 * hash + id.charCodeAt(index) >>> 0;
|
|
89
|
+
return hash;
|
|
90
|
+
};
|
|
91
|
+
const formatRectKey = (rect)=>[
|
|
92
|
+
Math.round(100 * rect.left) / 100,
|
|
93
|
+
Math.round(100 * rect.top) / 100,
|
|
94
|
+
Math.round(100 * rect.width) / 100,
|
|
95
|
+
Math.round(100 * rect.height) / 100
|
|
96
|
+
].join(':');
|
|
97
|
+
const getBoundaryId = (element)=>element.dataset.modernBoundaryId ?? element.dataset.mfRemote ?? element.getAttribute('data-mf-remote') ?? void 0;
|
|
98
|
+
const collectBoundaryElements = (legacySelector)=>{
|
|
99
|
+
const elements = new Set();
|
|
100
|
+
for (const element of document.querySelectorAll(boundarySelector))elements.add(element);
|
|
101
|
+
if (!legacySelector) return Array.from(elements);
|
|
102
|
+
try {
|
|
103
|
+
for (const element of document.querySelectorAll(legacySelector))elements.add(element);
|
|
104
|
+
} catch {}
|
|
105
|
+
return Array.from(elements);
|
|
106
|
+
};
|
|
107
|
+
function BoundaryDebugger({ controlMode = 'visible', enabledByDefault = false, labels = defaultLabels, legacySelector, metadata, storageKey = defaultStorageKey }) {
|
|
108
|
+
const [mounted, setMounted] = (0, external_react_namespaceObject.useState)(false);
|
|
109
|
+
const [enabled, setEnabled] = (0, external_react_namespaceObject.useState)(false);
|
|
110
|
+
const [boxes, setBoxes] = (0, external_react_namespaceObject.useState)([]);
|
|
111
|
+
const boundaries = (0, external_react_namespaceObject.useMemo)(()=>new Map(metadata.boundaries.map((entry, index)=>[
|
|
112
|
+
entry.mfName,
|
|
113
|
+
{
|
|
114
|
+
...entry,
|
|
115
|
+
color: entry.color ?? palette[index % palette.length],
|
|
116
|
+
label: entry.label ?? entry.appId
|
|
117
|
+
}
|
|
118
|
+
])), [
|
|
119
|
+
metadata
|
|
120
|
+
]);
|
|
121
|
+
const language = mounted ? detectLanguage() : 'en';
|
|
122
|
+
const toggleLabel = labels[language]?.toggle ?? labels.en?.toggle ?? defaultLabels.en?.toggle ?? 'show team boundaries';
|
|
123
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
124
|
+
setMounted(true);
|
|
125
|
+
const queryOverride = readQueryEnabledOverride();
|
|
126
|
+
setEnabled(queryOverride ?? readStoredEnabled(storageKey, enabledByDefault));
|
|
127
|
+
}, [
|
|
128
|
+
enabledByDefault,
|
|
129
|
+
storageKey
|
|
130
|
+
]);
|
|
131
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
132
|
+
if (!mounted) return;
|
|
133
|
+
writeStoredEnabled(storageKey, enabled);
|
|
134
|
+
}, [
|
|
135
|
+
enabled,
|
|
136
|
+
mounted,
|
|
137
|
+
storageKey
|
|
138
|
+
]);
|
|
139
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
140
|
+
if (!enabled) return void setBoxes([]);
|
|
141
|
+
const readBoxes = ()=>{
|
|
142
|
+
const seenBoxes = new Set();
|
|
143
|
+
const nextBoxes = collectBoundaryElements(legacySelector).map((element)=>{
|
|
144
|
+
const boundaryId = getBoundaryId(element);
|
|
145
|
+
if (!boundaryId) return;
|
|
146
|
+
const rect = element.getBoundingClientRect();
|
|
147
|
+
if (rect.width <= 0 || rect.height <= 0) return;
|
|
148
|
+
const rectKey = formatRectKey(rect);
|
|
149
|
+
const boxKey = `${boundaryId}:${rectKey}`;
|
|
150
|
+
if (seenBoxes.has(boxKey)) return;
|
|
151
|
+
seenBoxes.add(boxKey);
|
|
152
|
+
const boundary = boundaries.get(boundaryId);
|
|
153
|
+
const color = boundary?.color ?? palette[hashBoundaryId(boundaryId) % palette.length];
|
|
154
|
+
const label = boundary?.label ?? boundary?.appId ?? boundaryId;
|
|
155
|
+
const expose = element.dataset.modernMfExpose;
|
|
156
|
+
const detail = expose && expose !== label && expose !== boundaryId ? expose : void 0;
|
|
157
|
+
const box = {
|
|
158
|
+
color,
|
|
159
|
+
height: rect.height,
|
|
160
|
+
id: boxKey,
|
|
161
|
+
label,
|
|
162
|
+
left: rect.left,
|
|
163
|
+
top: rect.top,
|
|
164
|
+
width: rect.width
|
|
165
|
+
};
|
|
166
|
+
if (detail) box.detail = detail;
|
|
167
|
+
return box;
|
|
168
|
+
}).filter((box)=>void 0 !== box);
|
|
169
|
+
setBoxes(nextBoxes);
|
|
170
|
+
};
|
|
171
|
+
readBoxes();
|
|
172
|
+
const resizeObserver = "u" < typeof ResizeObserver ? void 0 : new ResizeObserver(readBoxes);
|
|
173
|
+
for (const element of collectBoundaryElements(legacySelector))resizeObserver?.observe(element);
|
|
174
|
+
const mutationObserver = new MutationObserver(readBoxes);
|
|
175
|
+
mutationObserver.observe(document.body, {
|
|
176
|
+
childList: true,
|
|
177
|
+
subtree: true
|
|
178
|
+
});
|
|
179
|
+
window.addEventListener('resize', readBoxes);
|
|
180
|
+
window.addEventListener('scroll', readBoxes, true);
|
|
181
|
+
return ()=>{
|
|
182
|
+
mutationObserver.disconnect();
|
|
183
|
+
resizeObserver?.disconnect();
|
|
184
|
+
window.removeEventListener('resize', readBoxes);
|
|
185
|
+
window.removeEventListener('scroll', readBoxes, true);
|
|
186
|
+
};
|
|
187
|
+
}, [
|
|
188
|
+
boundaries,
|
|
189
|
+
enabled,
|
|
190
|
+
legacySelector
|
|
191
|
+
]);
|
|
192
|
+
if (!mounted) return null;
|
|
193
|
+
const shouldRenderToggle = 'visible' === controlMode || 'hidden-when-off' === controlMode && enabled;
|
|
194
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
195
|
+
children: [
|
|
196
|
+
shouldRenderToggle ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("label", {
|
|
197
|
+
style: {
|
|
198
|
+
alignItems: 'center',
|
|
199
|
+
background: 'rgba(255, 255, 255, 0.96)',
|
|
200
|
+
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
201
|
+
borderRadius: 10,
|
|
202
|
+
boxShadow: '0 10px 28px rgba(0, 0, 0, 0.14)',
|
|
203
|
+
color: '#111827',
|
|
204
|
+
display: 'flex',
|
|
205
|
+
font: '600 13px/1.2 system-ui, sans-serif',
|
|
206
|
+
gap: 8,
|
|
207
|
+
left: 'max(12px, env(safe-area-inset-left))',
|
|
208
|
+
maxWidth: 'calc(100vw - 24px)',
|
|
209
|
+
padding: '9px 11px',
|
|
210
|
+
position: 'fixed',
|
|
211
|
+
top: 'max(12px, env(safe-area-inset-top))',
|
|
212
|
+
zIndex: 2147483000
|
|
213
|
+
},
|
|
214
|
+
children: [
|
|
215
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("input", {
|
|
216
|
+
checked: enabled,
|
|
217
|
+
onChange: (event)=>setEnabled(event.currentTarget.checked),
|
|
218
|
+
type: "checkbox"
|
|
219
|
+
}),
|
|
220
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
221
|
+
children: toggleLabel
|
|
222
|
+
})
|
|
223
|
+
]
|
|
224
|
+
}) : null,
|
|
225
|
+
enabled ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
226
|
+
"aria-hidden": "true",
|
|
227
|
+
children: boxes.map((box)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
228
|
+
style: {
|
|
229
|
+
border: `2px solid ${box.color}`,
|
|
230
|
+
borderRadius: 8,
|
|
231
|
+
boxShadow: `0 0 0 1px rgba(255,255,255,.72), 0 6px 20px color-mix(in srgb, ${box.color} 20%, transparent)`,
|
|
232
|
+
height: box.height,
|
|
233
|
+
left: box.left,
|
|
234
|
+
pointerEvents: 'none',
|
|
235
|
+
position: 'fixed',
|
|
236
|
+
top: box.top,
|
|
237
|
+
width: box.width,
|
|
238
|
+
zIndex: 2147482999
|
|
239
|
+
},
|
|
240
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
241
|
+
style: {
|
|
242
|
+
background: box.color,
|
|
243
|
+
borderRadius: 999,
|
|
244
|
+
color: '#111827',
|
|
245
|
+
display: 'grid',
|
|
246
|
+
font: '800 11px/1.1 system-ui, sans-serif',
|
|
247
|
+
gap: 3,
|
|
248
|
+
maxWidth: 'min(280px, calc(100vw - 24px))',
|
|
249
|
+
padding: '5px 8px',
|
|
250
|
+
position: 'absolute',
|
|
251
|
+
right: 4,
|
|
252
|
+
top: 4,
|
|
253
|
+
whiteSpace: 'nowrap'
|
|
254
|
+
},
|
|
255
|
+
children: [
|
|
256
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
257
|
+
children: box.label
|
|
258
|
+
}),
|
|
259
|
+
box.detail ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
260
|
+
style: {
|
|
261
|
+
font: '700 10px/1.1 system-ui, sans-serif',
|
|
262
|
+
opacity: 0.82,
|
|
263
|
+
overflow: 'hidden',
|
|
264
|
+
textOverflow: 'ellipsis'
|
|
265
|
+
},
|
|
266
|
+
children: box.detail
|
|
267
|
+
}) : null
|
|
268
|
+
]
|
|
269
|
+
})
|
|
270
|
+
}, box.id))
|
|
271
|
+
}) : null
|
|
272
|
+
]
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
const ultramodernBoundaryDebuggerPlugin = (options)=>({
|
|
276
|
+
name: '@modern-js/runtime/boundary-debugger',
|
|
277
|
+
setup: (api)=>{
|
|
278
|
+
api.wrapRoot((App)=>(props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
279
|
+
children: [
|
|
280
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
|
|
281
|
+
...props
|
|
282
|
+
}),
|
|
283
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(BoundaryDebugger, {
|
|
284
|
+
...options
|
|
285
|
+
})
|
|
286
|
+
]
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
const boundary_debugger = ultramodernBoundaryDebuggerPlugin;
|
|
291
|
+
exports["default"] = __webpack_exports__["default"];
|
|
292
|
+
exports.ultramodernBoundaryDebuggerPlugin = __webpack_exports__.ultramodernBoundaryDebuggerPlugin;
|
|
293
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
294
|
+
"default",
|
|
295
|
+
"ultramodernBoundaryDebuggerPlugin"
|
|
296
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
297
|
+
Object.defineProperty(exports, '__esModule', {
|
|
298
|
+
value: true
|
|
299
|
+
});
|
|
@@ -125,30 +125,20 @@ const ssrBuilderPlugin = (modernAPI, outputModule, exportLoadablePath)=>({
|
|
|
125
125
|
const hasServerRendering = hasServerRenderingConfig(userConfig);
|
|
126
126
|
const hasModuleFederationRuntimeMarker = hasServerRendering && shouldUseModuleFederationNodeOutput(config);
|
|
127
127
|
const hasExplicitMfSsrFlag = isModuleFederationAppSSREnabled(userConfig);
|
|
128
|
+
const isCloudflareWorkerSSR = 'workerSSR' === name && userConfig.deploy?.target === 'cloudflare';
|
|
128
129
|
const requireExplicitMfSsrFlag = 'true' === process.env.MODERN_MF_APP_SSR_REQUIRE_EXPLICIT;
|
|
129
130
|
if (hasServerRendering && hasModuleFederationRuntimeMarker && !hasExplicitMfSsrFlag) {
|
|
130
131
|
const warningMessage = '[modernjs][mf-ssr] Module Federation SSR was auto-detected from runtime markers. Set server.ssr.moduleFederationAppSSR=true explicitly in host and remotes to avoid heuristic drift.';
|
|
131
132
|
if (requireExplicitMfSsrFlag) throw new Error(`${warningMessage} (enforced by MODERN_MF_APP_SSR_REQUIRE_EXPLICIT=true)`);
|
|
132
133
|
console.warn(warningMessage);
|
|
133
134
|
}
|
|
134
|
-
const isModuleFederationAppSSR = hasServerRendering && hasExplicitMfSsrFlag;
|
|
135
|
-
const useModuleFederationNodeOutput = hasServerRendering && isModuleFederationAppSSR && isNodeEnvironmentTarget(config.output.target);
|
|
135
|
+
const isModuleFederationAppSSR = hasServerRendering && hasExplicitMfSsrFlag && !isCloudflareWorkerSSR;
|
|
136
136
|
const ssrEnv = userConfig.deploy?.worker?.ssr || userConfig.server?.rsc ? 'edge' : 'node';
|
|
137
137
|
const appContext = modernAPI.getAppContext();
|
|
138
138
|
const { appDirectory, entrypoints } = appContext;
|
|
139
|
-
const serverBundlerChain = useModuleFederationNodeOutput ? (chain)=>{
|
|
140
|
-
chain.target('async-node');
|
|
141
|
-
chain.output.module(false);
|
|
142
|
-
chain.output.chunkFormat('commonjs');
|
|
143
|
-
chain.output.chunkLoading('async-node');
|
|
144
|
-
chain.output.library({
|
|
145
|
-
...chain.output.get('library') || {},
|
|
146
|
-
type: 'commonjs-module'
|
|
147
|
-
});
|
|
148
|
-
} : void 0;
|
|
149
139
|
const useLoadablePlugin = (0, utils_namespaceObject.isUseSSRBundle)(userConfig) && !isServerEnvironment && checkUseStringSSR(userConfig, appDirectory, entrypoints);
|
|
150
140
|
const outputConfig = {
|
|
151
|
-
module: isServerEnvironment &&
|
|
141
|
+
module: isServerEnvironment && (outputModule || 'workerSSR' === name && userConfig.deploy?.target === 'cloudflare')
|
|
152
142
|
};
|
|
153
143
|
const useLoadableComponents = (0, utils_namespaceObject.isUseSSRBundle)(userConfig) && checkUseStringSSR(userConfig, appDirectory, entrypoints);
|
|
154
144
|
return mergeEnvironmentConfig(config, {
|
|
@@ -161,13 +151,13 @@ const ssrBuilderPlugin = (modernAPI, outputModule, exportLoadablePath)=>({
|
|
|
161
151
|
},
|
|
162
152
|
output: outputConfig,
|
|
163
153
|
tools: {
|
|
164
|
-
bundlerChain:
|
|
154
|
+
bundlerChain: useLoadablePlugin ? (chain)=>{
|
|
165
155
|
chain.plugin('loadable').use(external_loadable_bundler_plugin_js_default(), [
|
|
166
156
|
{
|
|
167
157
|
filename: utils_namespaceObject.LOADABLE_STATS_FILE
|
|
168
158
|
}
|
|
169
159
|
]);
|
|
170
|
-
} : void 0
|
|
160
|
+
} : void 0,
|
|
171
161
|
swc: useLoadableComponents ? {
|
|
172
162
|
jsc: {
|
|
173
163
|
experimental: {
|
|
@@ -27,9 +27,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
wrapRuntimeContextProvider: ()=>wrapRuntimeContextProvider
|
|
28
28
|
});
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_react_helmet_async_namespaceObject = require("react-helmet-async");
|
|
30
31
|
const index_js_namespaceObject = require("../context/index.js");
|
|
31
32
|
function wrapRuntimeContextProvider(App, contextValue) {
|
|
32
|
-
const { isBrowser, initialData, routes, routerFramework, context, routeManifest, routerRuntime, routerInstance, routerHydrationScript, routerMatchedRouteIds, routerServerSnapshot, routerContext, unstable_getBlockNavState, ssrContext, _internalContext, _internalRouterBaseName, ...rest } = contextValue;
|
|
33
|
+
const { isBrowser, initialData, routes, routerFramework, context, routeManifest, routerRuntime, routerInstance, routerHydrationScript, routerMatchedRouteIds, routerServerSnapshot, routerContext, unstable_getBlockNavState, ssrContext, _internalContext, _internalRouterBaseName, _helmetContext, ...rest } = contextValue;
|
|
34
|
+
const internalContextValue = contextValue;
|
|
35
|
+
internalContextValue._helmetContext ??= {};
|
|
33
36
|
const runtimeContextValue = {
|
|
34
37
|
isBrowser,
|
|
35
38
|
initialData,
|
|
@@ -39,10 +42,13 @@ function wrapRuntimeContextProvider(App, contextValue) {
|
|
|
39
42
|
...rest
|
|
40
43
|
};
|
|
41
44
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.InternalRuntimeContext.Provider, {
|
|
42
|
-
value:
|
|
45
|
+
value: internalContextValue,
|
|
43
46
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.RuntimeContext.Provider, {
|
|
44
47
|
value: runtimeContextValue,
|
|
45
|
-
children:
|
|
48
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_helmet_async_namespaceObject.HelmetProvider, {
|
|
49
|
+
context: internalContextValue._helmetContext,
|
|
50
|
+
children: App
|
|
51
|
+
})
|
|
46
52
|
})
|
|
47
53
|
});
|
|
48
54
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createFederatedCssLinks: ()=>createFederatedCssLinks
|
|
28
|
+
});
|
|
29
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
30
|
+
const createFederatedCssLinks = (assets, options)=>{
|
|
31
|
+
if (!assets?.length) return '';
|
|
32
|
+
const seen = new Set(options.existingAssets || []);
|
|
33
|
+
const attributes = (0, external_utils_js_namespaceObject.attributesToString)(options.attributes || {});
|
|
34
|
+
const links = [];
|
|
35
|
+
for (const asset of assets)if (!(!asset || seen.has(asset) || options.template.includes(asset))) {
|
|
36
|
+
seen.add(asset);
|
|
37
|
+
links.push(`<link${attributes} href="${asset}" rel="stylesheet" />`);
|
|
38
|
+
}
|
|
39
|
+
return links.join('');
|
|
40
|
+
};
|
|
41
|
+
exports.createFederatedCssLinks = __webpack_exports__.createFederatedCssLinks;
|
|
42
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
43
|
+
"createFederatedCssLinks"
|
|
44
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
45
|
+
Object.defineProperty(exports, '__esModule', {
|
|
46
|
+
value: true
|
|
47
|
+
});
|
|
@@ -25,15 +25,19 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
createReplaceHelemt: ()=>createReplaceHelemt,
|
|
28
|
+
getHelmetData: ()=>getHelmetData,
|
|
28
29
|
helmetReplace: ()=>helmetReplace
|
|
29
30
|
});
|
|
30
|
-
const external_os_namespaceObject = require("os");
|
|
31
31
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
32
|
+
const EOL = '\n';
|
|
32
33
|
const RE_HTML_ATTR = /<html[^>]*>/;
|
|
33
34
|
const RE_BODY_ATTR = /<body[^>]*>/;
|
|
34
35
|
const RE_LAST_IN_HEAD = /<\/head>/;
|
|
35
36
|
const RE_TITLE = /<title[^>]*>([\s\S\n\r]*?)<\/title>/;
|
|
36
37
|
const TEST_TITLE_CONTENT = /(?<=<title[^>]*>)([\s\S\n\r]*?)([.|\S])([\s\S\n\r]*?)(?=<\/title>)/;
|
|
38
|
+
function getHelmetData(runtimeContext) {
|
|
39
|
+
return runtimeContext._helmetContext?.helmet ?? void 0;
|
|
40
|
+
}
|
|
37
41
|
function createReplaceHelemt(helmetData) {
|
|
38
42
|
return helmetData ? (template)=>helmetReplace(template, helmetData) : (tempalte)=>tempalte;
|
|
39
43
|
}
|
|
@@ -61,13 +65,15 @@ function helmetReplace(content, helmetData) {
|
|
|
61
65
|
script,
|
|
62
66
|
style,
|
|
63
67
|
!existTitleTag ? title : ''
|
|
64
|
-
].reduce((pre, cur)=>pre + (cur.length > 0 ? ` ${cur}${
|
|
68
|
+
].reduce((pre, cur)=>pre + (cur.length > 0 ? ` ${cur}${EOL}` : ''), '');
|
|
65
69
|
return (0, external_utils_js_namespaceObject.safeReplace)(result, RE_LAST_IN_HEAD, `${helmetStr}</head>`);
|
|
66
70
|
}
|
|
67
71
|
exports.createReplaceHelemt = __webpack_exports__.createReplaceHelemt;
|
|
72
|
+
exports.getHelmetData = __webpack_exports__.getHelmetData;
|
|
68
73
|
exports.helmetReplace = __webpack_exports__.helmetReplace;
|
|
69
74
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
70
75
|
"createReplaceHelemt",
|
|
76
|
+
"getHelmetData",
|
|
71
77
|
"helmetReplace"
|
|
72
78
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
73
79
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -50,12 +50,15 @@ function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
|
50
50
|
if (!routeManifest) return template;
|
|
51
51
|
const { routeAssets } = routeManifest;
|
|
52
52
|
if (!routeAssets) return template;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
const matchedRouteIds = (0, lifecycle_js_namespaceObject.getRouterMatchedRouteIds)(runtimeContext) ?? [];
|
|
54
|
+
const assetEntries = [
|
|
55
|
+
...matchedRouteIds.map((routeId)=>routeAssets[routeId]),
|
|
56
|
+
routeAssets[`async-${entryName}`]
|
|
57
|
+
].filter(Boolean);
|
|
58
|
+
const jsAssets = Array.from(new Set(assetEntries.flatMap((entry)=>(entry.assets ?? []).filter((asset)=>asset.endsWith('.js')))));
|
|
59
|
+
const nonceAttr = nonce ? ` nonce="${nonce}"` : '';
|
|
60
|
+
const jsChunkStr = jsAssets.filter((asset)=>!template.includes(asset)).map((asset)=>`<script src=${asset}${nonceAttr}></script>`).join(' ');
|
|
61
|
+
if (jsChunkStr) return (0, external_utils_js_namespaceObject.safeReplace)(template, '<!--<?- chunksMap.js ?>-->', jsChunkStr);
|
|
59
62
|
return template;
|
|
60
63
|
}
|
|
61
64
|
return (0, external_shared_js_namespaceObject.buildHtml)(afterAppTemplate, callbacks);
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
3
|
(()=>{
|
|
13
4
|
__webpack_require__.d = (exports1, definition)=>{
|
|
14
5
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -36,10 +27,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
27
|
buildShellBeforeTemplate: ()=>buildShellBeforeTemplate
|
|
37
28
|
});
|
|
38
29
|
const router_namespaceObject = require("@modern-js/runtime-utils/router");
|
|
39
|
-
const external_react_helmet_namespaceObject = require("react-helmet");
|
|
40
|
-
var external_react_helmet_default = /*#__PURE__*/ __webpack_require__.n(external_react_helmet_namespaceObject);
|
|
41
30
|
const lifecycle_js_namespaceObject = require("../../../router/runtime/lifecycle.js");
|
|
42
31
|
const external_constants_js_namespaceObject = require("../constants.js");
|
|
32
|
+
const external_federatedCss_js_namespaceObject = require("../federatedCss.js");
|
|
43
33
|
const external_helmet_js_namespaceObject = require("../helmet.js");
|
|
44
34
|
const external_shared_js_namespaceObject = require("../shared.js");
|
|
45
35
|
const external_utils_js_namespaceObject = require("../utils.js");
|
|
@@ -55,8 +45,8 @@ const checkIsInline = (chunk, enableInline)=>{
|
|
|
55
45
|
return Boolean(enableInline);
|
|
56
46
|
};
|
|
57
47
|
async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
58
|
-
const { config, runtimeContext, styledComponentsStyleTags, entryName } = options;
|
|
59
|
-
const helmetData =
|
|
48
|
+
const { config, runtimeContext, styledComponentsStyleTags, entryName, moduleFederationCssAssets } = options;
|
|
49
|
+
const helmetData = (0, external_helmet_js_namespaceObject.getHelmetData)(runtimeContext);
|
|
60
50
|
const callbacks = [
|
|
61
51
|
(0, external_helmet_js_namespaceObject.createReplaceHelemt)(helmetData),
|
|
62
52
|
(template)=>injectCss(template, entryName, styledComponentsStyleTags)
|
|
@@ -65,33 +55,36 @@ async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
|
65
55
|
async function injectCss(template, entryName, styledComponentsStyleTags) {
|
|
66
56
|
let css = await getCssChunks();
|
|
67
57
|
if (styledComponentsStyleTags) css += styledComponentsStyleTags;
|
|
58
|
+
css += (0, external_federatedCss_js_namespaceObject.createFederatedCssLinks)(moduleFederationCssAssets, {
|
|
59
|
+
template,
|
|
60
|
+
existingAssets: css.match(/href="([^"]+)"/g)?.map((item)=>item.replace(/^href="/, '').replace(/"$/, ''))
|
|
61
|
+
});
|
|
68
62
|
return (0, external_utils_js_namespaceObject.safeReplace)(template, external_constants_js_namespaceObject.CHUNK_CSS_PLACEHOLDER, css);
|
|
69
63
|
async function getCssChunks() {
|
|
70
64
|
const { routeManifest, routerContext, routes } = runtimeContext;
|
|
71
65
|
if (!routeManifest) return '';
|
|
72
66
|
const { routeAssets } = routeManifest;
|
|
73
|
-
let matchedRouteManifests;
|
|
67
|
+
let matchedRouteManifests = [];
|
|
74
68
|
const matchedRouteIds = (0, lifecycle_js_namespaceObject.getRouterMatchedRouteIds)(runtimeContext);
|
|
75
69
|
if (matchedRouteIds?.length) matchedRouteManifests = matchedRouteIds.map((routeId)=>routeAssets[routeId]).filter(Boolean);
|
|
76
|
-
else {
|
|
77
|
-
if (!routerContext || !routes) return '';
|
|
70
|
+
else if (routerContext && routes) {
|
|
78
71
|
const matches = (0, router_namespaceObject.matchRoutes)(routes, routerContext.location, routerContext.basename);
|
|
79
72
|
matchedRouteManifests = matches?.map((match, index)=>{
|
|
80
73
|
if (!index) return;
|
|
81
74
|
const routeId = match.route.id;
|
|
82
75
|
if (routeId) return routeAssets[routeId];
|
|
83
|
-
}).filter(Boolean);
|
|
76
|
+
}).filter(Boolean) ?? [];
|
|
84
77
|
}
|
|
85
78
|
const asyncEntry = routeAssets[`async-${entryName}`];
|
|
86
|
-
if (asyncEntry) matchedRouteManifests
|
|
87
|
-
const cssChunks = matchedRouteManifests
|
|
79
|
+
if (asyncEntry) matchedRouteManifests.push(asyncEntry);
|
|
80
|
+
const cssChunks = matchedRouteManifests.reduce((chunks, routeManifest)=>{
|
|
88
81
|
const { referenceCssAssets = [] } = routeManifest;
|
|
89
82
|
const _cssChunks = referenceCssAssets.filter((asset)=>asset?.endsWith('.css') && !template.includes(asset));
|
|
90
83
|
return [
|
|
91
84
|
...chunks,
|
|
92
85
|
..._cssChunks
|
|
93
86
|
];
|
|
94
|
-
}, [])
|
|
87
|
+
}, []);
|
|
95
88
|
const { inlineStyles } = config;
|
|
96
89
|
const styles = await Promise.all(cssChunks.map(async (chunk)=>{
|
|
97
90
|
const link = `<link href="${chunk}" rel="stylesheet" />`;
|