Web: Doceditor: fix after merge, added bootstarp client

This commit is contained in:
Artem Tarasov 2022-05-03 23:26:05 +03:00
parent 049b4461d8
commit afcda9b556
4 changed files with 62 additions and 66 deletions

View File

@ -0,0 +1,56 @@
import React, { Suspense } from "react";
import { hydrate } from "react-dom";
import { registerSW } from "@appserver/common/sw/helper";
import App from "../App.js";
import { useSSR } from "react-i18next";
import useMfScripts from "../helpers/useMfScripts";
import initDesktop from "../helpers/initDesktop";
import { AppServerConfig } from "@appserver/common/constants";
import { combineUrl } from "@appserver/common/utils";
import ErrorBoundary from "../components/ErrorBoundary";
const propsObj = window.__ASC_INITIAL_STATE__;
const initialI18nStore = window.initialI18nStore;
const initialLanguage = window.initialLanguage;
delete window.__ASC_INITIAL_STATE__;
delete window.initialI18nStore;
delete window.initialLanguage;
const stateInit = document.getElementById("__ASC_INITIAL_STATE__");
const i18nInit = document.getElementById("__ASC_I18N_INIT__");
stateInit.parentNode.removeChild(stateInit);
i18nInit.parentNode.removeChild(i18nInit);
const isDesktopEditor = window["AscDesktopEditor"] !== undefined;
const AppWrapper = () => {
const [isInitialized, isErrorLoading] = useMfScripts();
useSSR(initialI18nStore, initialLanguage);
const onError = () =>
window.open(
combineUrl(
AppServerConfig.proxyURL,
propsObj.personal ? "sign-in" : "/login"
),
"_self"
);
return (
<ErrorBoundary onError={onError}>
<Suspense fallback={<div />}>
<App
{...propsObj}
mfReady={isInitialized}
mfFailed={isErrorLoading}
isDesktopEditor={isDesktopEditor}
initDesktop={initDesktop}
/>
</Suspense>
</ErrorBoundary>
);
};
hydrate(<AppWrapper />, document.getElementById("root"));
registerSW();

View File

@ -1,56 +1 @@
import React, { Suspense } from "react";
import { hydrate } from "react-dom";
import { registerSW } from "@appserver/common/sw/helper";
import App from "../App.js";
import { useSSR } from "react-i18next";
import useMfScripts from "../helpers/useMfScripts";
import initDesktop from "../helpers/initDesktop";
import { AppServerConfig } from "@appserver/common/constants";
import { combineUrl } from "@appserver/common/utils";
import ErrorBoundary from "../components/ErrorBoundary";
const propsObj = window.__ASC_INITIAL_STATE__;
const initialI18nStore = window.initialI18nStore;
const initialLanguage = window.initialLanguage;
delete window.__ASC_INITIAL_STATE__;
delete window.initialI18nStore;
delete window.initialLanguage;
const stateInit = document.getElementById("__ASC_INITIAL_STATE__");
const i18nInit = document.getElementById("__ASC_I18N_INIT__");
stateInit.parentNode.removeChild(stateInit);
i18nInit.parentNode.removeChild(i18nInit);
const isDesktopEditor = window["AscDesktopEditor"] !== undefined;
const AppWrapper = () => {
const [isInitialized, isErrorLoading] = useMfScripts();
useSSR(initialI18nStore, initialLanguage);
const onError = () =>
window.open(
combineUrl(
AppServerConfig.proxyURL,
propsObj.personal ? "sign-in" : "/login"
),
"_self"
);
return (
<ErrorBoundary onError={onError}>
<Suspense fallback={<div />}>
<App
{...propsObj}
mfReady={isInitialized}
mfFailed={isErrorLoading}
isDesktopEditor={isDesktopEditor}
initDesktop={initDesktop}
/>
</Suspense>
</ErrorBoundary>
);
};
hydrate(<AppWrapper />, document.getElementById("root"));
registerSW();
import("./bootstrap");

View File

@ -8,6 +8,7 @@ const clientConfig = {
devtool: false,
optimization: {
splitChunks: { chunks: "all" },
minimize: true,
minimizer: [new TerserPlugin()],
},

View File

@ -15,15 +15,9 @@ const deps = pkg.dependencies || {};
const BUILD_DIR = path.resolve(process.cwd(), "dist");
const getDeps = () => {
for (dep in sharedDeps) {
sharedDeps[dep].eager = true;
}
return {
...deps,
...sharedDeps,
};
};
const clientBaseConfig = {
target: "web",
@ -99,7 +93,7 @@ const clientBaseConfig = {
exposes: {
"./app": "./src/client/index.js",
},
shared: getDeps(),
shared: { ...sharedDeps },
}),
new ExternalTemplateRemotesPlugin(),
new CopyPlugin({