infrastructure-components
Version:
Infrastructure-Components configure the infrastructure of your React-App as part of your React-Components.
47 lines • 2.3 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// 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");
const types_1 = __importDefault(require("../types"));
const loader_1 = require("../libs/loader");
/**
*
* 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__;
}
// load the IsomorphicComponent
// we must load it directly from the module here, to enable the aliad of the config_file_path
const isoConfig = loader_1.loadConfigurationFromModule(require('__CONFIG_FILE_PATH__'), loader_1.INFRASTRUCTURE_MODES.RUNTIME);
// let's extract it from the root configuration
const webApp = loader_1.extractObject(isoConfig, types_1.default.INFRASTRUCTURE_TYPE_CLIENT, __ISOMORPHIC_ID__);
// TODO!!!!
//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(webApp.routes, webApp.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