Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
Los componentes compartidos no se procesan en SSR desde la aplicación host

Tuve un problema cuando usé SSR con la federación de módulos. Mi ejemplo con código

Cómo empezar

  • instalación de hilo: todo
  • shell de hilo: servidor: construir
  • shell de hilo: servidor: inicio
  • control remoto de hilo: inicio

Tengo dos aplicaciones diferentes, una de ellas es una aplicación Host con SSR y lógica para los componentes de procesamiento, la segunda es como una biblioteca compartida con componentes. Configuré ng-universal en la aplicación host y quiero ver el código completo en respuesta cuando se carga la página, pero solo obtuve el código de la aplicación host. Captura de pantalla de mi respuesta Ese código me da la oportunidad de obtener componentes de remoteEntry.js

 import { LoadRemoteModuleOptions } from '../interfaces/module-federation.interfaces'; type Scope = unknown; type Factory = () => any; type Container = { init(shareScope: Scope, initScope?: Scope): void; get(module: string, getScope?: Scope): Promise<Factory>; }; const createContainer = (name: string): Container => { // @ts-ignore const container = window[name] as Container; return container } ; declare const __webpack_init_sharing__: (shareScope: string) => Promise<void>; declare const __webpack_share_scopes__: { default: Scope, plugin: Scope }; const moduleMap: any = {}; export function loadRemoteEntry(remoteEntry: string): Promise<boolean> { return new Promise<any>((resolve, reject) => { if (moduleMap[remoteEntry]) { resolve(moduleMap[remoteEntry]); return; } const script = document.createElement('script'); script.src = remoteEntry; script.onerror = reject; script.onload = () => { moduleMap[remoteEntry] = true; resolve(moduleMap[remoteEntry]); // window is the global namespace }; document.body.appendChild(script); }); } async function lookupExposedRemote<T>( remoteName: string, exposedModule: string ): Promise<T> { // Initializes the share scope. This fills it with known provided modules from this build and all remotes await __webpack_init_sharing__('default'); // @ts-ignore // @ts-ignore const container = createContainer(remoteName); if (!container) {throw new Error('Container with script is not defined')} await container.init(__webpack_share_scopes__.default); const factory = await container.get(exposedModule); const Module = factory(); return Module as T; } export async function loadRemoteModule( options: LoadRemoteModuleOptions ): Promise<any> { await loadRemoteEntry(options.remoteEntry); return await lookupExposedRemote<any>( options.remoteName, options.exposedModule ); }

Creo que es un problema porque no tengo una ventana de objetos en el lado del servidor, pero uso Domino para eso. Quizás alguien me pueda ayudar, se lo agradecería.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Problema fue resuelto. Simplemente cree una aplicación remota e iníciela con un servidor ligero. Se actualizó el repositorio. Úsalo si lo necesitas. https://i.imgur.com/pkyTEsQ.png

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!