feat(angular): use provideRouter for standalone remote apps (#18468)
This commit is contained in:
parent
e9d50af945
commit
64492ece8c
@ -252,19 +252,13 @@ module.exports = withModuleFederation(config);
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`MF Remote App Generator should generate the a remote setup for standalone components 1`] = `
|
exports[`MF Remote App Generator should generate the a remote setup for standalone components 1`] = `
|
||||||
"import { importProvidersFrom } from '@angular/core';
|
"import { bootstrapApplication } from '@angular/platform-browser';
|
||||||
import { bootstrapApplication } from '@angular/platform-browser';
|
import { appConfig } from './app/app.config';
|
||||||
import { RouterModule } from '@angular/router';
|
|
||||||
import { RemoteEntryComponent } from './app/remote-entry/entry.component';
|
import { RemoteEntryComponent } from './app/remote-entry/entry.component';
|
||||||
import { appRoutes } from './app/app.routes';
|
|
||||||
|
|
||||||
bootstrapApplication(RemoteEntryComponent, {
|
bootstrapApplication(RemoteEntryComponent, appConfig).catch((err) =>
|
||||||
providers: [
|
console.error(err)
|
||||||
importProvidersFrom(
|
);
|
||||||
RouterModule.forRoot(appRoutes, { initialNavigation: 'enabledBlocking' })
|
|
||||||
),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@ -35,11 +35,9 @@ export function fixBootstrap(tree: Tree, appRoot: string, options: Schema) {
|
|||||||
|
|
||||||
const standaloneBootstrapCode = (
|
const standaloneBootstrapCode = (
|
||||||
includeEnvironments: boolean = false
|
includeEnvironments: boolean = false
|
||||||
) => `import {importProvidersFrom} from "@angular/core";
|
) => `import {bootstrapApplication} from "@angular/platform-browser";
|
||||||
import {bootstrapApplication} from "@angular/platform-browser";
|
import {appConfig} from './app/app.config';
|
||||||
import {RouterModule} from "@angular/router";
|
import {RemoteEntryComponent} from './app/remote-entry/entry.component';
|
||||||
import {RemoteEntryComponent} from "./app/remote-entry/entry.component";
|
|
||||||
import {appRoutes} from "./app/app.routes";
|
|
||||||
${
|
${
|
||||||
includeEnvironments
|
includeEnvironments
|
||||||
? `import {enableProdMode} from '@angular/core';
|
? `import {enableProdMode} from '@angular/core';
|
||||||
@ -50,10 +48,6 @@ if(environment.production) {
|
|||||||
`
|
`
|
||||||
: ``
|
: ``
|
||||||
}
|
}
|
||||||
bootstrapApplication(RemoteEntryComponent, {
|
bootstrapApplication(RemoteEntryComponent, appConfig).catch((err) =>
|
||||||
providers: [
|
console.error(err)
|
||||||
importProvidersFrom(
|
);`;
|
||||||
RouterModule.forRoot(appRoutes, {initialNavigation: 'enabledBlocking'})
|
|
||||||
)
|
|
||||||
]
|
|
||||||
});`;
|
|
||||||
|
|||||||
@ -357,24 +357,18 @@ describe('Init MF', () => {
|
|||||||
// ASSERT
|
// ASSERT
|
||||||
expect(tree.read('apps/ng14/src/bootstrap.ts', 'utf-8'))
|
expect(tree.read('apps/ng14/src/bootstrap.ts', 'utf-8'))
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
"import { importProvidersFrom } from '@angular/core';
|
"import { bootstrapApplication } from '@angular/platform-browser';
|
||||||
import { bootstrapApplication } from '@angular/platform-browser';
|
import { appConfig } from './app/app.config';
|
||||||
import { RouterModule } from '@angular/router';
|
|
||||||
import { RemoteEntryComponent } from './app/remote-entry/entry.component';
|
import { RemoteEntryComponent } from './app/remote-entry/entry.component';
|
||||||
import { appRoutes } from './app/app.routes';
|
|
||||||
import { enableProdMode } from '@angular/core';
|
import { enableProdMode } from '@angular/core';
|
||||||
import { environment } from './environments/environment';
|
import { environment } from './environments/environment';
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
enableProdMode();
|
enableProdMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrapApplication(RemoteEntryComponent, {
|
bootstrapApplication(RemoteEntryComponent, appConfig).catch((err) =>
|
||||||
providers: [
|
console.error(err)
|
||||||
importProvidersFrom(
|
);
|
||||||
RouterModule.forRoot(appRoutes, { initialNavigation: 'enabledBlocking' })
|
|
||||||
),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
"
|
"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user