UNPKG

1.47 kBTypeScriptView Raw
1declare var __ISOMORPHIC_ID__: any;
2
3import React from 'react';
4import ReactDOM from 'react-dom';
5import { extractObject, INFRASTRUCTURE_MODES, loadConfigurationFromModule } from '../libs/loader';
6
7import { createSinglePageApp } from './routed-app';
8import Types from '../types';
9import { renderFromDataLayer } from './datalayer-integration';
10
11/**
12 * this module must not import anything that does not exist in web-mode, e.g. fs
13 */
14const createApp = () => {
15
16 // load the IsomorphicComponent
17 // we must load it directly from the module here, to enable the aliad of the config_file_path
18 const soaConfig = loadConfigurationFromModule(require('__CONFIG_FILE_PATH__'), INFRASTRUCTURE_MODES.RUNTIME);
19
20 // function to create the client-side app with
21 const fCreateApp = soaConfig.dataLayerId !== undefined ? (node) => renderFromDataLayer(
22 node,
23 extractObject(
24 soaConfig,
25 Types.INFRASTRUCTURE_TYPE_COMPONENT,
26 soaConfig.dataLayerId
27 )
28 ) : (node) => {
29 console.log("no data layer present");
30 return node;
31 };
32
33 ReactDOM.render(
34 fCreateApp(
35 createSinglePageApp(
36 soaConfig.routes,
37 soaConfig.redirects
38 )
39 ),
40 document.getElementById('root')
41 );
42
43};
44
45// this module MUST NOT export anything else. Because it would also load the default, which would be executed right away
46export default createApp();
\No newline at end of file