infrastructure-components
Version:
Infrastructure-Components configure the infrastructure of your React-App as part of your React-Components.
53 lines • 2.14 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 route_component_1 = require("../route/route-component");
const libs_1 = require("../libs");
const spa_plugin_1 = require("./spa-plugin");
const environment_plugin_1 = require("../environment/environment-plugin");
exports.SINGLEPAGE_INSTANCE_TYPE = "SinglePageComponent";
/**
* The SinglePageApp is an infrastructure and must implement [[IInfrastructure]]
*
* @param props
*/
exports.default = (props) => {
const infProps = {
// allows to identify this component as Infrastructure
infrastructureType: types_1.default.INFRASTRUCTURE_TYPE_CONFIGURATION,
instanceId: props.stackName,
instanceType: exports.SINGLEPAGE_INSTANCE_TYPE,
// only load plugins during compilation
createPlugins: (configPath, stage, parserMode) => props.infrastructureMode === "COMPILATION" ? [
// be able to process IsomorphicApps (as top-level-node)
spa_plugin_1.SpaPlugin({
stage: stage,
parserMode: parserMode,
buildPath: props.buildPath,
configFilePath: configPath
}),
// Single Page apps can have different environments
environment_plugin_1.EnvironmentPlugin({
stage: stage,
parserMode: parserMode
}),
] : []
};
// TODO maybe edit to support the web-mode?!
const spaProps = {
id: props.stackName,
routes: libs_1.getChildrenArray(props.children)
.filter(child => route_component_1.isRoute(child)),
redirects: []
};
return Object.assign(props, infProps, spaProps);
};
function isSinglePageApp(component) {
return component !== undefined &&
component.instanceType === exports.SINGLEPAGE_INSTANCE_TYPE;
}
exports.isSinglePageApp = isSinglePageApp;
//# sourceMappingURL=spa-component.js.map
;