How to exclude browser modules from being built in Angular 5 Universal app
Date : March 29 2020, 07:55 AM
hope this fix your issue You can try and create a third module exclusively for the browser. This BrowserModule will include everything you need in your browser. import { NgModule } from '@angular/core';
import { AppModule} from './app.module';
import { AppComponent } from './app.component';
// other browser exlusive imports
@NgModule({
imports: [
// browser exlusive imports
AppModule
],
bootstrap: [AppComponent]
})
export class AppBrowserModule { }
babel ./node_modules/failingPackage -d ./node_modules/failingPackage --presets es2015
|
Problem executing Angular Universal with lodash-es as a dependency
Date : March 29 2020, 07:55 AM
hope this fix your issue I am converting my existing Angular project with an Express backend to Angular Universal. I am facing an error , There was an error in the webpack merge configuration. "customWebpackConfig": {
"path": "./universal-webpack.config.js",
"mergeStrategies": { "externals": "replace" }
}
|
Exclude component that breaks Angular Universal
Date : March 29 2020, 07:55 AM
To fix the issue you can do The fix is simple, you should use a PLATFORM_ID token together with the isPlatformBrowser or isPlatformServer method. Inside your template use the #ngIf statement: <section class="sec-space-b" id="banner" *ngIf="isBrowser">
import { isPlatformBrowser } from '@angular/common';
import { Component, OnInit, Inject, PLATFORM_ID } from '@angular/core';
@Component({
selector: 'app-home-banner',
templateUrl: './banner.component.html',
styleUrls: ['./banner.component.scss']
})
export class BannerComponent implements OnInit {
public isBrowser = isPlatformBrowser(this.platformId);
constructor(@Inject(PLATFORM_ID) private platformId: any) { }
}
|
NestJs : Angular Universal ReferenceError - KeyboardEvent is not defined
Date : March 29 2020, 07:55 AM
this will help Take a look at Universal Nest, specifically at the app.module.ts file of the server side (server dir). This file implements domino to handle DOM object on the server as you should know, those doesn't exist on the server as mentioned on the Angular documentation.
|
Critical dependency using MongoDB with Angular universal / webpack
Date : March 29 2020, 07:55 AM
Any of those help I had the same issue yesterday trying out angular universal starter with mongoose. First, I tried by using ContextReplacementPlugin webpack plugin like in webpack.server.config.js. new webpack.ContextReplacementPlugin(
// fixes WARNING Critical dependency: the request of a dependency is an expression
/(.+)?express(\\|\/)(.+)?/,
path.join(__dirname, 'src'),
{}
)
|