infrastructure-components
Version:
Infrastructure-Components configure the infrastructure of your React-App as part of your React-Components.
58 lines • 2.5 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = __importDefault(require("../types"));
const middleware_component_1 = require("../middleware/middleware-component");
const webapp_component_1 = require("../webapp/webapp-component");
const libs_1 = require("../libs");
const iso_plugin_1 = require("./iso-plugin");
const webapp_plugin_1 = require("../webapp/webapp-plugin");
const environment_plugin_1 = require("../environment/environment-plugin");
exports.ISOMORPHIC_INSTANCE_TYPE = "IsomorphicComponent";
/**
* The IsomorphicApp is an infrastructure and must implement [[IInfrastructure]]
*
* @param props
*/
exports.default = (props) => {
//console.log ("isomorphic: ",props );
const infProps = {
// allows to identify this component as Infrastructure
infrastructureType: types_1.default.INFRASTRUCTURE_TYPE_CONFIGURATION,
instanceId: props.stackName,
instanceType: exports.ISOMORPHIC_INSTANCE_TYPE,
// only load plugins during compilation
createPlugins: (configPath, stage, parserMode) => props.infrastructureMode === "COMPILATION" ? [
// be able to process IsomorphicApps (as top-level-node)
iso_plugin_1.IsoPlugin({
buildPath: props.buildPath,
configFilePath: configPath
}),
// isomorphic apps can have webapps (i.e. clients!)
webapp_plugin_1.WebAppPlugin({
buildPath: props.buildPath,
configFilePath: configPath
}),
// isomorphic apps can have different environments
environment_plugin_1.EnvironmentPlugin({
stage: stage,
parserMode: parserMode
})
] : []
};
const isoProps = {
middlewares: libs_1.getChildrenArray(props.children)
.filter(child => middleware_component_1.isMiddleware(child)),
webApps: libs_1.getChildrenArray(props.children)
.filter(child => webapp_component_1.isWebApp(child))
};
return Object.assign(props, infProps, isoProps);
};
function isIsomorphicApp(component) {
return component !== undefined &&
component.instanceType === exports.ISOMORPHIC_INSTANCE_TYPE;
}
exports.isIsomorphicApp = isIsomorphicApp;
//# sourceMappingURL=iso-component.js.map