1 | /**
|
2 | * The global declaration is required of the typedoc documentation
|
3 | */
|
4 | declare global {
|
5 | interface Window {
|
6 | __BASENAME__: any;
|
7 | }
|
8 | }
|
9 |
|
10 | // this must be imported to allow async-functions within an AWS lambda environment
|
11 | // see: https://github.com/babel/babel/issues/5085
|
12 | import "@babel/polyfill";
|
13 |
|
14 | import React from 'react';
|
15 | import { hydrate } from 'react-dom';
|
16 | import { createClientApp } from './routed-app';
|
17 | import Types from '../src/types';
|
18 | import { extractObject, INFRASTRUCTURE_MODES, loadConfigurationFromModule } from '../src/libs/loader';
|
19 |
|
20 |
|
21 | /**
|
22 | *
|
23 | * this module must not import anything that does not exist in web-mode, e.g. fs
|
24 | *
|
25 | * Creates the main Client WebApp. The `./src/client/index.tsx` module exports the result of calling this function
|
26 | * This serves as Entry-Point specified in the [[webpackConfigClient]]
|
27 | *
|
28 | * This function takes the data that is generated from the server endpoint
|
29 | */
|
30 | const createClientWebApp = () => {
|
31 |
|
32 | var basename: string = "";
|
33 | if (typeof window != 'undefined' && window.__BASENAME__) {
|
34 | basename = window.__BASENAME__;
|
35 | delete window.__BASENAME__;
|
36 | }
|
37 |
|
38 | // load the IsomorphicComponent
|
39 | // we must load it directly from the module here, to enable the aliad of the config_file_path
|
40 | const isoConfig = loadConfigurationFromModule(require('__CONFIG_FILE_PATH__'), INFRASTRUCTURE_MODES.RUNTIME);
|
41 |
|
42 | // let's extract it from the root configuration
|
43 | const webApp = extractObject(
|
44 | isoConfig,
|
45 | Types.INFRASTRUCTURE_TYPE_CLIENT,
|
46 | __ISOMORPHIC_ID__
|
47 | )
|
48 |
|
49 |
|
50 | // TODO!!!!
|
51 | //const clientApp = IsoConfig.isoConfig.clientApps["INDEX_OF_CLIENT"];
|
52 |
|
53 | /*const hydrateFromDataLayer = clientApp.dataLayer !== undefined ?
|
54 | clientApp.dataLayer.type({infrastructureMode: "component"}).hydrateFromDataLayer :
|
55 | (node) => {
|
56 | console.log("this is the dummy data layer hydration")
|
57 | return node;
|
58 | }*/
|
59 |
|
60 | hydrate(//hydrateFromDataLayer(
|
61 | createClientApp(
|
62 | webApp.routes,
|
63 | webApp.redirects,
|
64 | basename),//),
|
65 | document.getElementById('root')
|
66 | );
|
67 |
|
68 |
|
69 | };
|
70 |
|
71 | // this module MUST NOT export anything else. Because it would also load the default, which would be executed right away
|
72 | export default createClientWebApp(); |
\ | No newline at end of file |