-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathmain.tsx
More file actions
47 lines (41 loc) · 1.3 KB
/
main.tsx
File metadata and controls
47 lines (41 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React, { lazy, Suspense } from 'react';
import ReactDOM from 'react-dom/client';
import * as Sentry from '@sentry/react';
Sentry.init({
dsn: import.meta.env.PUBLIC_E2E_TEST_DSN,
environment: import.meta.env.MODE || 'development',
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 1.0,
tunnel: 'http://localhost:3031/',
});
// Workaround: propagate MFE identity from current scope to span attributes
const client = Sentry.getClient()!;
client.on('spanStart', span => {
const mfeName = Sentry.getCurrentScope().getScopeData().tags['mfe.name'];
if (typeof mfeName === 'string') {
span.setAttribute('mfe.name', mfeName);
}
});
// Load MFEs via Module Federation (React.lazy + dynamic import)
const MfeHeader = lazy(() => import('mfe_header/App'));
const MfeOne = lazy(() => import('mfe_one/App'));
function App() {
return (
<div id="app">
<h1>Shell</h1>
<Suspense fallback={<div>Loading header...</div>}>
<MfeHeader />
</Suspense>
<Suspense fallback={<div>Loading mfe-one...</div>}>
<MfeOne />
</Suspense>
</div>
);
}
// Shell's own fetch — no MFE scope
fetch('http://localhost:6969/api/shell-config');
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);