Skip to content

Commit

Permalink
Standalone migration - standalone bootstrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsongutidev committed Sep 21, 2023
1 parent 7099667 commit fe51847
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 63 deletions.
14 changes: 9 additions & 5 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { Component, ViewEncapsulation, AfterViewInit, ChangeDetectorRef } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { Router, NavigationEnd, RouterOutlet } from '@angular/router';
import { environment } from '../environments/environment';
import { ProjectQuery } from './project/state/project/project.query';
import { ProjectService } from './project/state/project/project.service';
import { GoogleAnalyticsService } from './core/services/google-analytics.service';
import { AsyncPipe } from '@angular/common';
import { NzSpinModule } from 'ng-zorro-antd/spin';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
encapsulation: ViewEncapsulation.None,
standalone: true,
imports: [NzSpinModule, RouterOutlet, AsyncPipe]
})
export class AppComponent implements AfterViewInit {
constructor(
Expand Down
54 changes: 0 additions & 54 deletions src/app/app.module.ts

This file was deleted.

44 changes: 40 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import { enableProdMode } from '@angular/core';
import { enableProdMode, ErrorHandler, APP_INITIALIZER, importProvidersFrom } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import * as Sentry from '@sentry/angular';
import { Integrations } from '@sentry/tracing';
import { AppModule } from './app/app.module';

import { environment } from './environments/environment';
import { AppComponent } from './app/app.component';
import { QuillModule } from 'ngx-quill';
import { AkitaNgRouterStoreModule } from '@datorama/akita-ng-router-store';
import { AkitaNgDevtools } from '@datorama/akita-ngdevtools';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzSpinModule } from 'ng-zorro-antd/spin';
import { AppRoutingModule } from './app/app-routing.module';
import { withInterceptorsFromDi, provideHttpClient } from '@angular/common/http';
import { ReactiveFormsModule } from '@angular/forms';
import { provideAnimations } from '@angular/platform-browser/animations';
import { BrowserModule, bootstrapApplication } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { NG_ENTITY_SERVICE_CONFIG } from '@datorama/akita-ng-entity-service';

const initSentry = () => {
Sentry.init({
Expand All @@ -25,6 +38,29 @@ if (environment.production) {
initSentry();
}

platformBrowserDynamic()
.bootstrapModule(AppModule)
bootstrapApplication(AppComponent, {
providers: [
importProvidersFrom(BrowserModule, ReactiveFormsModule, AppRoutingModule, NzSpinModule, NzIconModule.forRoot([]), environment.production ? [] : AkitaNgDevtools, AkitaNgRouterStoreModule, QuillModule.forRoot()),
{
provide: NG_ENTITY_SERVICE_CONFIG,
useValue: { baseUrl: 'https://jsonplaceholder.typicode.com' }
},
{
provide: ErrorHandler,
useValue: Sentry.createErrorHandler()
},
{
provide: Sentry.TraceService,
deps: [Router],
},
{
provide: APP_INITIALIZER,
useFactory: () => () => { },
deps: [Sentry.TraceService],
multi: true,
},
provideAnimations(),
provideHttpClient(withInterceptorsFromDi())
]
})
.catch((err) => console.error(err));

0 comments on commit fe51847

Please sign in to comment.