-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: Angular Warning: CommonJS or AMD dependencies can cause optimization bailouts. #805
Comments
I have the same warning for IsPostalCode.js as well.
|
This warning raised for the We already provide all main package formats in our published package, so once validator does the same it will be auto-picked by Angular. |
I will go forward and close this as we have nothing to fix this. |
I don't think this is correct. According to validator.js github site they do provide tree-shakeable ES imports. You have to replace the import paths a little bit:
Then the WARNING should go away and projects using class-validator will be able to get optimized better. |
I had the same problem and, according to https://angular.io/guide/build#configuring-commonjs-dependencies, I added "validator" to "allowedCommonJsDependencies" inside my "angular.json" file:
This fixed the issue. |
As do we. The Angular compiler when building an app should pick up that both this lib and validator.js has ES exports and use that version. We explicitly tell the bundlers which versions we support in Closing again as I still believe this is a problem with the configuration of https://github.com/validatorjs/validator.js/. Feel free to open an issue there and link back so others can see how this progresses. Thanks! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Upon adding class-validator to my Angular project, I get this warning when building:
WARNING in /node_modules/class-validator/esm2015/decorator/common/IsLatLong.js depends on 'validator'. CommonJS or AMD dependencies can cause optimization bailouts.
I am not using the
@IsLatLong()
decorator so I'm assuming the tree shaking/webpack will ignore this, but I just wanted to put a question out there for reassurance!The text was updated successfully, but these errors were encountered: