refactor(core): split web entry from core (#6082)

This pr is trying to split `web` and `electron` entries from `core`. It allows more platform-related optimization to be addressed in each entry.
We should remove all browser/electron only codes from `core` eventually, this is the very first step for that.
This commit is contained in:
LongYinan
2024-03-19 07:48:56 +00:00
parent 26925c96e4
commit 332cd3b380
54 changed files with 963 additions and 800 deletions
+45
View File
@@ -0,0 +1,45 @@
import './polyfill/intl-segmenter';
import './polyfill/request-idle-callback';
import './polyfill/resize-observer';
import { setup } from '@affine/core/bootstrap/setup';
import { performanceLogger } from '@affine/core/shared';
import { isDesktop } from '@affine/env/constant';
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { App } from './app';
const performanceMainLogger = performanceLogger.namespace('main');
function main() {
performanceMainLogger.info('start');
// skip bootstrap setup for desktop onboarding
if (isDesktop && window.appInfo?.windowName === 'onboarding') {
performanceMainLogger.info('skip setup');
} else {
performanceMainLogger.info('setup start');
setup();
performanceMainLogger.info('setup done');
}
mountApp();
}
function mountApp() {
performanceMainLogger.info('import app');
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const root = document.getElementById('app')!;
performanceMainLogger.info('render app');
createRoot(root).render(
<StrictMode>
<App />
</StrictMode>
);
}
try {
main();
} catch (err) {
console.error('Failed to bootstrap app', err);
}