How to use the fusion-core.RoutePrefixToken.optional function in fusion-core

To help you get started, we’ve selected a few fusion-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fusionjs / fusionjs / fusion-cli / entries / client-entry.js View on Github external
Promise.resolve(initialize()).then(app => {
    if (!(app instanceof BaseApp)) {
      throw new Error('Application entry point did not return an App');
    }
    if (window.__ROUTE_PREFIX__) {
      // No-op plugin so token can be registered without any consumers
      // Should not be needed when route prefixing is refactored into a separate plugin
      app.register(
        createPlugin({
          deps: {routePrefix: RoutePrefixToken.optional},
        })
      );
      app.register(RoutePrefixToken, window.__ROUTE_PREFIX__);
    }
    app.callback().call();
  });
}
github fusionjs / fusion-cli / plugins / ssr-plugin.js View on Github external
chunks,
  runtimeChunkIds,
  initialChunkIds, // $FlowFixMe
} from '../build/loaders/chunk-manifest-loader.js!'; // eslint-disable-line

/*::
import type {SSRBodyTemplateDepsType, SSRBodyTemplateType} from './types.js';
declare var __webpack_public_path__: string;
*/

/* eslint-disable-next-line */
const SSRBodyTemplate = createPlugin/*::  */(
  {
    deps: {
      criticalChunkIds: CriticalChunkIdsToken.optional,
      routePrefix: RoutePrefixToken.optional,
    },
    provides: ({criticalChunkIds, routePrefix}) => {
      return ctx => {
        const {htmlAttrs, bodyAttrs, title, head, body} = ctx.template;
        const safeAttrs = Object.keys(htmlAttrs)
          .map(attrKey => {
            return ` ${escape(attrKey)}="${escape(htmlAttrs[attrKey])}"`;
          })
          .join('');

        const safeBodyAttrs = Object.keys(bodyAttrs)
          .map(attrKey => {
            return ` ${escape(attrKey)}="${escape(bodyAttrs[attrKey])}"`;
          })
          .join('');
github fusionjs / fusionjs / fusion-cli / plugins / ssr-plugin.js View on Github external
initialChunkIds, // $FlowFixMe
} from '../build/loaders/chunk-manifest-loader.js!'; // eslint-disable-line

import modernBrowserVersions from '../build/modern-browser-versions.js';

/*::
import type {SSRBodyTemplateDepsType, SSRBodyTemplateType} from './types.js';
declare var __webpack_public_path__: string;
*/

/* eslint-disable-next-line */
const SSRBodyTemplate = createPlugin/*::  */(
  {
    deps: {
      criticalChunkIds: CriticalChunkIdsToken.optional,
      routePrefix: RoutePrefixToken.optional,
    },
    provides: ({criticalChunkIds, routePrefix}) => {
      return ctx => {
        const {htmlAttrs, bodyAttrs, title, head, body} = ctx.template;
        const safeAttrs = Object.keys(htmlAttrs)
          .map(attrKey => {
            return ` ${escape(attrKey)}="${escape(htmlAttrs[attrKey])}"`;
          })
          .join('');

        const safeBodyAttrs = Object.keys(bodyAttrs)
          .map(attrKey => {
            return ` ${escape(attrKey)}="${escape(bodyAttrs[attrKey])}"`;
          })
          .join('');