I am working on an angular application with Angular CLI 11.0.2 and I am using hammerJS in my application to handle the swipe events.
When I compile the application, I have the following warning message:
Warning: F:\Programs\GoodRiddles\git\angular\src\app\config\hammerjs.config.ts depends on 'hammerjs'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
From what I could understand here, I should replace hammerJS by an ECMA version of the library.
My question is: Is there a proper way (without simply hiding the message) to fix it? Do I need to use another library instead?
If it can help, this is how I use it:
import { Injectable } from '@angular/core';
import { HammerGestureConfig } from "@angular/platform-browser";
import * as hammer from "hammerjs";
@Injectable()
export class HammerConfig extends HammerGestureConfig {
overrides = <any>{
swipe: { direction: hammer.DIRECTION_HORIZONTAL },
pinch: { enable: false },
rotate: { enable: false }
};
}
Add Hammerjs to allowedCommonJsDependencies in your angular.json
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"allowedCommonJsDependencies": [
"hammerjs" <== here
],...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With