當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript module-map-ngfactory-loader.provideModuleMap函數代碼示例

本文整理匯總了TypeScript中@nguniversal/module-map-ngfactory-loader.provideModuleMap函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript provideModuleMap函數的具體用法?TypeScript provideModuleMap怎麽用?TypeScript provideModuleMap使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了provideModuleMap函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: renderModuleFactory

 prom = prom.then(_ => renderModuleFactory(AppServerModuleNgFactory, {
   document: index,
   url: route,
   extraProviders: [
     provideModuleMap(LAZY_MODULE_MAP)
   ]
 })).then(html => writeFileSync(join(BROWSER_FOLDER, route, 'index.html'), html));
開發者ID:sebastienbarbier,項目名稱:sebastienbarbier.com,代碼行數:7,代碼來源:prerender.ts

示例2: renderModuleFactory

 previousRender = previousRender.then(_ => renderModuleFactory(AppServerModuleNgFactory, {
   document: index,
   url: route,
   extraProviders: [
     provideModuleMap(LAZY_MODULE_MAP)
   ]
 })).then(html => writeFileSync(join(fullPath, 'index.html'), html));
開發者ID:nacardin,項目名稱:monicawulaw-website,代碼行數:7,代碼來源:prerender.ts

示例3: renderModuleFactory

app.engine('html', (_: any, options: any, callback: any) => {
  renderModuleFactory(AppServerModuleNgFactory, {
    document: template,
    url: options.req.url,
    extraProviders: [
      provideModuleMap(LAZY_MODULE_MAP)
    ]
  }).then(html => {
    callback(null, html);
  });
});
開發者ID:mightymoose,項目名稱:mmoaig,代碼行數:11,代碼來源:server.ts

示例4: renderModuleFactory

app.engine('html', (_, options, callback) => {
  renderModuleFactory(AppServerModuleNgFactory, {
    // Our index.html
    document: template,
    url: options.req.url,
    // DI so that we can get lazy-loading to work differently (since we need it to just instantly render it)
    extraProviders: [provideModuleMap(LAZY_MODULE_MAP)]
  }).then(html => {
    callback(null, html);
  });
});
開發者ID:garlictech,項目名稱:generator-garlic-webapp,代碼行數:11,代碼來源:server.ts

示例5: engine

app.get('**', (req, res) => {
  const url: string = req.path;
  engine(url, {
    req,
    res,
    url,
    document,
    bootstrap: AppServerModuleNgFactory,
    providers: [
      provideModuleMap(LAZY_MODULE_MAP)
    ]
  }, (err?: Error, html: string = 'oops') => {
    res.set('Cache-Control', 'public, max-age=3600, s-maxage=43200');
    res.send((err) ? err.message : html);
  });
});
開發者ID:MichaelSolati,項目名稱:ng-portfolio,代碼行數:16,代碼來源:ssr.ts

示例6: createServerRenderer

export default createServerRenderer(params => {
  const { AppServerModule, AppServerModuleNgFactory, LAZY_MODULE_MAP } = (module as any).exports;
 
  const options = {
    document: params.data.originalHtml,
    url: params.url,
    extraProviders: [
      provideModuleMap(LAZY_MODULE_MAP),
      { provide: APP_BASE_HREF, useValue: params.baseUrl },
      { provide: 'BASE_URL', useValue: params.origin + params.baseUrl }
    ]
  };

  const renderPromise = AppServerModuleNgFactory
    ? /* AoT */ renderModuleFactory(AppServerModuleNgFactory, options)
    : /* dev */ renderModule(AppServerModule, options);
    
  return renderPromise.then(html => ({ html }));
});
開發者ID:jasebanico,項目名稱:banico,代碼行數:19,代碼來源:main.server.ts

示例7: renderModuleFactory

app.engine('html', (_, options, callback) => {
  renderModuleFactory(AppServerModuleNgFactory, {
    // Our index.html
    document: template,
    url: options.req.url,
    
    // configure DI to make lazy-loading work differently
    // (we need to instantly render the view)
    extraProviders: [
      provideModuleMap(LAZY_MODULE_MAP),
      {
          provide: REQUEST,
          useValue: options.req
      },
      {
          provide: RESPONSE,
          useValue: options.req.res,
      },
    ]
  }).then(html => {
    callback(null, html);
  });
});
開發者ID:usnistgov,項目名稱:oar-pdr,代碼行數:23,代碼來源:server.ts

示例8: readFileSync

// Our index.html we'll use as our template
const template = readFileSync(join(DIST_FOLDER, 'browser', 'index.html')).toString();

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main.bundle');

// Express Engine
import { ngExpressEngine } from '@nguniversal/express-engine';
// Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';

// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
app.engine('html', ngExpressEngine({
  bootstrap: AppServerModuleNgFactory,
  providers: [
    provideModuleMap(LAZY_MODULE_MAP)
  ]
}));

app.set('view engine', 'html');
app.set('views', join(DIST_FOLDER, 'browser'));

/* - Example Express Rest API endpoints -
  app.get('/api/**', (req, res) => { });
*/

// Server static files from /browser
app.get('*.*', express.static(join(DIST_FOLDER, 'browser'), {
  maxAge: '1y'
}));
開發者ID:MarkPieszak,項目名稱:universal-starter,代碼行數:30,代碼來源:server.ts

示例9: require

// Load zone.js for the server.
import 'zone.js/dist/zone-node';
import 'reflect-metadata';
import { readFileSync, writeFileSync } from 'fs';
import { join } from 'path';

// Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';

import { renderModuleFactory } from '@angular/platform-server';

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./server/main');

// Load the index.html file containing referances to your application bundle.
const index = readFileSync(join('browser', 'index.html'), 'utf8');

// Writes rendered HTML to ./dist/index.html, replacing the file if it already exists.
renderModuleFactory(AppServerModuleNgFactory, {
  document: index,
  url: '/',
  extraProviders: [provideModuleMap(LAZY_MODULE_MAP)]
}).then(html => writeFileSync(join('browser', 'index.html'), html));
開發者ID:sumanbh,項目名稱:amazon-clone,代碼行數:23,代碼來源:prerender.ts

示例10: renderModuleFactory

 .then((_) =>
   renderModuleFactory(AppServerModuleNgFactory, {
     document: index,
     url: route,
     extraProviders: [provideModuleMap(LAZY_MODULE_MAP)]
   })
開發者ID:k3nsei,項目名稱:angular2-in-viewport,代碼行數:6,代碼來源:prerender.ts


注:本文中的@nguniversal/module-map-ngfactory-loader.provideModuleMap函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。