Skip to content

Commit

Permalink
feat(angular): use provideRouter for standalone apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Sep 14, 2022
1 parent d57e754 commit a344427
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ module.exports = withModuleFederation(config);"
`;

exports[`app --standalone should generate a standalone app correctly with routing 1`] = `
"import { enableProdMode, importProvidersFrom } from '@angular/core';
"import { enableProdMode} from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { provideRouter, withNonEnabledBlockingInitialNavigation } from '@angular/router';
import { AppComponent } from './app/app.component';
import { environment } from './environments/environment';
import { appRoutes } from './app/app.routes';
Expand All @@ -37,7 +37,7 @@ if (environment.production) {
}
bootstrapApplication(AppComponent, {
providers: [importProvidersFrom(RouterModule.forRoot(appRoutes, {initialNavigation: 'enabledBlocking'}))],
providers: [provideRouter(appRoutes, withEnabledBlockingInitialNavigation())],
}).catch((err) => console.error(err));"
`;

Expand Down Expand Up @@ -98,7 +98,7 @@ describe('AppComponent', () => {
`;
exports[`app --standalone should generate a standalone app correctly without routing 1`] = `
"import { enableProdMode } from '@angular/core';
"import { enableProdMode} from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';;
import { AppComponent } from './app/app.component';
import { environment } from './environments/environment';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ function updateMainEntrypoint(

const standaloneComponentMainContents = (
routerModuleSetup
) => `import { enableProdMode${
routerModuleSetup ? `, importProvidersFrom` : ``
} } from '@angular/core';
) => `import { enableProdMode} from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';${
routerModuleSetup
? `
import { RouterModule } from '@angular/router'`
import { provideRouter, withNonEnabledBlockingInitialNavigation } from '@angular/router'`
: ``
};
import { AppComponent } from './app/app.component';
Expand All @@ -65,7 +63,7 @@ if (environment.production) {
bootstrapApplication(AppComponent${
routerModuleSetup
? `, {
providers: [importProvidersFrom(${routerModuleSetup})],
providers: [provideRouter(appRoutes, withEnabledBlockingInitialNavigation())],
}`
: ''
}).catch((err) => console.error(err));`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ module.exports = withModuleFederation(config);"
`;

exports[`Host App Generator should generate a host with remotes using standalone components 1`] = `
"import { enableProdMode, importProvidersFrom } from '@angular/core';
"import { enableProdMode} from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { provideRouter, withNonEnabledBlockingInitialNavigation } from '@angular/router';
import { AppComponent } from './app/app.component';
import { environment } from './environments/environment';
import { appRoutes } from './app/app.routes';
Expand All @@ -31,7 +31,7 @@ if (environment.production) {
}
bootstrapApplication(AppComponent, {
providers: [importProvidersFrom(RouterModule.forRoot(appRoutes, {initialNavigation: 'enabledBlocking'}))],
providers: [provideRouter(appRoutes, withEnabledBlockingInitialNavigation())],
}).catch((err) => console.error(err));"
`;

Expand Down

0 comments on commit a344427

Please sign in to comment.