UNPKG

infrastructure-components

Version:

Infrastructure-Components configure the infrastructure of your React-App as part of your React-Components.

39 lines 1.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const isolib_1 = require("../isolib"); // this must be imported to allow async-functions within an AWS lambda environment // see: https://github.com/babel/babel/issues/5085 require("@babel/polyfill"); const react_dom_1 = require("react-dom"); const routed_app_1 = require("./routed-app"); /** * For a not yet known reason (maybe because compiled on "web"), this module must not import anything * that does not exist in web-mode, e.g. fs * * Creates the main Client WebApp. The `./src/client/index.tsx` module exports the result of calling this function * This serves as Entry-Point specified in the [[webpackConfigClient]] * * This function takes the data that is generated from the server endpoint */ const createClientWebApp = () => { var basename = ""; if (typeof window != 'undefined' && window.__BASENAME__) { basename = window.__BASENAME__; delete window.__BASENAME__; } var IsoConfig = require('IsoConfig'); if (IsoConfig && IsoConfig.default && IsoConfig.default.props) { IsoConfig = isolib_1.loadIsoConfigFromComponent(IsoConfig.default, false); } const clientApp = IsoConfig.isoConfig.clientApps["INDEX_OF_CLIENT"]; const hydrateFromDataLayer = clientApp.dataLayer !== undefined ? clientApp.dataLayer.type({ infrastructureMode: "component" }).hydrateFromDataLayer : (node) => { console.log("this is the dummy data layer hydration"); return node; }; react_dom_1.hydrate(hydrateFromDataLayer(routed_app_1.createClientApp(clientApp.routes, clientApp.redirects, basename)), document.getElementById('root')); }; // this module MUST NOT export anything else. Because it would also load the default, which would be executed right away exports.default = createClientWebApp(); //# sourceMappingURL=client.js.map